commit 528a32fff9138b4dcb53dad3cdcb9bbdf24f2dbc
parent 64d370a6b24eeef111c6d72acf8a5dcb2206192e
Author: Florian Dold <dold@taler.net>
Date: Thu, 6 Aug 2026 20:32:10 +0200
wallet: do not store a second reserve for a known reserve public key
A peer-credit withdrawal group draws on the exchange's merge reserve, which
already has a record; the reserves store is auto-increment, so storing the key
pair again added a row rather than updating that one.
Issue: https://bugs.taler.net/n/11718
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -3561,10 +3561,20 @@ export async function internalPerformCreateWithdrawalGroup(
};
}
await tx.upsertWithdrawalGroup(withdrawalGroup);
- await tx.upsertReserve({
- reservePub: withdrawalGroup.reservePub,
- reservePriv: withdrawalGroup.reservePriv,
- });
+ // A peer-credit withdrawal draws on the exchange's merge reserve, which has
+ // a reserve record already -- and one the exchange entry points at by row
+ // id, carrying its KYC state. The reserves store is auto-increment, so
+ // storing the same key pair again does not update that record, it adds a
+ // second one for the same reserve public key.
+ const knownReserve = await tx.getReserveByReservePub(
+ withdrawalGroup.reservePub,
+ );
+ if (!knownReserve) {
+ await tx.upsertReserve({
+ reservePub: withdrawalGroup.reservePub,
+ reservePriv: withdrawalGroup.reservePriv,
+ });
+ }
wex.taskScheduler.startShepherdTask(ctx.taskId);