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: allow confirmPee


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: allow confirmPeerPullDebit via txId
Date: Mon, 26 Jun 2023 12:53:35 +0200

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 eae357160 wallet-core: allow confirmPeerPullDebit via txId
eae357160 is described below

commit eae357160760fba990f705b092e30a0eec6f7b29
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Jun 26 12:53:32 2023 +0200

    wallet-core: allow confirmPeerPullDebit via txId
---
 packages/taler-util/src/wallet-types.ts            | 11 +++++++---
 .../src/operations/pay-peer-pull-debit.ts          | 24 ++++++++++++++++++----
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index 2e26b79ef..52ce87725 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -2409,7 +2409,7 @@ export const codecForCheckPeerPullPaymentRequest =
 export interface ConfirmPeerPushCreditRequest {
   /**
    * Transparent identifier of the incoming peer push payment.
-   * 
+   *
    * @deprecated specify transactionId instead!
    */
   peerPushPaymentIncomingId?: string;
@@ -2434,8 +2434,12 @@ export const codecForConfirmPeerPushPaymentRequest =
 export interface ConfirmPeerPullDebitRequest {
   /**
    * Transparent identifier of the incoming peer pull payment.
+   *
+   * @deprecated use transactionId instead
    */
-  peerPullPaymentIncomingId: string;
+  peerPullPaymentIncomingId?: string;
+
+  transactionId?: string;
 }
 
 export interface ApplyDevExperimentRequest {
@@ -2451,7 +2455,8 @@ export const codecForApplyDevExperiment =
 export const codecForAcceptPeerPullPaymentRequest =
   (): Codec<ConfirmPeerPullDebitRequest> =>
     buildCodecForObject<ConfirmPeerPullDebitRequest>()
-      .property("peerPullPaymentIncomingId", codecForString())
+      .property("peerPullPaymentIncomingId", codecOptional(codecForString()))
+      .property("transactionId", codecOptional(codecForString()))
       .build("ConfirmPeerPullDebitRequest");
 
 export interface CheckPeerPullCreditRequest {
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
index 322d9ca71..c7b59e6db 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
@@ -78,6 +78,7 @@ import {
 import {
   constructTransactionIdentifier,
   notifyTransition,
+  parseTransactionIdentifier,
   stopLongpolling,
 } from "./transactions.js";
 
@@ -387,10 +388,25 @@ export async function confirmPeerPullDebit(
   ws: InternalWalletState,
   req: ConfirmPeerPullDebitRequest,
 ): Promise<AcceptPeerPullPaymentResponse> {
+
+  let peerPullPaymentIncomingId: string;
+
+  if (req.transactionId) {
+    const parsedTx = parseTransactionIdentifier(req.transactionId);
+    if (!parsedTx || parsedTx.tag !== TransactionType.PeerPullDebit) {
+      throw Error("invalid peer-pull-debit transaction identifier");
+    }
+    peerPullPaymentIncomingId = parsedTx.peerPullPaymentIncomingId;
+  } else if (req.peerPullPaymentIncomingId) {
+    peerPullPaymentIncomingId = req.peerPullPaymentIncomingId;
+  } else {
+    throw Error("invalid request, transactionId or peerPullPaymentIncomingId 
required");
+  }
+
   const peerPullInc = await ws.db
     .mktx((x) => [x.peerPullPaymentIncoming])
     .runReadOnly(async (tx) => {
-      return tx.peerPullPaymentIncoming.get(req.peerPullPaymentIncomingId);
+      return tx.peerPullPaymentIncoming.get(peerPullPaymentIncomingId);
     });
 
   if (!peerPullInc) {
@@ -436,7 +452,7 @@ export async function confirmPeerPullDebit(
         // allocationId: 
`txn:peer-pull-debit:${req.peerPullPaymentIncomingId}`,
         allocationId: constructTransactionIdentifier({
           tag: TransactionType.PeerPullDebit,
-          peerPullPaymentIncomingId: req.peerPullPaymentIncomingId,
+          peerPullPaymentIncomingId,
         }),
         coinPubs: sel.coins.map((x) => x.coinPub),
         contributions: sel.coins.map((x) =>
@@ -446,7 +462,7 @@ export async function confirmPeerPullDebit(
       });
 
       const pi = await tx.peerPullPaymentIncoming.get(
-        req.peerPullPaymentIncomingId,
+        peerPullPaymentIncomingId,
       );
       if (!pi) {
         throw Error();
@@ -473,7 +489,7 @@ export async function confirmPeerPullDebit(
 
   const transactionId = constructTransactionIdentifier({
     tag: TransactionType.PeerPullDebit,
-    peerPullPaymentIncomingId: req.peerPullPaymentIncomingId,
+    peerPullPaymentIncomingId,
   });
 
   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]