diff options
author | Florian Dold <florian@dold.me> | 2023-06-05 17:58:20 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-05 17:58:25 +0200 |
commit | 9fca44893a6f7fcee5c828da5fc10e7d76592b5d (patch) | |
tree | 634830c7a769302d5e107f2aee323c3f705cf113 /packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | |
parent | 6e7c88a62073082b28ef563561d08f56acc0b017 (diff) | |
download | wallet-core-9fca44893a6f7fcee5c828da5fc10e7d76592b5d.tar.xz |
wallet-core: handle more p2p abort cases nicely
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 91b0b6022..1a79c7b87 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -553,76 +553,6 @@ export async function confirmPeerPushCredit( }; } -export async function processPeerPullDebit( - ws: InternalWalletState, - peerPullPaymentIncomingId: string, -): Promise<OperationAttemptResult> { - const peerPullInc = await ws.db - .mktx((x) => [x.peerPullPaymentIncoming]) - .runReadOnly(async (tx) => { - return tx.peerPullPaymentIncoming.get(peerPullPaymentIncomingId); - }); - if (!peerPullInc) { - throw Error("peer pull debit not found"); - } - if (peerPullInc.status === PeerPullDebitRecordStatus.PendingDeposit) { - const pursePub = peerPullInc.pursePub; - - const coinSel = peerPullInc.coinSel; - if (!coinSel) { - throw Error("invalid state, no coins selected"); - } - - const coins = await queryCoinInfosForSelection(ws, coinSel); - - const depositSigsResp = await ws.cryptoApi.signPurseDeposits({ - exchangeBaseUrl: peerPullInc.exchangeBaseUrl, - pursePub: peerPullInc.pursePub, - coins, - }); - - const purseDepositUrl = new URL( - `purses/${pursePub}/deposit`, - peerPullInc.exchangeBaseUrl, - ); - - const depositPayload: ExchangePurseDeposits = { - deposits: depositSigsResp.deposits, - }; - - if (logger.shouldLogTrace()) { - logger.trace(`purse deposit payload: ${j2s(depositPayload)}`); - } - - const httpResp = await ws.http.postJson( - purseDepositUrl.href, - depositPayload, - ); - const resp = await readSuccessResponseJsonOrThrow(httpResp, codecForAny()); - logger.trace(`purse deposit response: ${j2s(resp)}`); - } - - await ws.db - .mktx((x) => [x.peerPullPaymentIncoming]) - .runReadWrite(async (tx) => { - const pi = await tx.peerPullPaymentIncoming.get( - peerPullPaymentIncomingId, - ); - if (!pi) { - throw Error("peer pull payment not found anymore"); - } - if (pi.status === PeerPullDebitRecordStatus.PendingDeposit) { - pi.status = PeerPullDebitRecordStatus.DonePaid; - } - await tx.peerPullPaymentIncoming.put(pi); - }); - - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; -} - export async function suspendPeerPushCreditTransaction( ws: InternalWalletState, peerPushPaymentIncomingId: string, |