warn about incompatible versions on withdraw

This commit is contained in:
Florian Dold 2017-06-04 20:16:09 +02:00
parent 2b1e88737f
commit 2cf33705c8
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
11 changed files with 131 additions and 43 deletions

2
.gitignore vendored
View File

@ -6,3 +6,5 @@ dist/
# Even though node_modules are tracked in git, # Even though node_modules are tracked in git,
# per default we don't want them to show up in git status # per default we don't want them to show up in git status
node_modules node_modules
*.swp

View File

@ -151,44 +151,44 @@ msgid ""
"selected." "selected."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:424 #: src/webex/pages/confirm-create-reserve.tsx:455
#, c-format #, c-format
msgid "Accept fees and withdraw" msgid "Accept fees and withdraw"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:429 #: src/webex/pages/confirm-create-reserve.tsx:460
#, c-format #, c-format
msgid "Change Exchange Provider" msgid "Change Exchange Provider"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:485 #: src/webex/pages/confirm-create-reserve.tsx:517
#, c-format #, c-format
msgid "You are about to withdraw %1$s from your bank account into your wallet." msgid "You are about to withdraw %1$s from your bank account into your wallet."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:568 #: src/webex/pages/confirm-create-reserve.tsx:600
#, c-format #, c-format
msgid "" msgid ""
"Oops, something went wrong. The wallet responded with error status (%1$s)." "Oops, something went wrong. The wallet responded with error status (%1$s)."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:579 #: src/webex/pages/confirm-create-reserve.tsx:611
#, c-format #, c-format
msgid "Checking URL, please wait ..." msgid "Checking URL, please wait ..."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:593 #: src/webex/pages/confirm-create-reserve.tsx:625
#, c-format #, c-format
msgid "Can't parse amount: %1$s" msgid "Can't parse amount: %1$s"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:600 #: src/webex/pages/confirm-create-reserve.tsx:632
#, c-format #, c-format
msgid "Can't parse wire_types: %1$s" msgid "Can't parse wire_types: %1$s"
msgstr "" msgstr ""
#. TODO:generic error reporting function or component. #. TODO:generic error reporting function or component.
#: src/webex/pages/confirm-create-reserve.tsx:620 #: src/webex/pages/confirm-create-reserve.tsx:652
#, c-format #, c-format
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""

View File

@ -151,44 +151,44 @@ msgid ""
"selected." "selected."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:424 #: src/webex/pages/confirm-create-reserve.tsx:455
#, c-format #, c-format
msgid "Accept fees and withdraw" msgid "Accept fees and withdraw"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:429 #: src/webex/pages/confirm-create-reserve.tsx:460
#, c-format #, c-format
msgid "Change Exchange Provider" msgid "Change Exchange Provider"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:485 #: src/webex/pages/confirm-create-reserve.tsx:517
#, c-format #, c-format
msgid "You are about to withdraw %1$s from your bank account into your wallet." msgid "You are about to withdraw %1$s from your bank account into your wallet."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:568 #: src/webex/pages/confirm-create-reserve.tsx:600
#, c-format #, c-format
msgid "" msgid ""
"Oops, something went wrong. The wallet responded with error status (%1$s)." "Oops, something went wrong. The wallet responded with error status (%1$s)."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:579 #: src/webex/pages/confirm-create-reserve.tsx:611
#, c-format #, c-format
msgid "Checking URL, please wait ..." msgid "Checking URL, please wait ..."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:593 #: src/webex/pages/confirm-create-reserve.tsx:625
#, c-format #, c-format
msgid "Can't parse amount: %1$s" msgid "Can't parse amount: %1$s"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:600 #: src/webex/pages/confirm-create-reserve.tsx:632
#, c-format #, c-format
msgid "Can't parse wire_types: %1$s" msgid "Can't parse wire_types: %1$s"
msgstr "" msgstr ""
#. TODO:generic error reporting function or component. #. TODO:generic error reporting function or component.
#: src/webex/pages/confirm-create-reserve.tsx:620 #: src/webex/pages/confirm-create-reserve.tsx:652
#, c-format #, c-format
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""

View File

@ -151,44 +151,44 @@ msgid ""
"selected." "selected."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:424 #: src/webex/pages/confirm-create-reserve.tsx:455
#, c-format #, c-format
msgid "Accept fees and withdraw" msgid "Accept fees and withdraw"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:429 #: src/webex/pages/confirm-create-reserve.tsx:460
#, c-format #, c-format
msgid "Change Exchange Provider" msgid "Change Exchange Provider"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:485 #: src/webex/pages/confirm-create-reserve.tsx:517
#, c-format #, c-format
msgid "You are about to withdraw %1$s from your bank account into your wallet." msgid "You are about to withdraw %1$s from your bank account into your wallet."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:568 #: src/webex/pages/confirm-create-reserve.tsx:600
#, c-format #, c-format
msgid "" msgid ""
"Oops, something went wrong. The wallet responded with error status (%1$s)." "Oops, something went wrong. The wallet responded with error status (%1$s)."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:579 #: src/webex/pages/confirm-create-reserve.tsx:611
#, c-format #, c-format
msgid "Checking URL, please wait ..." msgid "Checking URL, please wait ..."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:593 #: src/webex/pages/confirm-create-reserve.tsx:625
#, c-format #, c-format
msgid "Can't parse amount: %1$s" msgid "Can't parse amount: %1$s"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:600 #: src/webex/pages/confirm-create-reserve.tsx:632
#, c-format #, c-format
msgid "Can't parse wire_types: %1$s" msgid "Can't parse wire_types: %1$s"
msgstr "" msgstr ""
#. TODO:generic error reporting function or component. #. TODO:generic error reporting function or component.
#: src/webex/pages/confirm-create-reserve.tsx:620 #: src/webex/pages/confirm-create-reserve.tsx:652
#, c-format #, c-format
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""

View File

@ -151,44 +151,44 @@ msgid ""
"selected." "selected."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:424 #: src/webex/pages/confirm-create-reserve.tsx:455
#, c-format #, c-format
msgid "Accept fees and withdraw" msgid "Accept fees and withdraw"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:429 #: src/webex/pages/confirm-create-reserve.tsx:460
#, c-format #, c-format
msgid "Change Exchange Provider" msgid "Change Exchange Provider"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:485 #: src/webex/pages/confirm-create-reserve.tsx:517
#, c-format #, c-format
msgid "You are about to withdraw %1$s from your bank account into your wallet." msgid "You are about to withdraw %1$s from your bank account into your wallet."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:568 #: src/webex/pages/confirm-create-reserve.tsx:600
#, c-format #, c-format
msgid "" msgid ""
"Oops, something went wrong. The wallet responded with error status (%1$s)." "Oops, something went wrong. The wallet responded with error status (%1$s)."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:579 #: src/webex/pages/confirm-create-reserve.tsx:611
#, c-format #, c-format
msgid "Checking URL, please wait ..." msgid "Checking URL, please wait ..."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:593 #: src/webex/pages/confirm-create-reserve.tsx:625
#, c-format #, c-format
msgid "Can't parse amount: %1$s" msgid "Can't parse amount: %1$s"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:600 #: src/webex/pages/confirm-create-reserve.tsx:632
#, c-format #, c-format
msgid "Can't parse wire_types: %1$s" msgid "Can't parse wire_types: %1$s"
msgstr "" msgstr ""
#. TODO:generic error reporting function or component. #. TODO:generic error reporting function or component.
#: src/webex/pages/confirm-create-reserve.tsx:620 #: src/webex/pages/confirm-create-reserve.tsx:652
#, c-format #, c-format
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""

View File

@ -151,44 +151,44 @@ msgid ""
"selected." "selected."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:424 #: src/webex/pages/confirm-create-reserve.tsx:455
#, c-format #, c-format
msgid "Accept fees and withdraw" msgid "Accept fees and withdraw"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:429 #: src/webex/pages/confirm-create-reserve.tsx:460
#, c-format #, c-format
msgid "Change Exchange Provider" msgid "Change Exchange Provider"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:485 #: src/webex/pages/confirm-create-reserve.tsx:517
#, c-format #, c-format
msgid "You are about to withdraw %1$s from your bank account into your wallet." msgid "You are about to withdraw %1$s from your bank account into your wallet."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:568 #: src/webex/pages/confirm-create-reserve.tsx:600
#, c-format #, c-format
msgid "" msgid ""
"Oops, something went wrong. The wallet responded with error status (%1$s)." "Oops, something went wrong. The wallet responded with error status (%1$s)."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:579 #: src/webex/pages/confirm-create-reserve.tsx:611
#, c-format #, c-format
msgid "Checking URL, please wait ..." msgid "Checking URL, please wait ..."
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:593 #: src/webex/pages/confirm-create-reserve.tsx:625
#, c-format #, c-format
msgid "Can't parse amount: %1$s" msgid "Can't parse amount: %1$s"
msgstr "" msgstr ""
#: src/webex/pages/confirm-create-reserve.tsx:600 #: src/webex/pages/confirm-create-reserve.tsx:632
#, c-format #, c-format
msgid "Can't parse wire_types: %1$s" msgid "Can't parse wire_types: %1$s"
msgstr "" msgstr ""
#. TODO:generic error reporting function or component. #. TODO:generic error reporting function or component.
#: src/webex/pages/confirm-create-reserve.tsx:620 #: src/webex/pages/confirm-create-reserve.tsx:652
#, c-format #, c-format
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""

View File

@ -27,6 +27,7 @@
* Imports. * Imports.
*/ */
import { Checkable } from "./checkable"; import { Checkable } from "./checkable";
import * as LibtoolVersion from "./libtoolVersion";
/** /**
* Non-negative financial amount. Fractional values are expressed as multiples * Non-negative financial amount. Fractional values are expressed as multiples
@ -492,6 +493,11 @@ export interface ExchangeRecord {
* Timestamp for last update. * Timestamp for last update.
*/ */
lastUpdateTime: number; lastUpdateTime: number;
/**
* Last observed protocol version.
*/
protocolVersion?: string;
} }
/** /**
@ -558,6 +564,13 @@ export interface ReserveCreationInfo {
* Public keys of trusted auditors for the currency we're withdrawing. * Public keys of trusted auditors for the currency we're withdrawing.
*/ */
trustedAuditorPubs: string[]; trustedAuditorPubs: string[];
/**
* Result of checking the wallet's version
* against the exchange's version.
*
* Older exchanges don't return version information.
*/
versionMatch: LibtoolVersion.VersionMatchResult|undefined;
} }

View File

@ -34,6 +34,7 @@ import {
HttpRequestLibrary, HttpRequestLibrary,
RequestException, RequestException,
} from "./http"; } from "./http";
import * as LibtoolVersion from "./libtoolVersion";
import { import {
AbortTransaction, AbortTransaction,
Index, Index,
@ -151,6 +152,12 @@ export class KeysJson {
@Checkable.Any @Checkable.Any
signkeys: 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 * Verify that a value matches the schema of this class and convert it into a
* member. * member.
@ -1500,6 +1507,19 @@ export class Wallet {
trustedAuditorPubs.push(...currencyRecord.auditors.map((a) => a.auditorPub)); 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 = { const ret: ReserveCreationInfo = {
earliestDepositExpiration, earliestDepositExpiration,
exchangeInfo, exchangeInfo,
@ -1512,6 +1532,7 @@ export class Wallet {
wireFees, wireFees,
wireInfo, wireInfo,
withdrawFee: acc, withdrawFee: acc,
versionMatch,
}; };
return ret; return ret;
} }
@ -1610,8 +1631,9 @@ export class Wallet {
} }
const updatedExchangeInfo = await this.updateExchangeInfo(exchangeInfo, const updatedExchangeInfo = await this.updateExchangeInfo(exchangeInfo,
exchangeKeysJson); exchangeKeysJson);
await this.suspendCoins(updatedExchangeInfo); await this.suspendCoins(updatedExchangeInfo);
updatedExchangeInfo.protocolVersion = exchangeKeysJson.version;
await this.q() await this.q()
.put(Stores.exchanges, updatedExchangeInfo) .put(Stores.exchanges, updatedExchangeInfo)

View File

@ -414,10 +414,41 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
); );
} }
renderUpdateStatus() {
const rci = this.reserveCreationInfo();
if (!rci) {
return null;
}
if (!rci.versionMatch) {
return null;
}
if (rci.versionMatch.compatible) {
return null;
}
if (rci.versionMatch.currentCmp == -1) {
return (
<p className="errorbox">
Your wallet might be outdated. The exchange has a higher, incompatible
protocol version.
</p>
);
}
if (rci.versionMatch.currentCmp == 1) {
return (
<p className="errorbox">
The chosen exchange might be outdated. The exchange has a lower, incompatible
protocol version.
</p>
);
}
throw Error("not reached");
}
renderConfirm() { renderConfirm() {
return ( return (
<div> <div>
{this.renderFeeStatus()} {this.renderFeeStatus()}
<p>
<button className="pure-button button-success" <button className="pure-button button-success"
disabled={this.reserveCreationInfo() === null} disabled={this.reserveCreationInfo() === null}
onClick={() => this.confirmReserve()}> onClick={() => this.confirmReserve()}>
@ -428,7 +459,8 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
onClick={() => this.selectingExchange(true)}> onClick={() => this.selectingExchange(true)}>
{i18n.str`Change Exchange Provider`} {i18n.str`Change Exchange Provider`}
</button> </button>
<br/> </p>
{this.renderUpdateStatus()}
<Collapsible initiallyCollapsed={true} title="Fee and Spending Details"> <Collapsible initiallyCollapsed={true} title="Fee and Spending Details">
{renderReserveCreationDetails(this.reserveCreationInfo())} {renderReserveCreationDetails(this.reserveCreationInfo())}
</Collapsible> </Collapsible>

View File

@ -220,3 +220,22 @@ span.spacer {
a.actionLink { a.actionLink {
color: black; color: black;
} }
.errorbox {
border: 1px solid;
display: inline-block;
margin: 1em;
padding: 1em;
font-weight: bold;
background: #FF8A8A;
}
.okaybox {
border: 1px solid;
display: inline-block;
margin: 1em;
padding: 1em;
font-weight: bold;
background: #00FA9A;
}

View File

@ -58,7 +58,7 @@ const DB_NAME = "taler";
* In the future we might consider adding migration functions for * In the future we might consider adding migration functions for
* each version increment. * each version increment.
*/ */
const DB_VERSION = 17; const DB_VERSION = 18;
function handleMessage(db: IDBDatabase, function handleMessage(db: IDBDatabase,
wallet: Wallet, wallet: Wallet,