summaryrefslogtreecommitdiff
path: root/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-06-04 20:16:09 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-06-04 20:16:09 +0200
commit2cf33705c8ef95e04144b2a77cd4a79189136199 (patch)
treeb62b3b83d3b7fb951ba9ec00b676ff333ac73ef1 /src/wallet.ts
parent2b1e88737f6496fb0ad8790b501edaa1d556d83d (diff)
downloadwallet-core-2cf33705c8ef95e04144b2a77cd4a79189136199.tar.gz
wallet-core-2cf33705c8ef95e04144b2a77cd4a79189136199.tar.bz2
wallet-core-2cf33705c8ef95e04144b2a77cd4a79189136199.zip
warn about incompatible versions on withdraw
Diffstat (limited to 'src/wallet.ts')
-rw-r--r--src/wallet.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/wallet.ts b/src/wallet.ts
index b0029e755..2f5fa294e 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -34,6 +34,7 @@ import {
HttpRequestLibrary,
RequestException,
} from "./http";
+import * as LibtoolVersion from "./libtoolVersion";
import {
AbortTransaction,
Index,
@@ -152,6 +153,12 @@ export class KeysJson {
signkeys: any;
/**
+ * Protocol version.
+ */
+ @Checkable.Optional(Checkable.String)
+ version?: string;
+
+ /**
* Verify that a value matches the schema of this class and convert it into a
* member.
*/
@@ -1500,6 +1507,19 @@ export class Wallet {
trustedAuditorPubs.push(...currencyRecord.auditors.map((a) => a.auditorPub));
}
+ let versionMatch;
+ if (exchangeInfo.protocolVersion) {
+ versionMatch = LibtoolVersion.compare(WALLET_PROTOCOL_VERSION, exchangeInfo.protocolVersion);
+
+ if (versionMatch && !versionMatch.compatible && versionMatch.currentCmp == -1) {
+ console.log("wallet version might be outdated, checking for updates");
+ chrome.runtime.requestUpdateCheck((status, details) => {
+ console.log("update check status:", status);
+ });
+ }
+ }
+
+
const ret: ReserveCreationInfo = {
earliestDepositExpiration,
exchangeInfo,
@@ -1512,6 +1532,7 @@ export class Wallet {
wireFees,
wireInfo,
withdrawFee: acc,
+ versionMatch,
};
return ret;
}
@@ -1610,8 +1631,9 @@ export class Wallet {
}
const updatedExchangeInfo = await this.updateExchangeInfo(exchangeInfo,
- exchangeKeysJson);
+ exchangeKeysJson);
await this.suspendCoins(updatedExchangeInfo);
+ updatedExchangeInfo.protocolVersion = exchangeKeysJson.version;
await this.q()
.put(Stores.exchanges, updatedExchangeInfo)