From fe011321a4b65bc0736634ee2a4d9c7bf0618351 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 2 Nov 2022 13:40:03 +0100 Subject: wallet-core: compute residual amount for recoup properly --- packages/taler-wallet-core/src/operations/refresh.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/refresh.ts') diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index e18faea32..ea0fae8bb 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -687,6 +687,7 @@ async function refreshReveal( status: CoinStatus.Fresh, coinSource: { type: CoinSourceType.Refresh, + refreshGroupId, oldCoinPub: refreshGroup.oldCoinPubs[coinIndex], }, coinEvHash: pc.coinEvHash, @@ -838,10 +839,6 @@ async function processRefreshSession( * Refreshes the remaining amount on the coin, effectively capturing the remaining * value in the refresh group. * - * The caller must ensure that - * the remaining amount was updated correctly before the coin was deposited or - * credited. - * * The caller must also ensure that the coins that should be refreshed exist * in the current database transaction. */ @@ -893,6 +890,10 @@ export async function createRefreshGroup( ); switch (coin.status) { case CoinStatus.Dormant: + coin.spendAllocation = { + amount: Amounts.stringify(ocp.amount), + id: `txn:refresh:${refreshGroupId}`, + }; break; case CoinStatus.Fresh: { coin.status = CoinStatus.Dormant; @@ -911,6 +912,10 @@ export async function createRefreshGroup( // For suspended coins, we don't have to adjust coin // availability, as they are not counted as available. coin.status = CoinStatus.Dormant; + coin.spendAllocation = { + amount: Amounts.stringify(ocp.amount), + id: `txn:refresh:${refreshGroupId}`, + }; break; } default: -- cgit v1.2.3