electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d0352379d7f5c5aac2cfb63ec383603538860c93
parent e00499f04013b7d43c73fe64b74eb393c3700420
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 22 Apr 2018 04:00:57 +0200

fix #4071

Diffstat:
Mplugins/trustedcoin/qt.py | 3+++
Mplugins/trustedcoin/trustedcoin.py | 26+++++++++++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/plugins/trustedcoin/qt.py b/plugins/trustedcoin/qt.py @@ -115,6 +115,9 @@ class Plugin(TrustedCoinPlugin): if wallet.can_sign_without_server(): return if wallet.billing_info is None: + self.start_request_thread(wallet) + window.show_error(_('Requesting account info from TrustedCoin server...') + '\n' + + _('Please try again.')) return True return False diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -82,6 +82,11 @@ class TrustedCoinException(Exception): Exception.__init__(self, message) self.status_code = status_code + +class ErrorConnectingServer(Exception): + pass + + class TrustedCoinCosignerClient(object): def __init__(self, user_agent=None, base_url='https://api.trustedcoin.com/2/'): self.base_url = base_url @@ -100,7 +105,10 @@ class TrustedCoinCosignerClient(object): url = urljoin(self.base_url, relative_url) if self.debug: print('%s %s %s' % (method, url, data)) - response = requests.request(method, url, **kwargs) + try: + response = requests.request(method, url, **kwargs) + except Exception as e: + raise ErrorConnectingServer(e) if self.debug: print(response.text) if response.status_code != 200: @@ -336,17 +344,29 @@ class TrustedCoinPlugin(BasePlugin): if _type == TYPE_ADDRESS and addr == address: return address, amount + def finish_requesting(func): + def f(self, *args, **kwargs): + try: + return func(self, *args, **kwargs) + finally: + self.requesting = False + return f + + @finish_requesting def request_billing_info(self, wallet): if wallet.can_sign_without_server(): return self.print_error("request billing info") - billing_info = server.get(wallet.get_user_id()[1]) + try: + billing_info = server.get(wallet.get_user_id()[1]) + except ErrorConnectingServer as e: + self.print_error('cannot connect to TrustedCoin server: {}'.format(e)) + return billing_address = make_billing_address(wallet, billing_info['billing_index']) assert billing_address == billing_info['billing_address'] wallet.billing_info = billing_info wallet.price_per_tx = dict(billing_info['price_per_tx']) wallet.price_per_tx.pop(1) - self.requesting = False return True def start_request_thread(self, wallet):