mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 10:15:20 +00:00
trustedcoin: better UX in Qt when cannot connect to TC server
closes #5184
This commit is contained in:
parent
13f3f71125
commit
a62bf2a53a
2 changed files with 22 additions and 11 deletions
|
@ -121,10 +121,20 @@ class Plugin(TrustedCoinPlugin):
|
||||||
def prompt_user_for_otp(self, wallet, tx, on_success, on_failure):
|
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)
|
wallet.handler_2fa.prompt_user_for_otp(wallet, tx, on_success, on_failure)
|
||||||
|
|
||||||
def waiting_dialog(self, window, on_finished=None):
|
def waiting_dialog_for_billing_info(self, window, *, on_finished=None):
|
||||||
task = partial(self.request_billing_info, window.wallet)
|
def task():
|
||||||
return WaitingDialog(window, 'Getting billing information...', task,
|
return self.request_billing_info(window.wallet, suppress_connection_error=False)
|
||||||
on_finished)
|
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
|
@hook
|
||||||
def abort_send(self, window):
|
def abort_send(self, window):
|
||||||
|
@ -134,14 +144,13 @@ class Plugin(TrustedCoinPlugin):
|
||||||
if wallet.can_sign_without_server():
|
if wallet.can_sign_without_server():
|
||||||
return
|
return
|
||||||
if wallet.billing_info is None:
|
if wallet.billing_info is None:
|
||||||
self.start_request_thread(wallet)
|
self.waiting_dialog_for_billing_info(window)
|
||||||
window.show_error(_('Requesting account info from TrustedCoin server...') + '\n' +
|
|
||||||
_('Please try again.'))
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def settings_dialog(self, window):
|
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):
|
def show_settings_dialog(self, window, success):
|
||||||
if not success:
|
if not success:
|
||||||
|
|
|
@ -465,15 +465,17 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
return f
|
return f
|
||||||
|
|
||||||
@finish_requesting
|
@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():
|
if wallet.can_sign_without_server():
|
||||||
return
|
return
|
||||||
self.print_error("request billing info")
|
self.print_error("request billing info")
|
||||||
try:
|
try:
|
||||||
billing_info = server.get(wallet.get_user_id()[1])
|
billing_info = server.get(wallet.get_user_id()[1])
|
||||||
except ErrorConnectingServer as e:
|
except ErrorConnectingServer as e:
|
||||||
|
if suppress_connection_error:
|
||||||
self.print_error(str(e))
|
self.print_error(str(e))
|
||||||
return
|
return
|
||||||
|
raise
|
||||||
billing_index = billing_info['billing_index']
|
billing_index = billing_info['billing_index']
|
||||||
# add segwit billing address; this will be used for actual billing
|
# add segwit billing address; this will be used for actual billing
|
||||||
billing_address = make_billing_address(wallet, billing_index, addr_type='segwit')
|
billing_address = make_billing_address(wallet, billing_index, addr_type='segwit')
|
||||||
|
|
Loading…
Add table
Reference in a new issue