hw: allow bypassing "too old firmware" error when using hw wallets
The framework here is generic enough that it can be used for any hw plugin, however atm only Trezor is implemented. closes #5391
This commit is contained in:
@@ -37,6 +37,8 @@ from electrum.gui.qt.util import (read_QIcon, WWLabel, OkButton, WindowModalDial
|
||||
from electrum.i18n import _
|
||||
from electrum.logging import Logger
|
||||
|
||||
from .plugin import OutdatedHwFirmwareException
|
||||
|
||||
|
||||
# The trickiest thing about this handler was getting windows properly
|
||||
# parented on macOS.
|
||||
@@ -212,11 +214,27 @@ class QtPluginBase(object):
|
||||
handler = self.create_handler(window)
|
||||
handler.button = button
|
||||
keystore.handler = handler
|
||||
keystore.thread = TaskThread(window, window.on_error)
|
||||
keystore.thread = TaskThread(window, on_error=partial(self.on_task_thread_error, window, keystore))
|
||||
self.add_show_address_on_hw_device_button_for_receive_addr(wallet, keystore, window)
|
||||
# Trigger a pairing
|
||||
keystore.thread.add(partial(self.get_client, keystore))
|
||||
|
||||
def on_task_thread_error(self, window, keystore, exc_info):
|
||||
e = exc_info[1]
|
||||
if isinstance(e, OutdatedHwFirmwareException):
|
||||
if window.question(e.text_ignore_old_fw_and_continue(), title=_("Outdated device firmware")):
|
||||
self.set_ignore_outdated_fw()
|
||||
# will need to re-pair
|
||||
devmgr = self.device_manager()
|
||||
def re_pair_device():
|
||||
device_id = self.choose_device(window, keystore)
|
||||
devmgr.unpair_id(device_id)
|
||||
self.get_client(keystore)
|
||||
keystore.thread.add(re_pair_device)
|
||||
return
|
||||
else:
|
||||
window.on_error(exc_info)
|
||||
|
||||
def choose_device(self, window, keystore):
|
||||
'''This dialog box should be usable even if the user has
|
||||
forgotten their PIN or it is in bootloader mode.'''
|
||||
|
||||
Reference in New Issue
Block a user