gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: wallet-core: only hand out ta


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: only hand out talerUri for push payments when the transaction is in the right state
Date: Thu, 16 Nov 2023 10:42:05 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new c5f63c097 wallet-core: only hand out talerUri for push payments when 
the transaction is in the right state
c5f63c097 is described below

commit c5f63c097a6f7b07edfa7a481ac37ea45966d04a
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Nov 16 10:42:05 2023 +0100

    wallet-core: only hand out talerUri for push payments when the transaction 
is in the right state
---
 packages/taler-util/src/transactions-types.ts      |  5 ++++-
 .../src/operations/transactions.ts                 | 23 ++++++++++++++--------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/packages/taler-util/src/transactions-types.ts 
b/packages/taler-util/src/transactions-types.ts
index 88830d82b..3a7f4d541 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -406,8 +406,11 @@ export interface TransactionPeerPushDebit extends 
TransactionCommon {
 
   /**
    * URI to accept the payment.
+   *
+   * Only present if the transaction is in a state where the other party can
+   * accept the payment.
    */
-  talerUri: string;
+  talerUri?: string;
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index a30120baa..7ee6275b0 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -66,6 +66,7 @@ import {
 } from "../db.js";
 import {
   GetReadOnlyAccess,
+  PeerPushDebitStatus,
   timestampPreciseFromDb,
   timestampProtocolFromDb,
   WalletStoresV1,
@@ -136,9 +137,9 @@ import {
 import {
   iterRecordsForDeposit,
   iterRecordsForPeerPullDebit,
-  iterRecordsForPeerPullInitiation,
+  iterRecordsForPeerPullInitiation as iterRecordsForPeerPullCredit,
   iterRecordsForPeerPushCredit,
-  iterRecordsForPeerPushInitiation,
+  iterRecordsForPeerPushInitiation as iterRecordsForPeerPushDebit,
   iterRecordsForPurchase,
   iterRecordsForRefresh,
   iterRecordsForRefund,
@@ -463,6 +464,15 @@ function buildTransactionForPushPaymentDebit(
   contractTerms: PeerContractTerms,
   ort?: OperationRetryRecord,
 ): Transaction {
+  let talerUri: string | undefined = undefined;
+  switch (pi.status) {
+    case PeerPushDebitStatus.PendingReady:
+    case PeerPushDebitStatus.SuspendedReady:
+      talerUri = stringifyPayPushUri({
+        exchangeBaseUrl: pi.exchangeBaseUrl,
+        contractPriv: pi.contractPriv,
+      });
+  }
   return {
     type: TransactionType.PeerPushDebit,
     txState: computePeerPushDebitTransactionState(pi),
@@ -475,10 +485,7 @@ function buildTransactionForPushPaymentDebit(
       summary: contractTerms.summary,
     },
     timestamp: timestampPreciseFromDb(pi.timestampCreated),
-    talerUri: stringifyPayPushUri({
-      exchangeBaseUrl: pi.exchangeBaseUrl,
-      contractPriv: pi.contractPriv,
-    }),
+    talerUri,
     transactionId: constructTransactionIdentifier({
       tag: TransactionType.PeerPushDebit,
       pursePub: pi.pursePub,
@@ -985,7 +992,7 @@ export async function getTransactions(
       x.refundGroups,
     ])
     .runReadOnly(async (tx) => {
-      await iterRecordsForPeerPushInitiation(tx, filter, async (pi) => {
+      await iterRecordsForPeerPushDebit(tx, filter, async (pi) => {
         const amount = Amounts.parseOrThrow(pi.amount);
 
         if (shouldSkipCurrency(transactionsRequest, amount.currency)) {
@@ -1073,7 +1080,7 @@ export async function getTransactions(
         );
       });
 
-      await iterRecordsForPeerPullInitiation(tx, filter, async (pi) => {
+      await iterRecordsForPeerPullCredit(tx, filter, async (pi) => {
         const currency = Amounts.currencyOf(pi.amount);
         if (shouldSkipCurrency(transactionsRequest, currency)) {
           return;

-- 
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]