summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-01-14 18:00:00 +0100
committerFlorian Dold <florian@dold.me>2021-01-14 18:00:00 +0100
commit19eb72e277de89600506c2c7d1f14487ebe6408e (patch)
tree70b4d15291ad319abc302b09fc7cc4cd11361fb9 /packages/taler-wallet-core/src/operations/withdraw.ts
parent6293de7bfa4d8a52091b251e2333e9710ce1b22a (diff)
downloadwallet-core-19eb72e277de89600506c2c7d1f14487ebe6408e.tar.gz
wallet-core-19eb72e277de89600506c2c7d1f14487ebe6408e.tar.bz2
wallet-core-19eb72e277de89600506c2c7d1f14487ebe6408e.zip
logging, cosmetic fixes
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts30
1 files changed, 27 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index d28bea1e1..ffcc5ade6 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -67,6 +67,7 @@ import { TalerErrorCode } from "../TalerErrorCode";
import { encodeCrock } from "../crypto/talerCrypto";
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
import { compare } from "../util/libtoolVersion";
+import { j2s } from "../util/helpers";
const logger = new Logger("withdraw.ts");
@@ -207,7 +208,7 @@ export async function getBankWithdrawalInfo(
/**
* Return denominations that can potentially used for a withdrawal.
*/
-export async function getPossibleWithdrawalDenoms(
+export async function getCandidateWithdrawalDenoms(
ws: InternalWalletState,
exchangeBaseUrl: string,
): Promise<DenominationRecord[]> {
@@ -544,7 +545,7 @@ export async function updateWithdrawalDenoms(
logger.error("exchange details not available");
throw Error(`exchange ${exchangeBaseUrl} details not available`);
}
- const denominations = await getPossibleWithdrawalDenoms(ws, exchangeBaseUrl);
+ const denominations = await getCandidateWithdrawalDenoms(ws, exchangeBaseUrl);
for (const denom of denominations) {
if (denom.status === DenominationStatus.Unverified) {
const valid = await ws.cryptoApi.isValidDenom(
@@ -559,6 +560,29 @@ export async function updateWithdrawalDenoms(
await ws.db.put(Stores.denominations, denom);
}
}
+ // FIXME: This debug info should either be made conditional on some flag
+ // or put into some wallet-core API.
+ logger.trace("updated withdrawable denominations");
+ const nextDenominations = await getCandidateWithdrawalDenoms(
+ ws,
+ exchangeBaseUrl,
+ );
+ const now = getTimestampNow();
+ for (const denom of nextDenominations) {
+ const started = timestampCmp(now, denom.stampStart) >= 0;
+ const lastPossibleWithdraw = timestampSubtractDuraction(
+ denom.stampExpireWithdraw,
+ { d_ms: 50 * 1000 },
+ );
+ const remaining = getDurationRemaining(lastPossibleWithdraw, now);
+ logger.trace(
+ `Denom ${denom.denomPubHash} ${denom.status} revoked ${
+ denom.isRevoked
+ } offered ${denom.isOffered} remaining ${
+ (remaining.d_ms as number) / 1000
+ }sec started ${started}`,
+ );
+ }
}
async function incrementWithdrawalRetry(
@@ -725,7 +749,7 @@ export async function getExchangeWithdrawalInfo(
}
await updateWithdrawalDenoms(ws, baseUrl);
- const denoms = await getPossibleWithdrawalDenoms(ws, baseUrl);
+ const denoms = await getCandidateWithdrawalDenoms(ws, baseUrl);
const selectedDenoms = selectWithdrawalDenominations(amount, denoms);
const exchangeWireAccounts: string[] = [];
for (const account of exchangeWireInfo.accounts) {