aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/refresh.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-11-02 13:40:03 +0100
committerFlorian Dold <florian@dold.me>2022-11-02 13:40:03 +0100
commitfe011321a4b65bc0736634ee2a4d9c7bf0618351 (patch)
tree5bf2b5b3eff072390c0a857431b1212fd6d134f2 /packages/taler-wallet-core/src/operations/refresh.ts
parent87bc4a6fcd3b274f25ffe9a74196aa5f4f586b7e (diff)
downloadwallet-core-fe011321a4b65bc0736634ee2a4d9c7bf0618351.tar.xz
wallet-core: compute residual amount for recoup properly
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index e18faea32..ea0fae8bb 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -687,6 +687,7 @@ async function refreshReveal(
status: CoinStatus.Fresh,
coinSource: {
type: CoinSourceType.Refresh,
+ refreshGroupId,
oldCoinPub: refreshGroup.oldCoinPubs[coinIndex],
},
coinEvHash: pc.coinEvHash,
@@ -838,10 +839,6 @@ async function processRefreshSession(
* Refreshes the remaining amount on the coin, effectively capturing the remaining
* value in the refresh group.
*
- * The caller must ensure that
- * the remaining amount was updated correctly before the coin was deposited or
- * credited.
- *
* The caller must also ensure that the coins that should be refreshed exist
* in the current database transaction.
*/
@@ -893,6 +890,10 @@ 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;
@@ -911,6 +912,10 @@ 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: