diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-03 01:33:25 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-03 01:36:06 +0100 |
commit | 8683c93613caa4047c4fd874aefb0b7d35fdc038 (patch) | |
tree | d8cbdab473e9f53119db4590f6543a5f0f8a39f8 /src/wallet-impl/balance.ts | |
parent | c33dd75711a39403bd4dd9940caab6d5e6ad2d77 (diff) | |
download | wallet-core-8683c93613caa4047c4fd874aefb0b7d35fdc038.tar.xz |
version bump / pending balance tweaks
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; |