aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-03 01:33:25 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-03 01:36:06 +0100
commit8683c93613caa4047c4fd874aefb0b7d35fdc038 (patch)
treed8cbdab473e9f53119db4590f6543a5f0f8a39f8 /src
parentc33dd75711a39403bd4dd9940caab6d5e6ad2d77 (diff)
downloadwallet-core-8683c93613caa4047c4fd874aefb0b7d35fdc038.tar.xz
version bump / pending balance tweaks
Diffstat (limited to 'src')
-rw-r--r--src/dbTypes.ts9
-rw-r--r--src/wallet-impl/balance.ts25
-rw-r--r--src/wallet-impl/history.ts2
-rw-r--r--src/wallet-impl/reserves.ts7
-rw-r--r--src/wallet-impl/tip.ts3
-rw-r--r--src/wallet-impl/withdraw.ts3
-rw-r--r--src/wallet.ts2
7 files changed, 36 insertions, 15 deletions
diff --git a/src/dbTypes.ts b/src/dbTypes.ts
index 4f374c260..66c4fa8b9 100644
--- a/src/dbTypes.ts
+++ b/src/dbTypes.ts
@@ -44,7 +44,7 @@ import { Timestamp, OperationError } from "./walletTypes";
* In the future we might consider adding migration functions for
* each version increment.
*/
-export const WALLET_DB_VERSION = 27;
+export const WALLET_DB_VERSION = 28;
export enum ReserveRecordStatus {
/**
@@ -1045,11 +1045,12 @@ export interface WithdrawalSessionRecord {
*/
finishTimestamp?: Timestamp;
+ totalCoinValue: AmountJson;
+
/**
- * Amount that is being withdrawn with this operation.
- * This does not include fees.
+ * Amount including fees.
*/
- withdrawalAmount: string;
+ rawWithdrawalAmount: AmountJson;
denoms: string[];
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;
diff --git a/src/wallet-impl/history.ts b/src/wallet-impl/history.ts
index f5a4e9d3e..dfc683e6d 100644
--- a/src/wallet-impl/history.ts
+++ b/src/wallet-impl/history.ts
@@ -61,7 +61,7 @@ export async function getHistory(
for (const w of withdrawals) {
history.push({
detail: {
- withdrawalAmount: w.withdrawalAmount,
+ withdrawalAmount: w.rawWithdrawalAmount,
},
timestamp: w.startTimestamp,
type: "withdraw",
diff --git a/src/wallet-impl/reserves.ts b/src/wallet-impl/reserves.ts
index c9cd10ca2..d70f02576 100644
--- a/src/wallet-impl/reserves.ts
+++ b/src/wallet-impl/reserves.ts
@@ -502,6 +502,8 @@ async function depleteReserve(
const withdrawalSessionId = encodeCrock(randomBytes(32));
+ const totalCoinValue = Amounts.sum(denomsForWithdraw.map(x => x.value)).amount;
+
const withdrawalRecord: WithdrawalSessionRecord = {
withdrawSessionId: withdrawalSessionId,
exchangeBaseUrl: reserve.exchangeBaseUrl,
@@ -509,15 +511,14 @@ async function depleteReserve(
type: "reserve",
reservePub: reserve.reservePub,
},
- withdrawalAmount: Amounts.toString(withdrawAmount),
+ rawWithdrawalAmount: withdrawAmount,
startTimestamp: getTimestampNow(),
denoms: denomsForWithdraw.map(x => x.denomPub),
withdrawn: denomsForWithdraw.map(x => false),
planchets: denomsForWithdraw.map(x => undefined),
+ totalCoinValue,
};
- const totalCoinValue = Amounts.sum(denomsForWithdraw.map(x => x.value))
- .amount;
const totalCoinWithdrawFee = Amounts.sum(
denomsForWithdraw.map(x => x.feeWithdraw),
).amount;
diff --git a/src/wallet-impl/tip.ts b/src/wallet-impl/tip.ts
index b102d026f..593f0d612 100644
--- a/src/wallet-impl/tip.ts
+++ b/src/wallet-impl/tip.ts
@@ -202,8 +202,9 @@ export async function processTip(
},
startTimestamp: getTimestampNow(),
withdrawSessionId: withdrawalSessionId,
- withdrawalAmount: Amounts.toString(tipRecord.amount),
+ rawWithdrawalAmount: tipRecord.amount,
withdrawn: planchets.map((x) => false),
+ totalCoinValue: Amounts.sum(planchets.map((p) => p.coinValue)).amount,
};
diff --git a/src/wallet-impl/withdraw.ts b/src/wallet-impl/withdraw.ts
index baeae1a50..d02ae14aa 100644
--- a/src/wallet-impl/withdraw.ts
+++ b/src/wallet-impl/withdraw.ts
@@ -143,9 +143,12 @@ export async function acceptWithdrawal(
senderWire: withdrawInfo.senderWire,
exchangeWire: exchangeWire,
});
+ ws.badge.showNotification();
+ ws.notifier.notify();
// We do this here, as the reserve should be registered before we return,
// so that we can redirect the user to the bank's status page.
await processReserveBankStatus(ws, reserve.reservePub);
+ ws.notifier.notify();
console.log("acceptWithdrawal: returning");
return {
reservePub: reserve.reservePub,
diff --git a/src/wallet.ts b/src/wallet.ts
index 432a3e989..89f31f519 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -120,7 +120,7 @@ import { AsyncCondition } from "./util/promiseUtils";
*/
export const WALLET_PROTOCOL_VERSION = "3:0:0";
-export const WALLET_CACHE_BREAKER_CLIENT_VERSION = "2";
+export const WALLET_CACHE_BREAKER_CLIENT_VERSION = "3";
const builtinCurrencies: CurrencyRecord[] = [
{