Browse Source

trustedcoin: better UX in Qt when cannot connect to TC server

closes #5184
regtest_lnd
SomberNight 6 years ago
parent
commit
a62bf2a53a
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 25
      electrum/plugins/trustedcoin/qt.py
  2. 8
      electrum/plugins/trustedcoin/trustedcoin.py

25
electrum/plugins/trustedcoin/qt.py

@ -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):
@ -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:

8
electrum/plugins/trustedcoin/trustedcoin.py

@ -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')

Loading…
Cancel
Save