From 4101946ff599b8b7411583f7dd52c30b669863b4 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 14 Sep 2023 12:10:28 +0200 Subject: [PATCH] wizard: add non-hardened derivation path check for digital bitbox, re-add rescan button in choose hw device, clear clipboard before confirming seed. --- electrum/gui/qt/wizard/wallet.py | 18 ++++++++++++++++++ .../plugins/digitalbitbox/digitalbitbox.py | 4 ++++ electrum/plugins/hw_wallet/plugin.py | 2 ++ electrum/plugins/trezor/qt.py | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/electrum/gui/qt/wizard/wallet.py b/electrum/gui/qt/wizard/wallet.py index 9ffc2255c..6169f9d61 100644 --- a/electrum/gui/qt/wizard/wallet.py +++ b/electrum/gui/qt/wizard/wallet.py @@ -498,6 +498,8 @@ class WCConfirmSeed(WizardComponent): ) self.layout().addLayout(self.slayout) + wizard.app.clipboard().clear() + def apply(self): pass @@ -1072,15 +1074,28 @@ class WCChooseHWDevice(WizardComponent, Logger): self.device_list.setLayout(self.device_list_layout) self.choice_w = None + self.rescan_button = QPushButton(_('Rescan devices')) + self.rescan_button.clicked.connect(self.on_rescan) + + hbox = QHBoxLayout() + hbox.addStretch(1) + hbox.addWidget(self.rescan_button) + hbox.addStretch(1) + self.layout().addWidget(self.error_l) self.layout().addWidget(self.device_list) self.layout().addStretch(1) + self.layout().addLayout(hbox) + self.layout().addStretch(1) self.c_values = [] def on_ready(self): self.scan_devices() + def on_rescan(self): + self.scan_devices() + def on_scan_failed(self, code, message): self.error_l.setText(message) self.error_l.setVisible(True) @@ -1115,6 +1130,9 @@ class WCChooseHWDevice(WizardComponent, Logger): if self.valid: self.wizard.next_button.setFocus() + else: + self.rescan_button.setFocus() + def failed_getting_device_infos(self, debug_msg, name, e): # nonlocal debug_msg diff --git a/electrum/plugins/digitalbitbox/digitalbitbox.py b/electrum/plugins/digitalbitbox/digitalbitbox.py index 474cf53cd..4440fd43c 100644 --- a/electrum/plugins/digitalbitbox/digitalbitbox.py +++ b/electrum/plugins/digitalbitbox/digitalbitbox.py @@ -120,6 +120,10 @@ class DigitalBitbox_Client(HardwareClientBase): def get_xpub(self, bip32_path, xtype): assert xtype in self.plugin.SUPPORTED_XTYPES + + if is_all_public_derivation(bip32_path): + raise UserFacingException(_('This device does not reveal xpubs corresponding to non-hardened paths')) + reply = self._get_xpub(bip32_path) if reply: xpub = reply['xpub'] diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py index 3795dc490..7148624be 100644 --- a/electrum/plugins/hw_wallet/plugin.py +++ b/electrum/plugins/hw_wallet/plugin.py @@ -38,6 +38,7 @@ from electrum.keystore import Xpub, Hardware_KeyStore if TYPE_CHECKING: import threading + from electrum.plugin import DeviceInfo from electrum.wallet import Abstract_Wallet @@ -272,6 +273,7 @@ class HardwareClientBase(ABC): is constructed for the first time. 'd' is the dict that will be passed to the keystore constructor. """ + # TODO: this is only used by coldcard. determine if this needs to stay generalized pass diff --git a/electrum/plugins/trezor/qt.py b/electrum/plugins/trezor/qt.py index b4e9cfaa8..0c1b1a9aa 100644 --- a/electrum/plugins/trezor/qt.py +++ b/electrum/plugins/trezor/qt.py @@ -423,7 +423,7 @@ class InitSettingsLayout(QVBoxLayout): # no backup self.cb_no_backup = None if method == TIM_NEW: - self.cb_no_backup = QCheckBox(f'''{_('Enable seedless mode')}''') + self.cb_no_backup = QCheckBox(_('Enable seedless mode')) self.cb_no_backup.setChecked(False) if (model == '1' and fw_version >= (1, 7, 1) or model == 'T' and fw_version >= (2, 0, 9)):