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 coin allocat


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix coin allocation when doing refresh
Date: Wed, 02 Nov 2022 19:05:09 +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 cc2122b50 wallet-core: fix coin allocation when doing refresh
cc2122b50 is described below

commit cc2122b50c7d8d0402c5c75228f4c1a241eaf4e0
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Nov 2 19:05:06 2022 +0100

    wallet-core: fix coin allocation when doing refresh
---
 packages/taler-wallet-core/src/operations/common.ts  |  2 ++
 packages/taler-wallet-core/src/operations/refresh.ts | 14 ++++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/common.ts 
b/packages/taler-wallet-core/src/operations/common.ts
index 73d1ee4b0..2323cb82c 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -142,6 +142,8 @@ export async function spendCoins(
       }
       if (alloc.id !== csi.allocationId) {
         // FIXME: assign error code
+        logger.info("conflicting coin allocation ID");
+        logger.info(`old ID: ${alloc.id}, new ID: ${csi.allocationId}`);
         throw Error("conflicting coin allocation (id)");
       }
       if (0 !== Amounts.cmp(alloc.amount, contrib)) {
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index c2f0f0360..806e4a246 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -890,10 +890,6 @@ export async function createRefreshGroup(
     );
     switch (coin.status) {
       case CoinStatus.Dormant:
-        coin.spendAllocation = {
-          amount: Amounts.stringify(ocp.amount),
-          id: `txn:refresh:${refreshGroupId}`,
-        };
         break;
       case CoinStatus.Fresh: {
         coin.status = CoinStatus.Dormant;
@@ -912,15 +908,17 @@ export async function createRefreshGroup(
         // For suspended coins, we don't have to adjust coin
         // availability, as they are not counted as available.
         coin.status = CoinStatus.Dormant;
-        coin.spendAllocation = {
-          amount: Amounts.stringify(ocp.amount),
-          id: `txn:refresh:${refreshGroupId}`,
-        };
         break;
       }
       default:
         assertUnreachable(coin.status);
     }
+    if (!coin.spendAllocation) {
+      coin.spendAllocation = {
+        amount: Amounts.stringify(ocp.amount),
+        id: `txn:refresh:${refreshGroupId}`,
+      };
+    }
     const refreshAmount = ocp.amount;
     inputPerCoin.push(Amounts.parseOrThrow(refreshAmount));
     await tx.coins.put(coin);

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