taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit b2ae1bbf6af45dead5beda488c473bd0dc71059a
parent d49407dfee1a4db99a6f721ae58ab59054fd96b8
Author: Florian Dold <florian@dold.me>
Date:   Mon, 23 Sep 2024 18:31:37 +0200

wallet-core: restore old, documented behavior for peer-push-debit fees

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts | 5+++--
Mpackages/taler-wallet-core/src/db.ts | 5-----
Mpackages/taler-wallet-core/src/pay-peer-push-debit.ts | 25+++++++------------------
3 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts @@ -83,7 +83,8 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) { }, ); - t.assertAmountEquals(checkResp0.amountEffective, "TESTKUDOS:5.3"); + t.assertAmountEquals(checkResp0.amountRaw, "TESTKUDOS:5"); + t.assertAmountEquals(checkResp0.amountEffective, "TESTKUDOS:5.49"); { const resp = await w1.walletClient.call( @@ -102,7 +103,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) { { const bal = await w1.walletClient.call(WalletApiOperation.GetBalances, {}); - t.assertAmountEquals(bal.balances[0].pendingOutgoing, "TESTKUDOS:5.3"); + t.assertAmountEquals(bal.balances[0].pendingOutgoing, "TESTKUDOS:5.49"); } await w1.walletClient.call(WalletApiOperation.TestingWaitRefreshesFinal, {}); diff --git 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 @@ -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") {