aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptoLib.ts5
-rw-r--r--src/pages/tree.tsx5
-rw-r--r--src/types.ts18
-rw-r--r--src/wallet.ts22
-rw-r--r--src/wxBackend.ts2
5 files changed, 24 insertions, 28 deletions
diff --git a/src/cryptoLib.ts b/src/cryptoLib.ts
index 7a363e643..717a681f4 100644
--- a/src/cryptoLib.ts
+++ b/src/cryptoLib.ts
@@ -24,7 +24,7 @@
import * as native from "./emscriptif";
import {
PreCoinRecord, PayCoinInfo, AmountJson,
- RefreshSessionRecord, RefreshPreCoinRecord, ReserveRecord
+ RefreshSessionRecord, RefreshPreCoinRecord, ReserveRecord, CoinStatus,
} from "./types";
import create = chrome.alarms.create;
import {OfferRecord} from "./wallet";
@@ -210,8 +210,7 @@ namespace RpcFunctions {
let newAmount = new native.Amount(cd.coin.currentAmount);
newAmount.sub(coinSpend);
cd.coin.currentAmount = newAmount.toJson();
- cd.coin.dirty = true;
- cd.coin.transactionPending = true;
+ cd.coin.status = CoinStatus.TransactionPending;
let d = new native.DepositRequestPS({
h_contract: native.HashCode.fromCrock(offer.H_contract),
diff --git a/src/pages/tree.tsx b/src/pages/tree.tsx
index dab637147..4909c189b 100644
--- a/src/pages/tree.tsx
+++ b/src/pages/tree.tsx
@@ -21,7 +21,7 @@
*/
-import {ExchangeRecord, DenominationRecord} from "src/types";
+import {ExchangeRecord, DenominationRecord, CoinStatus} from "src/types";
import { ReserveRecord, CoinRecord, PreCoinRecord, Denomination } from "src/types";
import { ImplicitStateComponent, StateHolder } from "src/components";
import {
@@ -124,8 +124,7 @@ class CoinView extends React.Component<CoinViewProps, void> {
<li>Current amount: {prettyAmount(c.currentAmount)}</li>
<li>Denomination: <ExpanderText text={c.denomPub} /></li>
<li>Suspended: {(c.suspended || false).toString()}</li>
- <li>Dirty: {(c.dirty || false).toString()}</li>
- <li>Transaction Pending: {(c.transactionPending || false).toString()}</li>
+ <li>Status: {CoinStatus[c.status]}</li>
<li><RefreshDialog coin={c} /></li>
</ul>
</div>
diff --git a/src/types.ts b/src/types.ts
index 5b2fa285c..87b77b8ac 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -347,6 +347,12 @@ export interface CoinPaySig {
f: AmountJson;
}
+
+export enum CoinStatus {
+ Fresh, TransactionPending, Dirty, Refreshed,
+}
+
+
/**
* CoinRecord as stored in the "coins" data store
* of the wallet database.
@@ -391,17 +397,9 @@ export interface CoinRecord {
suspended?: boolean;
/**
- * Was the coin revealed in a transaction?
- */
- dirty: boolean;
-
- /**
- * Is the coin currently involved in a transaction?
- *
- * This delays refreshing until the transaction is finished or
- * aborted.
+ * Status of the coin.
*/
- transactionPending: boolean;
+ status: CoinStatus;
}
diff --git a/src/wallet.ts b/src/wallet.ts
index 916d8e1d1..b47a8257e 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -42,6 +42,7 @@ import {
WalletBalance,
WalletBalanceEntry,
WireInfo, DenominationRecord, DenominationStatus, denominationRecordFromKeys,
+ CoinStatus,
} from "./types";
import {
HttpRequestLibrary,
@@ -266,7 +267,7 @@ export function selectCoins(cds: CoinWithDenom[], paymentAmount: AmountJson,
if (coin.suspended) {
continue;
}
- if (coin.dirty) {
+ if (coin.status != CoinStatus.Fresh) {
continue;
}
if (Amounts.cmp(denom.feeDeposit, coin.currentAmount) >= 0) {
@@ -526,7 +527,7 @@ export class Wallet {
this.q()
.iter(Stores.coins)
.reduce((c: CoinRecord) => {
- if (c.dirty && !c.transactionPending && !(c.currentAmount.value == 0 && c.currentAmount.fraction == 0)) {
+ if (c.status == CoinStatus.Dirty) {
console.log("resuming pending refresh for coin", c);
this.refresh(c.coinPub);
}
@@ -581,10 +582,7 @@ export class Wallet {
if (coin.suspended) {
continue;
}
- if (coin.dirty) {
- continue;
- }
- if (coin.transactionPending) {
+ if (coin.status != CoinStatus.Fresh) {
continue;
}
cds.push({coin, denom});
@@ -989,8 +987,7 @@ export class Wallet {
denomSig: denomSig,
currentAmount: pc.coinValue,
exchangeBaseUrl: pc.exchangeBaseUrl,
- dirty: false,
- transactionPending: false,
+ status: CoinStatus.Fresh,
};
return coin;
}
@@ -1348,6 +1345,9 @@ export class Wallet {
if (c.suspended) {
return balance;
}
+ if (!(c.status == CoinStatus.Dirty || c.status == CoinStatus.Fresh)) {
+ return balance;
+ }
let currency = c.currentAmount.currency;
let entry = ensureEntry(balance, currency);
entry.available = Amounts.add(entry.available, c.currentAmount).amount;
@@ -1496,6 +1496,7 @@ export class Wallet {
throw AbortTransaction;
}
c.currentAmount = r.amount;
+ c.status = CoinStatus.Refreshed;
return c;
}
@@ -1667,8 +1668,7 @@ export class Wallet {
denomSig: denomSig,
currentAmount: denom.value,
exchangeBaseUrl: refreshSession.exchangeBaseUrl,
- dirty: false,
- transactionPending: false,
+ status: CoinStatus.Fresh,
};
coins.push(coin);
@@ -1787,7 +1787,7 @@ export class Wallet {
console.error("coin not found");
return;
}
- c.transactionPending = false;
+ c.status = CoinStatus.Dirty;
modifiedCoins.push(c);
}
diff --git a/src/wxBackend.ts b/src/wxBackend.ts
index 7b1a2b35e..f31472cca 100644
--- a/src/wxBackend.ts
+++ b/src/wxBackend.ts
@@ -35,7 +35,7 @@ import * as logging from "./logging";
"use strict";
const DB_NAME = "taler";
-const DB_VERSION = 15;
+const DB_VERSION = 16;
import {Stores} from "./wallet";
import {Store, Index} from "./query";