taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 19c41e767739a409083e93cd9a17ed6cce57f8e6
parent f72c1fcc314d534db443e0c50aec42a6810e04f1
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 17:28:48 +0200

wallet: ignore a repeated global currency entry on IndexedDB

The row id is generated, so putting a record that is already stored inserted a
second row and violated the unique index over the three identifying fields,
which aborts the whole transaction rather than just the one statement.  sqlite
already ignored the duplicate.

Diffstat:
Mpackages/taler-wallet-core/src/dbtx-indexeddb.ts | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/packages/taler-wallet-core/src/dbtx-indexeddb.ts b/packages/taler-wallet-core/src/dbtx-indexeddb.ts @@ -407,6 +407,17 @@ export class IdbWalletTransaction implements WalletDbTransaction { async upsertGlobalCurrencyExchange( rec: WalletGlobalCurrencyExchange, ): Promise<void> { + // The row id is generated, so putting a record that is already stored + // would insert a second row and violate the unique index over the three + // identifying fields, which aborts the whole transaction. + const existing = await this.getGlobalCurrencyExchange( + rec.currency, + rec.exchangeBaseUrl, + rec.exchangeMasterPub, + ); + if (existing) { + return; + } await this.tx.globalCurrencyExchanges.put(rec); }