diff options
author | Florian Dold <florian@dold.me> | 2022-10-15 11:52:07 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-15 11:53:16 +0200 |
commit | e075134ffc94fda3582b179122bda594d91a962b (patch) | |
tree | 547920b2aa07bdb9f2c87a0c1f8c35dbcd64c8f7 /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | 4d70391f3db386766a516bdecc3d1d265c5d49a1 (diff) | |
download | wallet-core-e075134ffc94fda3582b179122bda594d91a962b.tar.xz |
wallet-core: simplify coin record
we only track the allocation now, not the remaining amount
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 83ab32f20..c7d2c320e 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -23,8 +23,9 @@ import { amountToPretty, codecForExchangeMeltResponse, codecForExchangeRevealResponse, - CoinPublicKey, CoinPublicKeyString, + CoinRefreshRequest, + CoinStatus, DenominationInfo, DenomKeyType, Duration, @@ -55,9 +56,7 @@ import { CryptoApiStoppedError } from "../crypto/workers/cryptoDispatcher.js"; import { CoinRecord, CoinSourceType, - CoinStatus, DenominationRecord, - OperationStatus, RefreshCoinStatus, RefreshGroupRecord, RefreshOperationStatus, @@ -672,7 +671,6 @@ async function refreshReveal( blindingKey: pc.blindingKey, coinPriv: pc.coinPriv, coinPub: pc.coinPub, - currentAmount: ncd.value, denomPubHash: ncd.denomPubHash, denomSig, exchangeBaseUrl: oldCoin.exchangeBaseUrl, @@ -684,7 +682,7 @@ async function refreshReveal( coinEvHash: pc.coinEvHash, maxAge: pc.maxAge, ageCommitmentProof: pc.ageCommitmentProof, - allocation: undefined, + spendAllocation: undefined, }; coins.push(coin); @@ -845,7 +843,7 @@ export async function createRefreshGroup( refreshGroups: typeof WalletStoresV1.refreshGroups; coinAvailability: typeof WalletStoresV1.coinAvailability; }>, - oldCoinPubs: CoinPublicKey[], + oldCoinPubs: CoinRefreshRequest[], reason: RefreshReason, ): Promise<RefreshGroupId> { const refreshGroupId = encodeCrock(getRandomBytes(32)); @@ -908,9 +906,8 @@ export async function createRefreshGroup( default: assertUnreachable(coin.status); } - const refreshAmount = coin.currentAmount; + const refreshAmount = ocp.amount; inputPerCoin.push(refreshAmount); - coin.currentAmount = Amounts.getZero(refreshAmount.currency); await tx.coins.put(coin); const denoms = await getDenoms(coin.exchangeBaseUrl); const cost = getTotalRefreshCost(denoms, denom, refreshAmount); @@ -1008,7 +1005,7 @@ export async function autoRefresh( const coins = await tx.coins.indexes.byBaseUrl .iter(exchangeBaseUrl) .toArray(); - const refreshCoins: CoinPublicKey[] = []; + const refreshCoins: CoinRefreshRequest[] = []; for (const coin of coins) { if (coin.status !== CoinStatus.Fresh) { continue; @@ -1023,7 +1020,14 @@ export async function autoRefresh( } const executeThreshold = getAutoRefreshExecuteThreshold(denom); if (AbsoluteTime.isExpired(executeThreshold)) { - refreshCoins.push(coin); + refreshCoins.push({ + coinPub: coin.coinPub, + amount: { + value: denom.amountVal, + fraction: denom.amountFrac, + currency: denom.currency, + }, + }); } else { const checkThreshold = getAutoRefreshCheckThreshold(denom); minCheckThreshold = AbsoluteTime.min( |