aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-06-19 16:03:06 +0200
committerFlorian Dold <florian@dold.me>2023-06-19 16:03:06 +0200
commit54f0c82999833132baf83995526025ac56d6fe06 (patch)
treeb0138031c4a0432ec5ecddb62be14b0432112a4b /packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
parentffa68ce8ddc77bf622af4234696a065cde482554 (diff)
downloadwallet-core-54f0c82999833132baf83995526025ac56d6fe06.tar.xz
wallet-core: fix peer-(push,pull)-debit withdrawal states
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts25
1 files changed, 16 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
index 33d317c6f..fc7e868dc 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
@@ -125,15 +125,21 @@ async function handlePurseCreationConflict(
}
const instructedAmount = Amounts.parseOrThrow(peerPushInitiation.amount);
+ const sel = peerPushInitiation.coinSel;
const repair: PeerCoinRepair = {
- coinPubs: peerPushInitiation.coinSel.coinPubs,
- contribs: peerPushInitiation.coinSel.contributions.map((x) =>
- Amounts.parseOrThrow(x),
- ),
+ coinPubs: [],
+ contribs: [],
exchangeBaseUrl: peerPushInitiation.exchangeBaseUrl,
};
+ for (let i = 0; i < sel.coinPubs.length; i++) {
+ if (sel.coinPubs[i] != brokenCoinPub) {
+ repair.coinPubs.push(sel.coinPubs[i]);
+ repair.contribs.push(Amounts.parseOrThrow(sel.contributions[i]));
+ }
+ }
+
const coinSelRes = await selectPeerCoins(ws, { instructedAmount, repair });
if (coinSelRes.type == "failure") {
@@ -244,9 +250,10 @@ async function processPeerPushDebitCreateReserve(
body: reqBody,
});
- const resp = await httpResp.json();
-
- logger.info(`resp: ${j2s(resp)}`);
+ {
+ const resp = await httpResp.json();
+ logger.info(`resp: ${j2s(resp)}`);
+ }
switch (httpResp.status) {
case HttpStatusCode.Ok:
@@ -258,10 +265,10 @@ async function processPeerPushDebitCreateReserve(
}
case HttpStatusCode.Conflict: {
// Handle double-spending
- return handlePurseCreationConflict(ws, peerPushInitiation, resp);
+ return handlePurseCreationConflict(ws, peerPushInitiation, httpResp);
}
default: {
- const errResp = await readTalerErrorResponse(resp);
+ const errResp = await readTalerErrorResponse(httpResp);
return {
type: OperationAttemptResultType.Error,
errorDetail: errResp,