diff options
author | Florian Dold <florian@dold.me> | 2022-11-02 19:05:06 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-11-02 19:05:06 +0100 |
commit | cc2122b50c7d8d0402c5c75228f4c1a241eaf4e0 (patch) | |
tree | bca8c94e7574f6fc140e5935cbba9e473f81f3f3 /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | 566248aec417f6653e6245b96312f187517f0cdd (diff) |
wallet-core: fix coin allocation when doing refresh
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 14 |
1 files changed, 6 insertions, 8 deletions
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); |