gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 03/04: fix: missing total cost in peer pull payment


From: gnunet
Subject: [taler-wallet-core] 03/04: fix: missing total cost in peer pull payment
Date: Wed, 18 Jan 2023 21:33:18 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit 4bd9b1ba79af12d5916e0ab308acd40935a813ec
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Jan 18 17:31:34 2023 -0300

    fix: missing total cost in peer pull payment
---
 packages/taler-wallet-core/src/db.ts                      | 6 ++++++
 packages/taler-wallet-core/src/operations/pay-peer.ts     | 7 +++++++
 packages/taler-wallet-core/src/operations/transactions.ts | 4 +++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index d2d01e100..72e9aff04 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1864,6 +1864,12 @@ export interface PeerPullPaymentIncomingRecord {
    * Status of the peer push payment incoming initiation.
    */
   status: PeerPullPaymentIncomingStatus;
+
+  /**
+   * Total cost based on the coin selection.
+   * Non undefined after status === "Accepted"
+   */
+  totalCost: AmountString | undefined;
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts 
b/packages/taler-wallet-core/src/operations/pay-peer.ts
index 48434e452..7dc7b67fe 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer.ts
@@ -882,6 +882,11 @@ export async function acceptPeerPullPayment(
 
   const sel = coinSelRes.result;
 
+  const totalAmount = await getTotalPeerPaymentCost(
+    ws,
+    coinSelRes.result.coins,
+  );
+
   await ws.db
     .mktx((x) => [
       x.exchanges,
@@ -908,6 +913,7 @@ export async function acceptPeerPullPayment(
         throw Error();
       }
       pi.status = PeerPullPaymentIncomingStatus.Accepted;
+      pi.totalCost = Amounts.stringify(totalAmount);
       await tx.peerPullPaymentIncoming.put(pi);
     });
 
@@ -995,6 +1001,7 @@ export async function checkPeerPullPayment(
         timestampCreated: TalerProtocolTimestamp.now(),
         contractTerms: dec.contractTerms,
         status: PeerPullPaymentIncomingStatus.Proposed,
+        totalCost: undefined,
       });
     });
 
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 58def0f34..b94617851 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -380,7 +380,9 @@ function buildTransactionForPullPaymentDebit(
 ): Transaction {
   return {
     type: TransactionType.PeerPullDebit,
-    amountEffective: Amounts.stringify(pi.contractTerms.amount),
+    amountEffective: pi.totalCost
+      ? pi.totalCost
+      : Amounts.stringify(pi.contractTerms.amount),
     amountRaw: Amounts.stringify(pi.contractTerms.amount),
     exchangeBaseUrl: pi.exchangeBaseUrl,
     frozen: false,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]