summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-01-06 17:06:19 +0100
committerFlorian Dold <florian@dold.me>2021-01-06 17:06:19 +0100
commit458777c5a2e66187cc3a8ac3e4a7557114886a4e (patch)
treefc99855431acd2e4c2138e242fa82396bf19d006 /packages/taler-wallet-core/src/operations
parentc032931f22e4d1b44e2a3af52c705db147129024 (diff)
downloadwallet-core-458777c5a2e66187cc3a8ac3e4a7557114886a4e.tar.gz
wallet-core-458777c5a2e66187cc3a8ac3e4a7557114886a4e.tar.bz2
wallet-core-458777c5a2e66187cc3a8ac3e4a7557114886a4e.zip
fix tipping planchet derivation
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts27
1 files changed, 17 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index f683999bc..68b5a2ad0 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -52,7 +52,7 @@ import { checkDbInvariant, checkLogicInvariant } from "../util/invariants";
import { TalerErrorCode } from "../TalerErrorCode";
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
import { j2s } from "../util/helpers";
-import { DerivedTipPlanchet } from '../types/cryptoTypes';
+import { DerivedTipPlanchet } from "../types/cryptoTypes";
const logger = new Logger("operations/tip.ts");
@@ -95,11 +95,11 @@ export async function prepareTip(
const walletTipId = encodeCrock(getRandomBytes(32));
await updateWithdrawalDenoms(ws, tipPickupStatus.exchange_url);
- const denoms = await getPossibleWithdrawalDenoms(ws, tipPickupStatus.exchange_url);
- const selectedDenoms = await selectWithdrawalDenominations(
- amount,
- denoms
+ const denoms = await getPossibleWithdrawalDenoms(
+ ws,
+ tipPickupStatus.exchange_url,
);
+ const selectedDenoms = selectWithdrawalDenominations(amount, denoms);
const secretSeed = encodeCrock(getRandomBytes(64));
@@ -213,7 +213,7 @@ async function processTipImpl(
const planchets: DerivedTipPlanchet[] = [];
// Planchets in the form that the merchant expects
const planchetsDetail: TipPlanchetDetail[] = [];
- const denomForPlanchet: { [index: number]: DenominationRecord} = [];
+ const denomForPlanchet: { [index: number]: DenominationRecord } = [];
for (const dh of denomsForWithdraw.selectedDenoms) {
const denom = await ws.db.get(Stores.denominations, [
@@ -222,11 +222,14 @@ async function processTipImpl(
]);
checkDbInvariant(!!denom, "denomination should be in database");
for (let i = 0; i < dh.count; i++) {
- const p = await ws.cryptoApi.createTipPlanchet({
+ const deriveReq = {
denomPub: denom.denomPub,
planchetIndex: planchets.length,
secretSeed: tipRecord.secretSeed,
- });
+ };
+ logger.trace(`deriving tip planchet: ${j2s(deriveReq)}`)
+ const p = await ws.cryptoApi.createTipPlanchet(deriveReq);
+ logger.trace(`derive result: ${j2s(p)}`);
denomForPlanchet[planchets.length] = denom;
planchets.push(p);
planchetsDetail.push({
@@ -242,14 +245,18 @@ async function processTipImpl(
);
const req = { planchets: planchetsDetail };
+ logger.trace(`sending tip request: ${j2s(req)}`);
const merchantResp = await ws.http.postJson(tipStatusUrl.href, req);
+ logger.trace(`got tip response, status ${merchantResp.status}`);
+
// Hide transient errors.
if (
tipRecord.retryInfo.retryCounter < 5 &&
- merchantResp.status >= 500 &&
- merchantResp.status <= 599
+ ((merchantResp.status >= 500 && merchantResp.status <= 599) ||
+ merchantResp.status === 424)
) {
+ logger.trace(`got transient tip error`);
const err = makeErrorDetails(
TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
"tip pickup failed (transient)",