diff options
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.ts | 33 |
1 files changed, 22 insertions, 11 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 a2e7a6891..e80ffc059 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 @@ -154,9 +154,7 @@ async function handlePurseCreationConflict( await ws.db .mktx((x) => [x.peerPushDebit]) .runReadWrite(async (tx) => { - const myPpi = await tx.peerPushDebit.get( - peerPushInitiation.pursePub, - ); + const myPpi = await tx.peerPushDebit.get(peerPushInitiation.pursePub); if (!myPpi) { return; } @@ -182,10 +180,27 @@ async function processPeerPushDebitCreateReserve( ws: InternalWalletState, peerPushInitiation: PeerPushDebitRecord, ): Promise<TaskRunResult> { - logger.info("processing peer-push-debit pending(create-reserve)"); const pursePub = peerPushInitiation.pursePub; const purseExpiration = peerPushInitiation.purseExpiration; const hContractTerms = peerPushInitiation.contractTermsHash; + const transactionId = constructTransactionIdentifier({ + tag: TransactionType.PeerPushDebit, + pursePub: pursePub, + }); + + logger.trace(`processing ${transactionId} pending(create-reserve)`); + + const contractTermsRecord = await ws.db + .mktx((x) => [x.contractTerms]) + .runReadOnly(async (tx) => { + return tx.contractTerms.get(hContractTerms); + }); + + if (!contractTermsRecord) { + throw Error( + `db invariant failed, contract terms for ${transactionId} missing`, + ); + } const purseSigResp = await ws.cryptoApi.signPurseCreation({ hContractTerms, @@ -208,7 +223,7 @@ async function processPeerPushDebitCreateReserve( }); const encryptContractRequest: EncryptContractRequest = { - contractTerms: peerPushInitiation.contractTerms, + contractTerms: contractTermsRecord.contractTermsRaw, mergePriv: peerPushInitiation.mergePriv, pursePriv: peerPushInitiation.pursePriv, pursePub: peerPushInitiation.pursePub, @@ -329,9 +344,7 @@ async function processPeerPushDebitAbortingDeletePurse( if (!ppiRec) { return undefined; } - if ( - ppiRec.status !== PeerPushDebitStatus.AbortingDeletePurse - ) { + if (ppiRec.status !== PeerPushDebitStatus.AbortingDeletePurse) { return undefined; } const currency = Amounts.currencyOf(ppiRec.amount); @@ -658,7 +671,6 @@ export async function initiatePeerPushDebit( pursePub: pursePair.pub, timestampCreated: TalerPreciseTimestamp.now(), status: PeerPushDebitStatus.PendingCreatePurse, - contractTerms: contractTerms, contractEncNonce, coinSel: { coinPubs: sel.coins.map((x) => x.coinPub), @@ -881,8 +893,7 @@ export async function suspendPeerPushDebitTransaction( newStatus = PeerPushDebitStatus.SuspendedAbortingRefresh; break; case PeerPushDebitStatus.AbortingDeletePurse: - newStatus = - PeerPushDebitStatus.SuspendedAbortingDeletePurse; + newStatus = PeerPushDebitStatus.SuspendedAbortingDeletePurse; break; case PeerPushDebitStatus.PendingReady: newStatus = PeerPushDebitStatus.SuspendedReady; |