From c493a3069ec330b955efd8604cb9d8b76277c74e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 13 Dec 2021 11:28:15 +0100 Subject: wallet-core: reset reserve retry when resetting withdrawal retry --- .../taler-wallet-core/src/operations/withdraw.ts | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts') diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 48d308b60..652b26c1e 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -854,7 +854,10 @@ async function resetWithdrawalGroupRetry( withdrawalGroupId: string, ): Promise { await ws.db - .mktx((x) => ({ withdrawalGroups: x.withdrawalGroups })) + .mktx((x) => ({ + withdrawalGroups: x.withdrawalGroups, + reserves: x.reserves, + })) .runReadWrite(async (tx) => { const x = await tx.withdrawalGroups.get(withdrawalGroupId); if (x) { @@ -879,8 +882,26 @@ async function processWithdrawGroupImpl( return tx.withdrawalGroups.get(withdrawalGroupId); }); if (!withdrawalGroup) { - logger.trace("withdraw session doesn't exist"); - return; + // Withdrawal group doesn't exist yet, but reserve might exist + // (and reference the yet to be created withdrawal group) + const reservePub = await ws.db + .mktx((x) => ({ reserves: x.reserves })) + .runReadOnly(async (tx) => { + const r = await tx.reserves.indexes.byInitialWithdrawalGroupId.get( + withdrawalGroupId, + ); + if (r) { + return r.reservePub; + } + return undefined; + }); + if (!reservePub) { + logger.warn( + "withdrawal group doesn't exist (and reserve doesn't exist either)", + ); + return; + } + return await ws.reserveOps.processReserve(ws, reservePub, forceNow); } await ws.exchangeOps.updateExchangeFromUrl( -- cgit v1.2.3