From 2cf33705c8ef95e04144b2a77cd4a79189136199 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 4 Jun 2017 20:16:09 +0200 Subject: warn about incompatible versions on withdraw --- src/wallet.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/wallet.ts') 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, @@ -151,6 +152,12 @@ export class KeysJson { @Checkable.Any 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) -- cgit v1.2.3