From 7631db2a902664f475b9074e305a95b0ad71a9df Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 5 Jun 2024 19:09:29 +0200 Subject: wallet-core: fail refresh when denomination is unknown to exchange --- packages/taler-wallet-core/src/refresh.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts index f160e0731..7dcb755be 100644 --- a/packages/taler-wallet-core/src/refresh.ts +++ b/packages/taler-wallet-core/src/refresh.ts @@ -537,7 +537,10 @@ async function destroyRefreshSession( denom, oldCoin.maxAge, ); - checkDbInvariant(car.pendingRefreshOutputCount != null, `no pendingRefreshOutputCount for denom ${dph}`); + checkDbInvariant( + car.pendingRefreshOutputCount != null, + `no pendingRefreshOutputCount for denom ${dph}`, + ); car.pendingRefreshOutputCount = car.pendingRefreshOutputCount - refreshSession.newDenoms[i].count; await tx.coinAvailability.put(car); @@ -905,6 +908,7 @@ async function handleRefreshMeltNotFound( // with the coin. switch (errDetails.code) { case TalerErrorCode.EXCHANGE_GENERIC_COIN_UNKNOWN: + case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN: break; default: throwUnexpectedRequestError(resp, errDetails); @@ -1250,7 +1254,10 @@ async function refreshReveal( coin.exchangeBaseUrl, coin.denomPubHash, ); - checkDbInvariant(!!denomInfo, `no denom with hash ${coin.denomPubHash}`); + checkDbInvariant( + !!denomInfo, + `no denom with hash ${coin.denomPubHash}`, + ); const car = await getCoinAvailabilityForDenom( wex, tx, @@ -1260,7 +1267,7 @@ async function refreshReveal( checkDbInvariant( car.pendingRefreshOutputCount != null && car.pendingRefreshOutputCount > 0, - `no pendingRefreshOutputCount for denom ${coin.denomPubHash} age ${coin.maxAge}` + `no pendingRefreshOutputCount for denom ${coin.denomPubHash} age ${coin.maxAge}`, ); car.pendingRefreshOutputCount--; car.freshCoinCount++; @@ -1568,8 +1575,14 @@ async function applyRefreshToOldCoins( coin.denomPubHash, coin.maxAge, ]); - checkDbInvariant(!!coinAv, `no denom info for ${coin.denomPubHash} age ${coin.maxAge}`); - checkDbInvariant(coinAv.freshCoinCount > 0, `no fresh coins for ${coin.denomPubHash}`); + checkDbInvariant( + !!coinAv, + `no denom info for ${coin.denomPubHash} age ${coin.maxAge}`, + ); + checkDbInvariant( + coinAv.freshCoinCount > 0, + `no fresh coins for ${coin.denomPubHash}`, + ); coinAv.freshCoinCount--; await tx.coinAvailability.put(coinAv); break; -- cgit v1.2.3