From 828e65b0eba66b7c999d9867396797a239449a6d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 23 Aug 2021 22:28:36 +0200 Subject: fix un-offered denom situation, test case almost works --- packages/taler-wallet-core/src/operations/withdraw.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 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 81c35c17b..521cfa113 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -158,8 +158,8 @@ interface ExchangeWithdrawDetails { } /** - * Check if a denom is withdrawable based on the expiration time - * and revocation state. + * Check if a denom is withdrawable based on the expiration time, + * revocation and offered state. */ export function isWithdrawableDenom(d: DenominationRecord): boolean { const now = getTimestampNow(); @@ -175,7 +175,7 @@ export function isWithdrawableDenom(d: DenominationRecord): boolean { } const remaining = getDurationRemaining(lastPossibleWithdraw, now); const stillOkay = remaining.d_ms !== 0; - return started && stillOkay && !d.isRevoked; + return started && stillOkay && !d.isRevoked && d.isOffered; } /** @@ -230,6 +230,14 @@ export function selectWithdrawalDenominations( } } + if (logger.shouldLogTrace()) { + logger.trace(`selected withdrawal denoms for ${Amounts.stringify(totalCoinValue)}`); + for (const sd of selectedDenoms) { + logger.trace(`denom_pub_hash=${sd.denom.denomPubHash}, count=${sd.count}`); + } + logger.trace("(end of withdrawal denom list)"); + } + return { selectedDenoms, totalCoinValue, @@ -306,7 +314,8 @@ export async function getCandidateWithdrawalDenoms( return await ws.db .mktx((x) => ({ denominations: x.denominations })) .runReadOnly(async (tx) => { - return tx.denominations.indexes.byExchangeBaseUrl.getAll(exchangeBaseUrl); + const allDenoms = await tx.denominations.indexes.byExchangeBaseUrl.getAll(exchangeBaseUrl); + return allDenoms.filter(isWithdrawableDenom); }); } -- cgit v1.2.3