From bfb20bef36e159a2a233d21c2c071162216373cc Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 2 Apr 2024 19:47:38 +0200 Subject: wallet-core: make refresh work again --- packages/taler-wallet-core/src/refresh.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts index 490b1b5f5..dbd81387b 100644 --- a/packages/taler-wallet-core/src/refresh.ts +++ b/packages/taler-wallet-core/src/refresh.ts @@ -989,12 +989,20 @@ async function refreshReveal( logger.warn("no refresh session found"); return; } + if (rg.statusPerCoin[coinIndex] !== RefreshCoinStatus.Pending) { + return; + } const rs = await tx.refreshSessions.get([refreshGroupId, coinIndex]); if (!rs) { return; } rg.statusPerCoin[coinIndex] = RefreshCoinStatus.Finished; for (const coin of coins) { + const existingCoin = await tx.coins.get(coin.coinPub); + if (existingCoin) { + continue; + } + await tx.coins.add(coin); const denomInfo = await getDenomInfo( wex, tx, @@ -1111,8 +1119,6 @@ export async function processRefreshGroup( ); rg.operationStatus = RefreshOperationStatus.Finished; } - } - if (allFinal) { await makeCoinsVisible(wex, tx, ctx.transactionId); await tx.refreshGroups.put(rg); const newTxState = computeRefreshTransactionState(rg); @@ -1120,9 +1126,8 @@ export async function processRefreshGroup( oldTxState, newTxState, }; - } else { - return undefined; } + return undefined; }, ); -- cgit v1.2.3