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: handle 'never' t


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: handle 'never' timestamp in purse status
Date: Wed, 28 Jun 2023 11:10:40 +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 5bbf41ce1 wallet-core: handle 'never' timestamp in purse status
5bbf41ce1 is described below

commit 5bbf41ce1c01497d3efe6db63fba1c3d4688c1a8
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jun 28 11:10:35 2023 +0200

    wallet-core: handle 'never' timestamp in purse status
---
 packages/taler-util/src/time.ts                           |  4 ++++
 .../src/operations/pay-peer-pull-credit.ts                | 15 +++++++--------
 .../src/operations/pay-peer-push-debit.ts                 | 14 ++++++++++----
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts
index cf370fdad..3ecf6f92c 100644
--- a/packages/taler-util/src/time.ts
+++ b/packages/taler-util/src/time.ts
@@ -110,6 +110,10 @@ export namespace TalerProtocolTimestamp {
     };
   }
 
+  export function isNever(t: TalerProtocolTimestamp): boolean {
+    return t.t_s === "never";
+  }
+
   export function fromSeconds(s: number): TalerProtocolTimestamp {
     return {
       t_s: s,
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
index 725e3f3d9..88bdcb90e 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
@@ -29,6 +29,7 @@ import {
   NotificationType,
   TalerErrorCode,
   TalerPreciseTimestamp,
+  TalerProtocolTimestamp,
   TalerUriAction,
   TransactionAction,
   TransactionMajorState,
@@ -64,12 +65,11 @@ import { PendingTaskType } from "../pending-types.js";
 import { assertUnreachable } from "../util/assertUnreachable.js";
 import { checkDbInvariant } from "../util/invariants.js";
 import {
+  LongpollResult,
   OperationAttemptResult,
   OperationAttemptResultType,
   constructTaskIdentifier,
-  LongpollResult,
   runLongpollAsync,
-  runTaskWithErrorReporting,
 } from "./common.js";
 import {
   codecForExchangePurseStatus,
@@ -84,7 +84,6 @@ import {
 import {
   getExchangeWithdrawalInfo,
   internalCreateWithdrawalGroup,
-  processWithdrawalGroup,
 } from "./withdraw.js";
 
 const logger = new Logger("pay-peer-pull-credit.ts");
@@ -121,7 +120,9 @@ async function queryPurseForPeerPullCredit(
     }
   }
 
-  if (!result.response.deposit_timestamp) {
+  const depositTimestamp = result.response.deposit_timestamp;
+
+  if (!depositTimestamp || TalerProtocolTimestamp.isNever(depositTimestamp)) {
     logger.info("purse not ready yet (no deposit)");
     return { ready: false };
   }
@@ -314,9 +315,7 @@ async function handlePeerPullCreditWithdrawing(
   const transitionInfo = await ws.db
     .mktx((x) => [x.peerPullPaymentInitiations, x.withdrawalGroups])
     .runReadWrite(async (tx) => {
-      const ppi = await tx.peerPullPaymentInitiations.get(
-        pullIni.pursePub,
-      );
+      const ppi = await tx.peerPullPaymentInitiations.get(pullIni.pursePub);
       if (!ppi) {
         finished = true;
         return;
@@ -653,7 +652,7 @@ export async function checkPeerPullPaymentInitiation(
   let numCoins = 0;
   for (let i = 0; i < wi.selectedDenoms.selectedDenoms.length; i++) {
     numCoins += wi.selectedDenoms.selectedDenoms[i].count;
-  } 
+  }
 
   return {
     exchangeBaseUrl: exchangeUrl,
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
index a070eea50..424715efa 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
@@ -29,6 +29,7 @@ import {
   TalerError,
   TalerErrorCode,
   TalerPreciseTimestamp,
+  TalerProtocolTimestamp,
   TalerProtocolViolationError,
   TalerUriAction,
   TransactionAction,
@@ -479,8 +480,11 @@ async function processPeerPushDebitReady(
         resp,
         codecForExchangePurseStatus(),
       );
+      const mergeTimestamp = purseStatus.merge_timestamp;
       logger.info(`got purse status ${purseStatus}`);
-      if (purseStatus.merge_timestamp) {
+      if (!mergeTimestamp || TalerProtocolTimestamp.isNever(mergeTimestamp)) {
+        return { ready: false };
+      } else {
         await transitionPeerPushDebitTransaction(
           ws,
           peerPushInitiation.pursePub,
@@ -505,10 +509,12 @@ async function processPeerPushDebitReady(
       return {
         ready: true,
       };
+    } else {
+      logger.warn(`unexpected HTTP status for purse: ${resp.status}`);
+      return {
+        ready: false,
+      };
     }
-    return {
-      ready: false,
-    };
   });
   logger.trace(
     "returning early from peer-push-debit for long-polling in background",

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