diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-09-12 13:54:44 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-09-12 13:54:44 +0200 |
commit | 64c19c8cde56699ab4aaf05a1ac6fea6a4e0e4ba (patch) | |
tree | 206f9968d8e4d5838d5b2b8dac1efcccb21dfc0e /packages/taler-wallet-core/src/operations/deposits.ts | |
parent | 121a6da78504204ddf34bf05b5136e09fab0261e (diff) | |
parent | 4b0680eefa0dcb2e9b00342949393e4b166eecb2 (diff) |
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index a3483a332..2de8f30a1 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -884,8 +884,18 @@ async function processDepositGroupPendingDeposit( ): Promise<TaskRunResult> { logger.info("processing deposit group in pending(deposit)"); const depositGroupId = depositGroup.depositGroupId; + const contractTermsRec = await ws.db + .mktx((x) => [x.contractTerms]) + .runReadOnly(async (tx) => { + return tx.contractTerms.get(depositGroup.contractTermsHash); + }); + if (!contractTermsRec) { + throw Error("contract terms for deposit not found in database"); + } + const contractTerms: MerchantContractTerms = + contractTermsRec.contractTermsRaw; const contractData = extractContractData( - depositGroup.contractTermsRaw, + contractTermsRec.contractTermsRaw, depositGroup.contractTermsHash, "", ); @@ -921,12 +931,11 @@ async function processDepositGroupPendingDeposit( coins, h_contract_terms: depositGroup.contractTermsHash, merchant_payto_uri: depositGroup.wire.payto_uri, - merchant_pub: depositGroup.contractTermsRaw.merchant_pub, - timestamp: depositGroup.contractTermsRaw.timestamp, + merchant_pub: contractTerms.merchant_pub, + timestamp: contractTerms.timestamp, wire_salt: depositGroup.wire.salt, - wire_transfer_deadline: - depositGroup.contractTermsRaw.wire_transfer_deadline, - refund_deadline: depositGroup.contractTermsRaw.refund_deadline, + wire_transfer_deadline: contractTerms.wire_transfer_deadline, + refund_deadline: contractTerms.refund_deadline, }; for (let i = 0; i < depositPermissions.length; i++) { @@ -1086,7 +1095,10 @@ async function trackDeposit( coinPub: string, exchangeUrl: string, ): Promise<TrackTransaction> { - const wireHash = depositGroup.contractTermsRaw.h_wire; + const wireHash = hashWire( + depositGroup.wire.payto_uri, + depositGroup.wire.salt, + ); const url = new URL( `deposits/${wireHash}/${depositGroup.merchantPub}/${depositGroup.contractTermsHash}/${coinPub}`, @@ -1358,8 +1370,9 @@ export async function createDepositGroup( const depositGroup: DepositGroupRecord = { contractTermsHash, - contractTermsRaw: contractTerms, depositGroupId, + currency: Amounts.currencyOf(totalDepositCost), + amount: contractData.amount, noncePriv: noncePair.priv, noncePub: noncePair.pub, timestampCreated: AbsoluteTime.toPreciseTimestamp(now), @@ -1375,6 +1388,7 @@ export async function createDepositGroup( counterpartyEffectiveDepositAmount: Amounts.stringify( counterpartyEffectiveDepositAmount, ), + wireTransferDeadline: contractTerms.wire_transfer_deadline, wire: { payto_uri: req.depositPaytoUri, salt: wireSalt, @@ -1395,6 +1409,7 @@ export async function createDepositGroup( x.denominations, x.refreshGroups, x.coinAvailability, + x.contractTerms, ]) .runReadWrite(async (tx) => { await spendCoins(ws, tx, { @@ -1406,6 +1421,10 @@ export async function createDepositGroup( refreshReason: RefreshReason.PayDeposit, }); await tx.depositGroups.put(depositGroup); + await tx.contractTerms.put({ + contractTermsRaw: contractTerms, + h: contractTermsHash, + }); return computeDepositTransactionStatus(depositGroup); }); |