diff options
author | Florian Dold <florian@dold.me> | 2023-09-12 13:48:52 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-09-12 13:49:24 +0200 |
commit | 4b0680eefa0dcb2e9b00342949393e4b166eecb2 (patch) | |
tree | 0681abaeacd7d1707d77677426f4f9f37831846a /packages/taler-wallet-core/src/operations/deposits.ts | |
parent | ee8993f11cf81721cc30b4473e40124c2fee0dff (diff) | |
download | wallet-core-4b0680eefa0dcb2e9b00342949393e4b166eecb2.tar.xz |
wallet-core: move contract terms to object store
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); }); |