diff options
Diffstat (limited to 'extension/lib/wallet')
-rw-r--r-- | extension/lib/wallet/emscriptif.ts | 4 | ||||
-rw-r--r-- | extension/lib/wallet/wallet.ts | 6 | ||||
-rw-r--r-- | extension/lib/wallet/wxMessaging.ts | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/extension/lib/wallet/emscriptif.ts b/extension/lib/wallet/emscriptif.ts index 690800e2f..b03bc9bc7 100644 --- a/extension/lib/wallet/emscriptif.ts +++ b/extension/lib/wallet/emscriptif.ts @@ -381,6 +381,10 @@ export class Amount extends ArenaObject { } cmp(a: Amount) { + // If we don't check this, the c code aborts. + if (this.currency !== a.currency) { + throw Error(`incomparable currencies (${this.currency} and ${a.currency})`); + } return emsc.amount_cmp(this.nativePtr, a.nativePtr); } diff --git a/extension/lib/wallet/wallet.ts b/extension/lib/wallet/wallet.ts index 448714254..8e7f63b12 100644 --- a/extension/lib/wallet/wallet.ts +++ b/extension/lib/wallet/wallet.ts @@ -513,7 +513,7 @@ export class Wallet { function storeMintCoin(mc) { let mint: IMintInfo = mc[0]; - let coin = mc[1]; + let coin: Coin = mc[1]; let cd = { coin: coin, denom: mint.denoms.find((e) => e.denom_pub === coin.denomPub) @@ -521,6 +521,10 @@ export class Wallet { if (!cd.denom) { throw Error("denom not found (database inconsistent)"); } + if (cd.denom.value.currency !== paymentAmount.currency) { + console.warn("same pubkey for different currencies"); + return; + } let x = m[mint.baseUrl]; if (!x) { m[mint.baseUrl] = [cd]; diff --git a/extension/lib/wallet/wxMessaging.ts b/extension/lib/wallet/wxMessaging.ts index df79648ab..d497e5246 100644 --- a/extension/lib/wallet/wxMessaging.ts +++ b/extension/lib/wallet/wxMessaging.ts @@ -139,7 +139,8 @@ function dispatch(handlers, req, sendResponse) { }) }) .catch((e) => { - console.log("exception during wallet handler"); + console.log(`exception during wallet handler for '${req.type}'`); + console.log("request", req); console.error(e); sendResponse({ error: "exception", @@ -205,7 +206,8 @@ export function wxMain() { try { return dispatch(handlers, req, sendResponse) } catch (e) { - console.log("exception during wallet handler (dispatch)"); + console.log(`exception during wallet handler (dispatch)`); + console.log("request", req); console.error(e); sendResponse({ error: "exception", |