summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts17
1 files changed, 13 insertions, 4 deletions
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);
});
}