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/wallet.ts | |
parent | 4d70391f3db386766a516bdecc3d1d265c5d49a1 (diff) | |
download | wallet-core-e075134ffc94fda3582b179122bda594d91a962b.tar.gz wallet-core-e075134ffc94fda3582b179122bda594d91a962b.tar.bz2 wallet-core-e075134ffc94fda3582b179122bda594d91a962b.zip |
wallet-core: simplify coin record
we only track the allocation now, not the remaining amount
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index ef7a745ab..ef41c5101 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -95,6 +95,8 @@ import { WalletNotification, codecForSetDevModeRequest, ExchangeTosStatusDetails, + CoinRefreshRequest, + CoinStatus, } from "@gnu-taler/taler-util"; import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js"; import { @@ -105,11 +107,9 @@ import { clearDatabase } from "./db-utils.js"; import { AuditorTrustRecord, CoinSourceType, - CoinStatus, ConfigRecordKey, DenominationRecord, ExchangeDetailsRecord, - ExchangeTosRecord, exportDb, importDb, WalletStoresV1, @@ -934,10 +934,15 @@ async function dumpCoins(ws: InternalWalletState): Promise<CoinDumpJson> { }), exchange_base_url: c.exchangeBaseUrl, refresh_parent_coin_pub: refreshParentCoinPub, - remaining_value: Amounts.stringify(c.currentAmount), withdrawal_reserve_pub: withdrawalReservePub, - coin_suspended: c.status === CoinStatus.FreshSuspended, + coin_status: c.status, ageCommitmentProof: c.ageCommitmentProof, + spend_allocation: c.spendAllocation + ? { + amount: c.spendAllocation.amount, + id: c.spendAllocation.id, + } + : undefined, }); } }); @@ -1153,7 +1158,6 @@ async function dispatchRequestInternal( } case "forceRefresh": { const req = codecForForceRefreshRequest().decode(payload); - const coinPubs = req.coinPubList.map((x) => ({ coinPub: x })); const refreshGroupId = await ws.db .mktx((x) => [ x.refreshGroups, @@ -1162,6 +1166,24 @@ async function dispatchRequestInternal( x.coins, ]) .runReadWrite(async (tx) => { + let coinPubs: CoinRefreshRequest[] = []; + for (const c of req.coinPubList) { + const coin = await tx.coins.get(c); + if (!coin) { + throw Error(`coin (pubkey ${c}) not found`); + } + const denom = await ws.getDenomInfo( + ws, + tx, + coin.exchangeBaseUrl, + coin.denomPubHash, + ); + checkDbInvariant(!!denom); + coinPubs.push({ + coinPub: c, + amount: denom?.value, + }); + } return await createRefreshGroup( ws, tx, |