From 09245bcbf926cf4a0e345acc9de3b9e0a28ed216 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 1 Nov 2019 12:17:41 +0100 Subject: [PATCH 01/10] build system --- build-system/taler-build-scripts | 2 +- configure | 87 -------------------------------- 2 files changed, 1 insertion(+), 88 deletions(-) delete mode 100755 configure diff --git a/build-system/taler-build-scripts b/build-system/taler-build-scripts index b2c9672f2..253680192 160000 --- a/build-system/taler-build-scripts +++ b/build-system/taler-build-scripts @@ -1 +1 @@ -Subproject commit b2c9672f2e493db810865b7de1e568a466b59360 +Subproject commit 2536801927781ea38fefc3de924934e1c6a74d88 diff --git a/configure b/configure deleted file mode 100755 index 45837b56b..000000000 --- a/configure +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# This file is part of TALER -# (C) 2019 GNUnet e.V. -# -# This is very simple POSIX sh script which -# identifies the first matching -# python3 identifier in $PATH and produces -# configure.py from configure.py.in, and then -# calls the new executable configure.py. -# -# It should be portable on Unices. Report bugs on -# the bugtracker if you discover that it isn't -# working as intended. -# -# Authors: -# Author: ng0 -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -# THIS SOFTWARE. -# -# SPDX-License-Identifier: 0BSD - -# there is a function used in curl to replicate which(1), but -# it uses too many other tools. this one uses command and in -# gnunet so far has no reports about failures. -existence() -{ - command -v "$1" >/dev/null 2>&1 -} - -# We have to check every possible variant of the -# executable name because there is a PEP which -# defines the executable to be like this. -if existence python3; then - if test ! -z "`python3 --version | awk '$2 ~ /3.7/ { print }'`"; then - python="python3" - else - echo "*** At least python 3.7 is required for the buildsystem" - exit 1 - fi -# elif existence python3.1; then -# python="python3.1" -# elif existence python3.2; then -# python="python3.2" -# elif existence python3.3; then -# python="python3.3" -# elif existence python3.4; then -# python="python3.4" -# elif existence python3.5; then -# python="python3.5" -# elif existence python3.6; then -# python="python3.6" -elif existence python3.7; then - python="python3.7" -elif existence python3.8; then - python="python3.8" -else - echo "*** No known python3 executable found in path ***" - echo "*** falling back to env(1) python ***" - # Unreliable, but if env finds no python, we still can - # not assume python in a fixed location. - # TODO: Check this in a clean chroot! - python="env python" -fi - -# we could check the return value here via || echo "blafoo" -# or fail anyway once configure.py is invoked because we -# don't have python if we reach the point to fail. -PYTHON=$($python -c 'import sys; print(sys.executable)') - - -# Call configure.py, assuming all went well. -# $1 is read by configure.py as the prefix. -# If $1 is empty, the python script checks the -# environment for PREFIX. We might need more -# variables and switches, such as DESTDIR. -exec "$PYTHON" ./configure.py $@ From a6bd1533397289c5ad0444e3108890d43db9b36e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 1 Nov 2019 12:19:59 +0100 Subject: [PATCH 02/10] simplify configure.py --- configure.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/configure.py b/configure.py index 3a5a8de1c..89d143325 100644 --- a/configure.py +++ b/configure.py @@ -1,15 +1,8 @@ -#!/usr/bin/env python3 +# This configure.py file is places in the public domain. -import sys -from pathlib import Path - -base_dir = Path(__file__, "../build-system/taler-build-scripts").resolve() -if not base_dir.exists(): - print( - f"build system directory ({base_dir}) missing", file=sys.stderr - ) - sys.exit(1) -sys.path.insert(0, str(base_dir)) +# Configure the build directory. +# This file is invoked by './configure' and should usually not be invoked +# manually. from talerbuildconfig import * From 1c5a9d2474f6281869c0ed0accbff4944359722a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 1 Nov 2019 18:39:18 +0100 Subject: [PATCH 03/10] gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9b4601c70..554c6be6c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,10 +12,13 @@ yarn-error.log npm-packages-offline-cache/ -config.mk +/configure +/config.mk + \#*\# *~ # old folder build-scripts/ + From ae8a00527168b13aa59ddc2fbd1f88a0f1e2669c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 1 Nov 2019 18:39:23 +0100 Subject: [PATCH 04/10] protocol changes --- src/talerTypes.ts | 4 +-- src/taleruri-test.ts | 56 ++++++++++++++++++++++++++++++++++++++++- src/taleruri.ts | 27 ++++++++++---------- src/types-test.ts | 2 +- src/wallet.ts | 16 ++++++------ src/webex/pages/pay.tsx | 14 ++++++++++- src/webex/wxApi.ts | 1 + 7 files changed, 95 insertions(+), 25 deletions(-) diff --git a/src/talerTypes.ts b/src/talerTypes.ts index 73b97c93d..e28b35c7f 100644 --- a/src/talerTypes.ts +++ b/src/talerTypes.ts @@ -402,10 +402,10 @@ export class ContractTerms { order_id: string; /** - * URL to post the payment to. + * Base URL of the merchant's backend. */ @Checkable.String() - pay_url: string; + merchant_base_url: string; /** * Fulfillment URL to view the product or diff --git a/src/taleruri-test.ts b/src/taleruri-test.ts index bf4e9d493..360f565f7 100644 --- a/src/taleruri-test.ts +++ b/src/taleruri-test.ts @@ -15,7 +15,7 @@ */ import test from "ava"; -import { parsePayUri, parseWithdrawUri } from "./taleruri"; +import { parsePayUri, parseWithdrawUri, parseRefundUri, parseTipUri } from "./taleruri"; test("taler pay url parsing: http(s)", (t) => { const url1 = "https://example.com/bar?spam=eggs"; @@ -150,3 +150,57 @@ test("taler withdraw uri parsing", (t) => { } t.is(r1.statusUrl, "https://bank.example.com/api/withdraw-operation/12345"); }); + + +test("taler refund uri parsing", (t) => { + const url1 = "taler://refund/merchant.example.com/-/-/1234"; + const r1 = parseRefundUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.refundUrl, "https://merchant.example.com/public/refund?order_id=1234"); +}); + + +test("taler refund uri parsing with instance", (t) => { + const url1 = "taler://refund/merchant.example.com/-/myinst/1234"; + const r1 = parseRefundUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.refundUrl, "https://merchant.example.com/public/instances/myinst/refund?order_id=1234"); +}); + +test("taler tip pickup uri", (t) => { + const url1 = "taler://tip/merchant.example.com/-/-/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/public/tip-pickup?tip_id=tipid"); +}); + + +test("taler tip pickup uri with instance", (t) => { + const url1 = "taler://tip/merchant.example.com/-/tipm/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/public/instances/tipm/tip-pickup?tip_id=tipid"); +}); + + +test("taler tip pickup uri with instance and prefix", (t) => { + const url1 = "taler://tip/merchant.example.com/my%2fpfx/tipm/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/my/pfx/instances/tipm/tip-pickup?tip_id=tipid"); +}); diff --git a/src/taleruri.ts b/src/taleruri.ts index 0af5c4c95..c810def29 100644 --- a/src/taleruri.ts +++ b/src/taleruri.ts @@ -147,17 +147,18 @@ export function parseTipUri(s: string): TipUriResult | undefined { } if (maybePath === "-") { - maybePath = "public/tip-pickup"; + maybePath = "public/"; } else { - maybePath = decodeURIComponent(maybePath); + maybePath = decodeURIComponent(maybePath) + "/"; } - if (maybeInstance === "-") { - maybeInstance = "default"; + let maybeInstancePath = ""; + if (maybeInstance !== "-") { + maybeInstancePath = `instances/${maybeInstance}/`; } const tipPickupUrl = new URI( - "https://" + host + "/" + decodeURIComponent(maybePath), - ).href(); + "https://" + host + "/" + maybePath + maybeInstancePath + "tip-pickup", + ).addQuery({ tip_id: tipId }).href(); return { tipPickupUrl, @@ -197,20 +198,20 @@ export function parseRefundUri(s: string): RefundUriResult | undefined { } if (maybePath === "-") { - maybePath = "public/refund"; + maybePath = "public/"; } else { - maybePath = decodeURIComponent(maybePath); + maybePath = decodeURIComponent(maybePath) + "/"; } - if (maybeInstance === "-") { - maybeInstance = "default"; + let maybeInstancePath = ""; + if (maybeInstance !== "-") { + maybeInstancePath = `instances/${maybeInstance}/`; } const refundUrl = new URI( - "https://" + host + "/" + decodeURIComponent(maybePath), + "https://" + host + "/" + maybePath + maybeInstancePath + "refund", ) - .addQuery({ instance: maybeInstance, order_id: orderId }) + .addQuery({ order_id: orderId }) .href(); - return { refundUrl, }; diff --git a/src/types-test.ts b/src/types-test.ts index 51c4d69c7..3ba059de1 100644 --- a/src/types-test.ts +++ b/src/types-test.ts @@ -115,7 +115,7 @@ test("contract terms validation", (t) => { merchant_pub: "12345", order_id: "test_order", pay_deadline: "Date(12346)", - pay_url: "https://example.com/pay", + merchant_base_url: "https://example.com/pay", products: [], refund_deadline: "Date(12345)", summary: "hello", diff --git a/src/wallet.ts b/src/wallet.ts index 25857870c..29475cc74 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -965,15 +965,17 @@ export class Wallet { let resp; const payReq = { ...purchase.payReq, session_id: sessionId }; + const payUrl = new URI("pay").absoluteTo(purchase.contractTerms.merchant_base_url).href() + try { - resp = await this.http.postJson(purchase.contractTerms.pay_url, payReq); + resp = await this.http.postJson(payUrl, payReq); } catch (e) { // Gives the user the option to retry / abort and refresh console.log("payment failed", e); throw e; } const merchantResp = resp.responseJson; - console.log("got success from pay_url"); + console.log("got success from pay URL"); const merchantPub = purchase.contractTerms.merchant_pub; const valid: boolean = await this.cryptoApi.isValidPaymentSignature( @@ -3033,7 +3035,7 @@ export class Wallet { merchant_pub: pub, order_id: "none", pay_deadline: `/Date(${stampSecNow + 60 * 5})/`, - pay_url: "", + merchant_base_url: "taler://return-to-account", products: [], refund_deadline: `/Date(${stampSecNow + 60 * 5})/`, timestamp: `/Date(${stampSecNow})/`, @@ -3466,9 +3468,7 @@ export class Wallet { throw Error("invalid taler://tip URI"); } - const tipStatusUrl = new URI(res.tipPickupUrl) - .addQuery({ tip_id: res.tipId }) - .href(); + const tipStatusUrl = new URI(res.tipPickupUrl).href(); console.log("checking tip status from", tipStatusUrl); const merchantResp = await this.http.get(tipStatusUrl); console.log("resp:", merchantResp.responseJson); @@ -3552,8 +3552,10 @@ export class Wallet { const abortReq = { ...purchase.payReq, mode: "abort-refund" }; + const payUrl = new URI("pay").absoluteTo(purchase.contractTerms.merchant_base_url).href() + try { - resp = await this.http.postJson(purchase.contractTerms.pay_url, abortReq); + resp = await this.http.postJson(payUrl, abortReq); } catch (e) { // Gives the user the option to retry / abort and refresh console.log("aborting payment failed", e); diff --git a/src/webex/pages/pay.tsx b/src/webex/pages/pay.tsx index 579688db3..7f2a174b7 100644 --- a/src/webex/pages/pay.tsx +++ b/src/webex/pages/pay.tsx @@ -53,6 +53,11 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) { return Loading payment information ...; } + let insufficientBalance = false; + if (payStatus.status == "insufficient-balance") { + insufficientBalance = true; + } + if (payStatus.status === "error") { return Error: {payStatus.error}; } @@ -93,7 +98,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) { const doPayment = async () => { if (payStatus.status !== "payment-possible") { - throw Error("invalid state"); + throw Error(`invalid state: ${payStatus.status}`); } const proposalId = payStatus.proposalId; setNumTries(numTries + 1); @@ -128,6 +133,12 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) { )}

+ {insufficientBalance ? ( +
+

Unable to pay: Your balance is insufficient.

+
+ ) : null} + {payErrMsg ? (

Payment failed: {payErrMsg}

@@ -142,6 +153,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
doPayment()}> {i18n.str`Confirm payment`} diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts index 65c14ac48..39c31ca51 100644 --- a/src/webex/wxApi.ts +++ b/src/webex/wxApi.ts @@ -86,6 +86,7 @@ async function callBackend( return new Promise((resolve, reject) => { chrome.runtime.sendMessage({ type, detail }, (resp) => { if (typeof resp === "object" && resp && resp.error) { + console.warn("response error:", resp) const e = new WalletApiError(resp.error.message, resp.error); reject(e); } else { From 8080c9a2859e0a612adb6dec1dad9b60e0fd4b1d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 1 Nov 2019 18:40:33 +0100 Subject: [PATCH 05/10] bump WebExtension manifest version --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 86928bf0d..61e063ea9 100644 --- a/manifest.json +++ b/manifest.json @@ -4,8 +4,8 @@ "name": "GNU Taler Wallet (git)", "description": "Privacy preserving and transparent payments", "author": "GNU Taler Developers", - "version": "0.6.68", - "version_name": "0.6.0pre1", + "version": "0.6.69", + "version_name": "0.6.0pre2", "minimum_chrome_version": "51", "minimum_opera_version": "36", From 8f973c69c4b84f455634f03e931304a3babde0ee Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 2 Nov 2019 00:22:55 +0100 Subject: [PATCH 06/10] handle multiple refresh sessions correctly for refunded coins --- src/i18n/de.po | 10 ++++---- src/i18n/en-US.po | 10 ++++---- src/i18n/fr.po | 10 ++++---- src/i18n/it.po | 10 ++++---- src/i18n/sv.po | 10 ++++---- src/i18n/taler-wallet-webex.pot | 10 ++++---- src/talerTypes.ts | 6 +++++ src/wallet.ts | 41 +++++++++++++++++++++++++-------- src/walletTypes.ts | 4 ++++ 9 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/i18n/de.po b/src/i18n/de.po index 7358c5507..0181420ae 100644 --- a/src/i18n/de.po +++ b/src/i18n/de.po @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, fuzzy, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "Der Händler %1$s möchte einen Vertrag über %2$s mit Ihnen abschließen." -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, c-format msgid "The total price is %1$s." msgstr "" -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, fuzzy, c-format msgid "Confirm payment" msgstr "Bezahlung bestätigen" diff --git a/src/i18n/en-US.po b/src/i18n/en-US.po index 508a1f1f9..fd4a9c983 100644 --- a/src/i18n/en-US.po +++ b/src/i18n/en-US.po @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "" -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, c-format msgid "The total price is %1$s." msgstr "" -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, c-format msgid "Confirm payment" msgstr "" diff --git a/src/i18n/fr.po b/src/i18n/fr.po index 56eee1dd4..bbc02869a 100644 --- a/src/i18n/fr.po +++ b/src/i18n/fr.po @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "" -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, c-format msgid "The total price is %1$s." msgstr "" -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, c-format msgid "Confirm payment" msgstr "" diff --git a/src/i18n/it.po b/src/i18n/it.po index 56eee1dd4..bbc02869a 100644 --- a/src/i18n/it.po +++ b/src/i18n/it.po @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "" -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, c-format msgid "The total price is %1$s." msgstr "" -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, c-format msgid "Confirm payment" msgstr "" diff --git a/src/i18n/sv.po b/src/i18n/sv.po index c1c0d4560..dd546b77c 100644 --- a/src/i18n/sv.po +++ b/src/i18n/sv.po @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, fuzzy, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "Säljaren %1$s erbjuder följande:" -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, fuzzy, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "Det totala priset är %1$s (plus %2$s avgifter).\n" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, fuzzy, c-format msgid "The total price is %1$s." msgstr "Det totala priset är %1$s." -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, c-format msgid "Confirm payment" msgstr "Godkän betalning" diff --git a/src/i18n/taler-wallet-webex.pot b/src/i18n/taler-wallet-webex.pot index 56eee1dd4..bbc02869a 100644 --- a/src/i18n/taler-wallet-webex.pot +++ b/src/i18n/taler-wallet-webex.pot @@ -37,27 +37,27 @@ msgstr "" msgid "time (ms/op)" msgstr "" -#: src/webex/pages/pay.tsx:113 +#: src/webex/pages/pay.tsx:118 #, c-format msgid "The merchant %1$s offers you to purchase:" msgstr "" -#: src/webex/pages/pay.tsx:119 +#: src/webex/pages/pay.tsx:124 #, c-format msgid "The total price is %1$s (plus %2$s fees)." msgstr "" -#: src/webex/pages/pay.tsx:124 +#: src/webex/pages/pay.tsx:129 #, c-format msgid "The total price is %1$s." msgstr "" -#: src/webex/pages/pay.tsx:138 +#: src/webex/pages/pay.tsx:149 #, c-format msgid "Retry" msgstr "" -#: src/webex/pages/pay.tsx:146 +#: src/webex/pages/pay.tsx:158 #, c-format msgid "Confirm payment" msgstr "" diff --git a/src/talerTypes.ts b/src/talerTypes.ts index e28b35c7f..ebb13f4a5 100644 --- a/src/talerTypes.ts +++ b/src/talerTypes.ts @@ -388,6 +388,12 @@ export class ContractTerms { @Checkable.String(timestampCheck) refund_deadline: string; + /** + * Deadline for the wire transfer. + */ + @Checkable.String(timestampCheck) + wire_transfer_deadline: string; + /** * Time when the contract was generated by the merchant. */ diff --git a/src/wallet.ts b/src/wallet.ts index 29475cc74..244a4f227 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -114,6 +114,7 @@ import { parseTipUri, parseRefundUri, } from "./taleruri"; +import { isFirefox } from "./webex/compat"; interface SpeculativePayData { payCoinInfo: PayCoinInfo; @@ -965,7 +966,9 @@ export class Wallet { let resp; const payReq = { ...purchase.payReq, session_id: sessionId }; - const payUrl = new URI("pay").absoluteTo(purchase.contractTerms.merchant_base_url).href() + const payUrl = new URI("pay") + .absoluteTo(purchase.contractTerms.merchant_base_url) + .href(); try { resp = await this.http.postJson(payUrl, payReq); @@ -1925,10 +1928,16 @@ export class Wallet { !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); - }); + console.warn( + `wallet version ${WALLET_PROTOCOL_VERSION} might be outdated (exchange has ${exchangeInfo.protocolVersion}), checking for updates`, + ); + if (!isFirefox()) { + console.log("skipping update check on Firefox") + } else { + chrome.runtime.requestUpdateCheck((status, details) => { + console.log("update check status:", status); + }); + } } } @@ -2215,6 +2224,9 @@ export class Wallet { paybackAmount: z, pendingIncoming: z, pendingPayment: z, + pendingIncomingDirty: z, + pendingIncomingRefresh: z, + pendingIncomingWithdraw: z, }; let entryCurr = balance.byCurrency[amount.currency]; if (!entryCurr) { @@ -2240,6 +2252,7 @@ export class Wallet { } if (c.status === CoinStatus.Dirty) { addTo(balance, "pendingIncoming", c.currentAmount, c.exchangeBaseUrl); + addTo(balance, "pendingIncomingDirty", c.currentAmount, c.exchangeBaseUrl); return balance; } return balance; @@ -2259,6 +2272,7 @@ export class Wallet { amount = Amounts.add(amount, r.precoin_amount).amount; if (Amounts.cmp(smallestWithdraw[r.exchange_base_url], amount) < 0) { addTo(balance, "pendingIncoming", amount, r.exchange_base_url); + addTo(balance, "pendingIncomingWithdraw", amount, r.exchange_base_url); } return balance; } @@ -2286,6 +2300,7 @@ export class Wallet { return balance; } addTo(balance, "pendingIncoming", r.valueOutput, r.exchangeBaseUrl); + addTo(balance, "pendingIncomingRefresh", r.valueOutput, r.exchangeBaseUrl); return balance; } @@ -2340,6 +2355,7 @@ export class Wallet { tx.iter(Stores.reserves).fold(collectPaybacks, balanceStore); tx.iter(Stores.purchases).fold(collectPayments, balanceStore); await tx.finish(); + console.log("computed balances:", balanceStore) return balanceStore; } @@ -2443,9 +2459,12 @@ export class Wallet { .iter(Stores.refresh) .toArray(); for (const session of oldRefreshSessions) { + if (session.finished) { + continue; + } Wallet.enableTracing && - console.log("got old refresh session for", oldCoinPub, session); - return this.continueRefreshSession(session); + console.log("waiting for unfinished old refresh session for", oldCoinPub, session); + await this.continueRefreshSession(session); } const coin = await this.q().get(Stores.coins, oldCoinPub); if (!coin) { @@ -2456,6 +2475,7 @@ export class Wallet { coin.status === CoinStatus.Useless || coin.status === CoinStatus.Fresh ) { + Wallet.enableTracing && console.log("not refreshing due to coin status", CoinStatus[coin.status]) return; } const refreshSession = await this.createRefreshSession(oldCoinPub); @@ -3034,7 +3054,8 @@ export class Wallet { merchant: {}, merchant_pub: pub, order_id: "none", - pay_deadline: `/Date(${stampSecNow + 60 * 5})/`, + pay_deadline: `/Date(${stampSecNow + 30 * 5})/`, + wire_transfer_deadline: `/Date(${stampSecNow + 60 * 5})/`, merchant_base_url: "taler://return-to-account", products: [], refund_deadline: `/Date(${stampSecNow + 60 * 5})/`, @@ -3552,7 +3573,9 @@ export class Wallet { const abortReq = { ...purchase.payReq, mode: "abort-refund" }; - const payUrl = new URI("pay").absoluteTo(purchase.contractTerms.merchant_base_url).href() + const payUrl = new URI("pay") + .absoluteTo(purchase.contractTerms.merchant_base_url) + .href(); try { resp = await this.http.postJson(payUrl, abortReq); diff --git a/src/walletTypes.ts b/src/walletTypes.ts index d29e3812e..fddf05680 100644 --- a/src/walletTypes.ts +++ b/src/walletTypes.ts @@ -187,6 +187,10 @@ export interface WalletBalanceEntry { * Amount that was paid back and we could withdraw again. */ paybackAmount: AmountJson; + + pendingIncomingWithdraw: AmountJson; + pendingIncomingRefresh: AmountJson; + pendingIncomingDirty: AmountJson; } /** From 574e6ce37ccf11fb15788937239acf79d76a8c20 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 2 Nov 2019 00:24:18 +0100 Subject: [PATCH 07/10] don't do requestUpdateStatus on FF --- src/wallet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet.ts b/src/wallet.ts index 244a4f227..c73af9062 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -1931,7 +1931,7 @@ export class Wallet { console.warn( `wallet version ${WALLET_PROTOCOL_VERSION} might be outdated (exchange has ${exchangeInfo.protocolVersion}), checking for updates`, ); - if (!isFirefox()) { + if (isFirefox()) { console.log("skipping update check on Firefox") } else { chrome.runtime.requestUpdateCheck((status, details) => { From d6a3a54d28a5d1e21cc3cca9927c78f674044531 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 2 Nov 2019 00:46:57 +0100 Subject: [PATCH 08/10] installation popup in FF --- manifest.json | 4 ++-- src/webex/background.ts | 2 +- src/webex/pages/tip.tsx | 2 +- src/webex/wxBackend.ts | 21 ++++++++++++++------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/manifest.json b/manifest.json index 61e063ea9..5abbccae0 100644 --- a/manifest.json +++ b/manifest.json @@ -4,8 +4,8 @@ "name": "GNU Taler Wallet (git)", "description": "Privacy preserving and transparent payments", "author": "GNU Taler Developers", - "version": "0.6.69", - "version_name": "0.6.0pre2", + "version": "0.6.70", + "version_name": "0.6.0pre3", "minimum_chrome_version": "51", "minimum_opera_version": "36", diff --git a/src/webex/background.ts b/src/webex/background.ts index 3c63f323e..dbc540df4 100644 --- a/src/webex/background.ts +++ b/src/webex/background.ts @@ -23,7 +23,7 @@ /** * Imports. */ -import {wxMain} from "./wxBackend"; +import { wxMain } from "./wxBackend"; window.addEventListener("load", () => { wxMain(); diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx index 0a066053b..148b8203c 100644 --- a/src/webex/pages/tip.tsx +++ b/src/webex/pages/tip.tsx @@ -88,7 +88,7 @@ function TipDisplay(props: { talerTipUri: string }) {

accept()}> - AcceptTip + Accept Tip {" "}