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: fix recoup issue


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix recoup issue
Date: Wed, 02 Nov 2022 12:50:37 +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 87bc4a6fc wallet-core: fix recoup issue
87bc4a6fc is described below

commit 87bc4a6fcd3b274f25ffe9a74196aa5f4f586b7e
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Nov 2 12:50:34 2022 +0100

    wallet-core: fix recoup issue
---
 .../taler-wallet-core/src/operations/recoup.ts     |  3 +-
 .../taler-wallet-core/src/operations/refresh.ts    | 10 ++++
 .../src/operations/transactions.ts                 | 54 ++++++++++++----------
 packages/taler-wallet-core/src/util/retries.ts     |  2 +-
 4 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/recoup.ts 
b/packages/taler-wallet-core/src/operations/recoup.ts
index d3bcde048..f16225295 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -281,7 +281,8 @@ async function recoupRefreshCoin(
       revokedCoin.status = CoinStatus.Dormant;
       recoupGroup.scheduleRefreshCoins.push({
         coinPub: oldCoin.coinPub,
-        amount: Amounts.sub(oldCoinDenom.value, revokedCoinDenom.value).amount,
+        //amount: Amounts.sub(oldCoinDenom.value, 
revokedCoinDenom.value).amount,
+        amount: revokedCoinDenom.value,
       });
       await tx.coins.put(revokedCoin);
       await tx.coins.put(oldCoin);
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index c7d2c320e..e18faea32 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -426,6 +426,16 @@ async function refreshMelt(
     return;
   }
 
+  if (resp.status === HttpStatusCode.Conflict) {
+    // Just log for better diagnostics here, error status
+    // will be handled later.
+    logger.error(
+      `melt request for ${Amounts.stringify(
+        derived.meltValueWithFee,
+      )} failed in refresh group ${refreshGroupId} due to conflict`,
+    );
+  }
+
   const meltResponse = await readSuccessResponseJsonOrThrow(
     resp,
     codecForExchangeMeltResponse(),
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 3f1d0a224..54cb84926 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -51,6 +51,7 @@ import {
   WalletContractData,
 } from "../db.js";
 import { InternalWalletState } from "../internal-wallet-state.js";
+import { assertUnreachable } from "../util/assertUnreachable.js";
 import { checkDbInvariant } from "../util/invariants.js";
 import { RetryTags } from "../util/retries.js";
 import {
@@ -803,33 +804,36 @@ export async function getTransactions(
         const opId = RetryTags.forWithdrawal(wsr);
         const ort = await tx.operationRetries.get(opId);
 
-        if (wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPullCredit) 
{
-          transactions.push(buildTransactionForPullPaymentCredit(wsr, ort));
-          return;
-        } else if (
-          wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPushCredit
-        ) {
-          transactions.push(buildTransactionForPushPaymentCredit(wsr, ort));
-          return;
-        } else if (
-          wsr.wgInfo.withdrawalType === WithdrawalRecordType.BankIntegrated
-        ) {
-          transactions.push(
-            buildTransactionForBankIntegratedWithdraw(wsr, ort),
-          );
-        } else {
-          const exchangeDetails = await getExchangeDetails(
-            tx,
-            wsr.exchangeBaseUrl,
-          );
-          if (!exchangeDetails) {
-            // FIXME: report somehow
+        switch (wsr.wgInfo.withdrawalType) {
+          case WithdrawalRecordType.PeerPullCredit:
+            transactions.push(buildTransactionForPullPaymentCredit(wsr, ort));
             return;
-          }
+          case WithdrawalRecordType.PeerPushCredit:
+            transactions.push(buildTransactionForPushPaymentCredit(wsr, ort));
+            return;
+          case WithdrawalRecordType.BankIntegrated:
+            transactions.push(
+              buildTransactionForBankIntegratedWithdraw(wsr, ort),
+            );
+            return;
+          case WithdrawalRecordType.BankManual: {
+            const exchangeDetails = await getExchangeDetails(
+              tx,
+              wsr.exchangeBaseUrl,
+            );
+            if (!exchangeDetails) {
+              // FIXME: report somehow
+              return;
+            }
 
-          transactions.push(
-            buildTransactionForManualWithdraw(wsr, exchangeDetails, ort),
-          );
+            transactions.push(
+              buildTransactionForManualWithdraw(wsr, exchangeDetails, ort),
+            );
+            return;
+          }
+          case WithdrawalRecordType.Recoup:
+            // FIXME: Do we also report a transaction here?
+            return;
         }
       });
 
diff --git a/packages/taler-wallet-core/src/util/retries.ts 
b/packages/taler-wallet-core/src/util/retries.ts
index 3597a4311..5e1089dc5 100644
--- a/packages/taler-wallet-core/src/util/retries.ts
+++ b/packages/taler-wallet-core/src/util/retries.ts
@@ -183,7 +183,7 @@ export namespace RetryTags {
     return `${PendingTaskType.TipPickup}:${tipRecord.walletTipId}`;
   }
   export function forRefresh(refreshGroupRecord: RefreshGroupRecord): string {
-    return `${PendingTaskType.TipPickup}:${refreshGroupRecord.refreshGroupId}`;
+    return `${PendingTaskType.Refresh}:${refreshGroupRecord.refreshGroupId}`;
   }
   export function forPay(purchaseRecord: PurchaseRecord): string {
     return `${PendingTaskType.Purchase}:${purchaseRecord.proposalId}`;

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