diff options
author | Florian Dold <florian@dold.me> | 2024-09-23 18:31:37 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-09-23 18:31:37 +0200 |
commit | b2ae1bbf6af45dead5beda488c473bd0dc71059a (patch) | |
tree | 49bd5d7278d30f4b544f4a68bc001124d279d086 /packages/taler-wallet-core/src | |
parent | d49407dfee1a4db99a6f721ae58ab59054fd96b8 (diff) | |
download | wallet-core-b2ae1bbf6af45dead5beda488c473bd0dc71059a.tar.xz |
wallet-core: restore old, documented behavior for peer-push-debit fees
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/pay-peer-push-debit.ts | 25 |
2 files changed, 7 insertions, 23 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index a3c535c34..346e56c11 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1914,11 +1914,6 @@ export interface PeerPushDebitRecord { amount: AmountString; /** - * Optional for backwards compatibility (added 2024-09-12). - */ - amountPurse?: AmountString; - - /** * Effective amount. * * (Called totalCost for historical reasons.) diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts index e52dd3400..afe852b07 100644 --- a/packages/taler-wallet-core/src/pay-peer-push-debit.ts +++ b/packages/taler-wallet-core/src/pay-peer-push-debit.ts @@ -456,7 +456,7 @@ async function internalCheckPeerPushDebit( const coinSelRes = await selectPeerCoins(wex, { instructedAmount, restrictScope: req.restrictScope, - feesCoveredByCounterparty: true, + feesCoveredByCounterparty: false, }); let coins: SelectedProspectiveCoin[] | undefined = undefined; switch (coinSelRes.type) { @@ -529,9 +529,7 @@ async function handlePurseCreationConflict( } const coinSelRes = await selectPeerCoins(wex, { - instructedAmount: Amounts.parseOrThrow( - peerPushInitiation.amountPurse ?? peerPushInitiation.amount, - ), + instructedAmount: Amounts.parseOrThrow(peerPushInitiation.amount), restrictScope: peerPushInitiation.restrictScope, repair, feesCoveredByCounterparty: false, @@ -606,7 +604,7 @@ async function processPeerPushDebitCreateReserve( const coinSelRes = await selectPeerCoins(wex, { instructedAmount: Amounts.parseOrThrow(peerPushInitiation.amount), restrictScope: peerPushInitiation.restrictScope, - feesCoveredByCounterparty: true, + feesCoveredByCounterparty: false, }); switch (coinSelRes.type) { @@ -675,8 +673,7 @@ async function processPeerPushDebitCreateReserve( return TaskRunResult.backoff(); } - const purseAmount = - peerPushInitiation.amountPurse ?? peerPushInitiation.amount; + const purseAmount = peerPushInitiation.amount; const purseSigResp = await wex.cryptoApi.signPurseCreation({ hContractTerms, @@ -1237,6 +1234,8 @@ export async function initiatePeerPushDebit( const contractEncNonce = encodeCrock(getRandomBytes(24)); + const hContractTerms = ContractTermsUtil.hashContractTerms(contractTerms); + const res = await wex.db.runReadWriteTx( { storeNames: [ @@ -1257,7 +1256,7 @@ export async function initiatePeerPushDebit( const coinSelRes = await selectPeerCoinsInTx(wex, tx, { instructedAmount, restrictScope: req.restrictScope, - feesCoveredByCounterparty: true, + feesCoveredByCounterparty: false, }); let coins: SelectedProspectiveCoin[] | undefined = undefined; @@ -1284,15 +1283,6 @@ export async function initiatePeerPushDebit( const sel = coinSelRes.result; - // Adjust the contract terms amount. - // Change it from the instructed amount to the raw amount - // of the counterparty. - contractTerms.amount = Amounts.stringify( - Amounts.sub(instructedAmount, sel.totalDepositFees).amount, - ); - - const hContractTerms = ContractTermsUtil.hashContractTerms(contractTerms); - logger.trace( `peer debit instructed amount: ${Amounts.stringify(instructedAmount)}`, ); @@ -1322,7 +1312,6 @@ export async function initiatePeerPushDebit( status: PeerPushDebitStatus.PendingCreatePurse, contractEncNonce, totalCost: Amounts.stringify(totalAmount), - amountPurse: contractTerms.amount, }; if (coinSelRes.type === "success") { |