mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
trezor: check if device is connected before asking passphrase
This commit is contained in:
parent
ad4449dc38
commit
ca6194e563
1 changed files with 18 additions and 3 deletions
|
@ -79,16 +79,31 @@ class Plugin(BasePlugin):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
return BasePlugin.enable(self)
|
return BasePlugin.enable(self)
|
||||||
|
|
||||||
|
def trezor_is_connected(self):
|
||||||
|
try:
|
||||||
|
self.wallet.get_client().ping('t')
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def init_qt(self, gui):
|
||||||
|
self.window = gui.main_window
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def close_wallet(self):
|
def close_wallet(self):
|
||||||
print_error("trezor: clear session")
|
print_error("trezor: clear session")
|
||||||
self.wallet.client.clear_session()
|
if self.wallet.client:
|
||||||
|
self.wallet.client.clear_session()
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def load_wallet(self, wallet):
|
def load_wallet(self, wallet):
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
if not self.wallet.check_proper_device():
|
if self.trezor_is_connected():
|
||||||
QMessageBox.information(None, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))
|
if not self.wallet.check_proper_device():
|
||||||
|
QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))
|
||||||
|
else:
|
||||||
|
QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK'))
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def installwizard_restore(self, wizard, storage):
|
def installwizard_restore(self, wizard, storage):
|
||||||
|
|
Loading…
Add table
Reference in a new issue