diff options
Diffstat (limited to 'src/wallet-impl/balance.ts')
-rw-r--r-- | src/wallet-impl/balance.ts | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/wallet-impl/balance.ts b/src/wallet-impl/balance.ts index 0abc96637..94d65fa96 100644 --- a/src/wallet-impl/balance.ts +++ b/src/wallet-impl/balance.ts @@ -17,10 +17,7 @@ /** * Imports. */ -import { - WalletBalance, - WalletBalanceEntry, -} from "../walletTypes"; +import { WalletBalance, WalletBalanceEntry } from "../walletTypes"; import { runWithReadTransaction } from "../util/query"; import { InternalWalletState } from "./state"; import { Stores, TipRecord, CoinStatus } from "../dbTypes"; @@ -77,7 +74,7 @@ export async function getBalances( await runWithReadTransaction( ws.db, - [Stores.coins, Stores.refresh, Stores.reserves, Stores.purchases], + [Stores.coins, Stores.refresh, Stores.reserves, Stores.purchases, Stores.withdrawalSession], async tx => { await tx.iter(Stores.coins).forEach(c => { if (c.suspended) { @@ -121,6 +118,24 @@ export async function getBalances( ); }); + await tx.iter(Stores.withdrawalSession).forEach(wds => { + let w = wds.totalCoinValue; + for (let i = 0; i < wds.planchets.length; i++) { + if (wds.withdrawn[i]) { + const p = wds.planchets[i]; + if (p) { + w = Amounts.sub(w, p.coinValue).amount; + } + } + } + addTo( + balanceStore, + "pendingIncoming", + w, + wds.exchangeBaseUrl, + ); + }); + await tx.iter(Stores.purchases).forEach(t => { if (t.finished) { return; |