summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-08-23 22:28:36 +0200
committerFlorian Dold <florian@dold.me>2021-08-23 22:28:46 +0200
commit828e65b0eba66b7c999d9867396797a239449a6d (patch)
tree2dcb55dfb5c9854c196fc21d0d5282928de12ff6 /packages/taler-wallet-core/src/operations/withdraw.ts
parent67e511d719cbc3e7f2b391a8d6914406caa2fb24 (diff)
downloadwallet-core-828e65b0eba66b7c999d9867396797a239449a6d.tar.gz
wallet-core-828e65b0eba66b7c999d9867396797a239449a6d.tar.bz2
wallet-core-828e65b0eba66b7c999d9867396797a239449a6d.zip
fix un-offered denom situation, test case almost works
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);
});
}