URI: 
       ttrustedcoin: better UX in Qt when cannot connect to TC server - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit a62bf2a53ac3c6a596b2570ba41636fb979df2c5
   DIR parent 13f3f71125efc4dfc1b953751e5409040252e64c
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sat, 16 Mar 2019 20:05:10 +0100
       
       ttrustedcoin: better UX in Qt when cannot connect to TC server
       
       closes #5184
       
       Diffstat:
         M electrum/plugins/trustedcoin/qt.py  |      25 +++++++++++++++++--------
         M electrum/plugins/trustedcoin/trust… |       8 +++++---
       
       2 files changed, 22 insertions(+), 11 deletions(-)
       ---
   DIR diff --git a/electrum/plugins/trustedcoin/qt.py b/electrum/plugins/trustedcoin/qt.py
       t@@ -121,10 +121,20 @@ class Plugin(TrustedCoinPlugin):
            def prompt_user_for_otp(self, wallet, tx, on_success, on_failure):
                wallet.handler_2fa.prompt_user_for_otp(wallet, tx, on_success, on_failure)
        
       -    def waiting_dialog(self, window, on_finished=None):
       -        task = partial(self.request_billing_info, window.wallet)
       -        return WaitingDialog(window, 'Getting billing information...', task,
       -                             on_finished)
       +    def waiting_dialog_for_billing_info(self, window, *, on_finished=None):
       +        def task():
       +            return self.request_billing_info(window.wallet, suppress_connection_error=False)
       +        def on_error(exc_info):
       +            e = exc_info[1]
       +            window.show_error("{header}\n{exc}\n\n{tor}"
       +                              .format(header=_('Error getting TrustedCoin account info.'),
       +                                      exc=str(e),
       +                                      tor=_('If you keep experiencing network problems, try using a Tor proxy.')))
       +        return WaitingDialog(parent=window,
       +                             message=_('Requesting account info from TrustedCoin server...'),
       +                             task=task,
       +                             on_success=on_finished,
       +                             on_error=on_error)
        
            @hook
            def abort_send(self, window):
       t@@ -134,14 +144,13 @@ 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.'))
       +            self.waiting_dialog_for_billing_info(window)
                    return True
                return False
        
            def settings_dialog(self, window):
       -        self.waiting_dialog(window, partial(self.show_settings_dialog, window))
       +        self.waiting_dialog_for_billing_info(window,
       +                                             on_finished=partial(self.show_settings_dialog, window))
        
            def show_settings_dialog(self, window, success):
                if not success:
   DIR diff --git a/electrum/plugins/trustedcoin/trustedcoin.py b/electrum/plugins/trustedcoin/trustedcoin.py
       t@@ -465,15 +465,17 @@ class TrustedCoinPlugin(BasePlugin):
                return f
        
            @finish_requesting
       -    def request_billing_info(self, wallet: 'Wallet_2fa'):
       +    def request_billing_info(self, wallet: 'Wallet_2fa', *, suppress_connection_error=True):
                if wallet.can_sign_without_server():
                    return
                self.print_error("request billing info")
                try:
                    billing_info = server.get(wallet.get_user_id()[1])
                except ErrorConnectingServer as e:
       -            self.print_error(str(e))
       -            return
       +            if suppress_connection_error:
       +                self.print_error(str(e))
       +                return
       +            raise
                billing_index = billing_info['billing_index']
                # add segwit billing address; this will be used for actual billing
                billing_address = make_billing_address(wallet, billing_index, addr_type='segwit')