gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: fix: withdrawal error when cr


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix: withdrawal error when creating an invoice
Date: Wed, 18 Jan 2023 17:12:47 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 5e129abe9 fix: withdrawal error when creating an invoice
5e129abe9 is described below

commit 5e129abe9e8d71c2fa67bc542684f49b76551379
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Jan 18 13:12:38 2023 -0300

    fix: withdrawal error when creating an invoice
---
 .../src/operations/transactions.ts                 | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 3db548fa3..58def0f34 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -29,6 +29,7 @@ import {
   PaymentStatus,
   PeerContractTerms,
   RefundInfoShort,
+  TalerErrorCode,
   TalerProtocolTimestamp,
   Transaction,
   TransactionByIdRequest,
@@ -402,8 +403,23 @@ function buildTransactionForPullPaymentCredit(
   wsr: WithdrawalGroupRecord,
   ort?: OperationRetryRecord,
 ): Transaction {
-  if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.PeerPullCredit)
-    throw Error("");
+  if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.PeerPullCredit) {
+    throw Error(`Unexpected withdrawalType: ${wsr.wgInfo.withdrawalType}`);
+  }
+  /**
+   * FIXME: this should be handled in the withdrawal process.
+   * PeerPull withdrawal fails until reserve have funds but it is not
+   * an error from the user perspective.
+   */
+  const silentWithdrawalErrorForInvoice =
+    ort?.lastError &&
+    ort.lastError.code === TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
+    Object.values(ort.lastError.errorsPerCoin ?? {}).every((e) => {
+      return (
+        e.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR &&
+        e.httpStatusCode === 409
+      );
+    });
   return {
     type: TransactionType.PeerPullCredit,
     amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
@@ -427,7 +443,9 @@ function buildTransactionForPullPaymentCredit(
       wsr.withdrawalGroupId,
     ),
     frozen: false,
-    ...(ort?.lastError ? { error: ort.lastError } : {}),
+    ...(ort?.lastError
+      ? { error: silentWithdrawalErrorForInvoice ? undefined : ort.lastError }
+      : {}),
   };
 }
 

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