Browse Source

wizard: fix co-signing hardware wallets data incorrectly referenced

master
Sander van Grieken 2 years ago
parent
commit
643fbecc15
No known key found for this signature in database
GPG Key ID: 9BCF8209EA402EBA
  1. 3
      electrum/plugins/bitbox02/qt.py
  2. 5
      electrum/plugins/coldcard/qt.py
  3. 3
      electrum/plugins/digitalbitbox/qt.py
  4. 38
      electrum/plugins/keepkey/qt.py
  5. 38
      electrum/plugins/safe_t/qt.py
  6. 39
      electrum/plugins/trezor/qt.py

3
electrum/plugins/bitbox02/qt.py

@ -122,7 +122,8 @@ class WCBitbox02ScriptAndDerivation(WCScriptAndDerivation):
def on_ready(self): def on_ready(self):
super().on_ready() super().on_ready()
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
plugin = self.wizard.plugins.get_plugin(_info.plugin_name) plugin = self.wizard.plugins.get_plugin(_info.plugin_name)
device_id = _info.device.id_ device_id = _info.device.id_

5
electrum/plugins/coldcard/qt.py

@ -1,11 +1,10 @@
from functools import partial from functools import partial
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QPushButton, QLabel, QVBoxLayout, QWidget, QGridLayout from PyQt5.QtWidgets import QPushButton, QLabel, QVBoxLayout, QWidget, QGridLayout
from electrum.gui.qt.util import (WindowModalDialog, CloseButton, Buttons, getOpenFileName, from electrum.gui.qt.util import WindowModalDialog, CloseButton, getOpenFileName, getSaveFileName
getSaveFileName)
from electrum.gui.qt.main_window import ElectrumWindow from electrum.gui.qt.main_window import ElectrumWindow
from electrum.i18n import _ from electrum.i18n import _

3
electrum/plugins/digitalbitbox/qt.py

@ -83,7 +83,8 @@ class WCDigitalBitboxScriptAndDerivation(WCScriptAndDerivation):
def on_ready(self): def on_ready(self):
super().on_ready() super().on_ready()
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
plugin = self.wizard.plugins.get_plugin(_info.plugin_name) plugin = self.wizard.plugins.get_plugin(_info.plugin_name)
device_id = _info.device.id_ device_id = _info.device.id_

38
electrum/plugins/keepkey/qt.py

@ -19,8 +19,7 @@ from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
from ..hw_wallet.plugin import only_hook_if_libraries_available from ..hw_wallet.plugin import only_hook_if_libraries_available
from .keepkey import KeepKeyPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, TIM_PRIVKEY from .keepkey import KeepKeyPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, TIM_PRIVKEY
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WalletWizardComponent
from electrum.gui.qt.wizard.wizard import WizardComponent
if TYPE_CHECKING: if TYPE_CHECKING:
from electrum.gui.qt.wizard.wallet import QENewWalletWizard from electrum.gui.qt.wizard.wallet import QENewWalletWizard
@ -602,12 +601,13 @@ class SettingsDialog(WindowModalDialog):
invoke_client(None) invoke_client(None)
class WCKeepkeyInitMethod(WizardComponent): class WCKeepkeyInitMethod(WalletWizardComponent):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup'))
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
msg = _("Choose how you want to initialize your {}.\n\n" msg = _("Choose how you want to initialize your {}.\n\n"
"The first two methods are secure as no secret information " "The first two methods are secure as no secret information "
"is entered into your computer.\n\n" "is entered into your computer.\n\n"
@ -630,35 +630,38 @@ class WCKeepkeyInitMethod(WizardComponent):
self._valid = True self._valid = True
def apply(self): def apply(self):
self.wizard_data['keepkey_init'] = self.choice_w.selected_item[0] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['keepkey_init'] = self.choice_w.selected_key
class WCKeepkeyInitParams(WizardComponent): class WCKeepkeyInitParams(WalletWizardComponent):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup'))
self.plugins = wizard.plugins self.plugins = wizard.plugins
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
self.settings_layout = KeepkeyInitLayout(self.wizard_data['keepkey_init'], _info.device.id_) _name, _info = current_cosigner['hardware_device']
self.settings_layout = KeepkeyInitLayout(current_cosigner['keepkey_init'], _info.device.id_)
self.settings_layout.validChanged.connect(self.on_settings_valid_changed) self.settings_layout.validChanged.connect(self.on_settings_valid_changed)
self.layout().addLayout(self.settings_layout) self.layout().addLayout(self.settings_layout)
self.layout().addStretch(1) self.layout().addStretch(1)
self.valid = self.wizard_data['keepkey_init'] != TIM_PRIVKEY # TODO: only privkey is validated self.valid = current_cosigner['keepkey_init'] != TIM_PRIVKEY # TODO: only privkey is validated
self.busy = False self.busy = False
def on_settings_valid_changed(self, is_valid: bool): def on_settings_valid_changed(self, is_valid: bool):
self.valid = is_valid self.valid = is_valid
def apply(self): def apply(self):
self.wizard_data['keepkey_settings'] = self.settings_layout.get_settings() current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['keepkey_settings'] = self.settings_layout.get_settings()
class WCKeepkeyInit(WizardComponent, Logger): class WCKeepkeyInit(WalletWizardComponent, Logger):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('KeepKey Setup'))
Logger.__init__(self) Logger.__init__(self)
self.plugins = wizard.plugins self.plugins = wizard.plugins
self.plugin = self.plugins.get_plugin('keepkey') self.plugin = self.plugins.get_plugin('keepkey')
@ -668,9 +671,10 @@ class WCKeepkeyInit(WizardComponent, Logger):
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
settings = self.wizard_data['keepkey_settings'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
method = self.wizard_data['keepkey_init'] settings = current_cosigner['keepkey_settings']
_name, _info = self.wizard_data['hardware_device'] method = current_cosigner['keepkey_init']
_name, _info = current_cosigner['hardware_device']
device_id = _info.device.id_ device_id = _info.device.id_
client = self.plugins.device_manager.client_by_id(device_id, scan_now=False) client = self.plugins.device_manager.client_by_id(device_id, scan_now=False)
client.handler = self.plugin.create_handler(self.wizard) client.handler = self.plugin.create_handler(self.wizard)

38
electrum/plugins/safe_t/qt.py

@ -19,8 +19,7 @@ from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
from ..hw_wallet.plugin import only_hook_if_libraries_available from ..hw_wallet.plugin import only_hook_if_libraries_available
from .safe_t import SafeTPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, TIM_PRIVKEY from .safe_t import SafeTPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC, TIM_PRIVKEY
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WalletWizardComponent
from electrum.gui.qt.wizard.wizard import WizardComponent
if TYPE_CHECKING: if TYPE_CHECKING:
from electrum.gui.qt.wizard.wallet import QENewWalletWizard from electrum.gui.qt.wizard.wallet import QENewWalletWizard
@ -534,12 +533,13 @@ class SettingsDialog(WindowModalDialog):
invoke_client(None) invoke_client(None)
class WCSafeTInitMethod(WizardComponent): class WCSafeTInitMethod(WalletWizardComponent):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup'))
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
msg = _("Choose how you want to initialize your {}.\n\n" msg = _("Choose how you want to initialize your {}.\n\n"
"The first two methods are secure as no secret information " "The first two methods are secure as no secret information "
"is entered into your computer.\n\n" "is entered into your computer.\n\n"
@ -562,35 +562,38 @@ class WCSafeTInitMethod(WizardComponent):
self._valid = True self._valid = True
def apply(self): def apply(self):
self.wizard_data['safe_t_init'] = self.choice_w.selected_key current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['safe_t_init'] = self.choice_w.selected_key
class WCSafeTInitParams(WizardComponent): class WCSafeTInitParams(WalletWizardComponent):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup'))
self.plugins = wizard.plugins self.plugins = wizard.plugins
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
self.settings_layout = SafeTInitLayout(self.wizard_data['safe_t_init'], _info.device.id_) _name, _info = current_cosigner['hardware_device']
self.settings_layout = SafeTInitLayout(current_cosigner['safe_t_init'], _info.device.id_)
self.settings_layout.validChanged.connect(self.on_settings_valid_changed) self.settings_layout.validChanged.connect(self.on_settings_valid_changed)
self.layout().addLayout(self.settings_layout) self.layout().addLayout(self.settings_layout)
self.layout().addStretch(1) self.layout().addStretch(1)
self.valid = self.wizard_data['safe_t_init'] != TIM_PRIVKEY self.valid = current_cosigner['safe_t_init'] != TIM_PRIVKEY
self.busy = False self.busy = False
def on_settings_valid_changed(self, is_valid: bool): def on_settings_valid_changed(self, is_valid: bool):
self.valid = is_valid self.valid = is_valid
def apply(self): def apply(self):
self.wizard_data['safe_t_settings'] = self.settings_layout.get_settings() current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['safe_t_settings'] = self.settings_layout.get_settings()
class WCSafeTInit(WizardComponent, Logger): class WCSafeTInit(WalletWizardComponent, Logger):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Safe-T Setup'))
Logger.__init__(self) Logger.__init__(self)
self.plugins = wizard.plugins self.plugins = wizard.plugins
self.plugin = self.plugins.get_plugin('safe_t') self.plugin = self.plugins.get_plugin('safe_t')
@ -600,9 +603,10 @@ class WCSafeTInit(WizardComponent, Logger):
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
settings = self.wizard_data['safe_t_settings'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
method = self.wizard_data['safe_t_init'] settings = current_cosigner['safe_t_settings']
_name, _info = self.wizard_data['hardware_device'] method = current_cosigner['safe_t_init']
_name, _info = current_cosigner['hardware_device']
device_id = _info.device.id_ device_id = _info.device.id_
client = self.plugins.device_manager.client_by_id(device_id, scan_now=False) client = self.plugins.device_manager.client_by_id(device_id, scan_now=False)
client.handler = self.plugin.create_handler(self.wizard) client.handler = self.plugin.create_handler(self.wizard)

39
electrum/plugins/trezor/qt.py

@ -18,8 +18,7 @@ from electrum.plugins.hw_wallet.plugin import only_hook_if_libraries_available,
from electrum.gui.qt.util import (WindowModalDialog, WWLabel, Buttons, CancelButton, from electrum.gui.qt.util import (WindowModalDialog, WWLabel, Buttons, CancelButton,
OkButton, CloseButton, PasswordLineEdit, getOpenFileName, ChoiceWidget) OkButton, CloseButton, PasswordLineEdit, getOpenFileName, ChoiceWidget)
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUnlock, WCHWXPub, WalletWizardComponent
from electrum.gui.qt.wizard.wizard import WizardComponent
from .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TrezorInitSettings, from .trezor import (TrezorPlugin, TIM_NEW, TIM_RECOVER, TrezorInitSettings,
PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceType) PASSPHRASE_ON_DEVICE, Capability, BackupType, RecoveryDeviceType)
@ -807,7 +806,8 @@ class WCTrezorXPub(WCHWXPub):
WCHWXPub.__init__(self, parent, wizard) WCHWXPub.__init__(self, parent, wizard)
def get_xpub_from_client(self, client, derivation, xtype): def get_xpub_from_client(self, client, derivation, xtype):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
if xtype not in self.plugin.SUPPORTED_XTYPES: if xtype not in self.plugin.SUPPORTED_XTYPES:
raise ScriptTypeNotSupported(_('This type of script is not supported with {}').format(_info.model_name)) raise ScriptTypeNotSupported(_('This type of script is not supported with {}').format(_info.model_name))
if not client.is_uptodate(): if not client.is_uptodate():
@ -818,15 +818,16 @@ class WCTrezorXPub(WCHWXPub):
return client.get_xpub(derivation, xtype, True) return client.get_xpub(derivation, xtype, True)
class WCTrezorInitMethod(WizardComponent, Logger): class WCTrezorInitMethod(WalletWizardComponent, Logger):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup'))
Logger.__init__(self) Logger.__init__(self)
self.plugins = wizard.plugins self.plugins = wizard.plugins
self.plugin = None self.plugin = None
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
_name, _info = current_cosigner['hardware_device']
self.plugin = self.plugins.get_plugin(_info.plugin_name) self.plugin = self.plugins.get_plugin(_info.plugin_name)
device_id = _info.device.id_ device_id = _info.device.id_
client = self.plugins.device_manager.client_by_id(device_id, scan_now=False) client = self.plugins.device_manager.client_by_id(device_id, scan_now=False)
@ -858,18 +859,20 @@ class WCTrezorInitMethod(WizardComponent, Logger):
def apply(self): def apply(self):
if not self.valid: if not self.valid:
return return
self.wizard_data['trezor_init'] = self.choice_w.selected_key current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['trezor_init'] = self.choice_w.selected_key
class WCTrezorInitParams(WizardComponent): class WCTrezorInitParams(WalletWizardComponent):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup'))
self.plugins = wizard.plugins self.plugins = wizard.plugins
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
_name, _info = self.wizard_data['hardware_device'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
self.settings_layout = InitSettingsLayout(self.plugins.device_manager, self.wizard_data['trezor_init'], _info.device.id_) _name, _info = current_cosigner['hardware_device']
self.settings_layout = InitSettingsLayout(self.plugins.device_manager, current_cosigner['trezor_init'], _info.device.id_)
self.layout().addLayout(self.settings_layout) self.layout().addLayout(self.settings_layout)
self.layout().addStretch(1) self.layout().addStretch(1)
@ -877,12 +880,13 @@ class WCTrezorInitParams(WizardComponent):
self.busy = False self.busy = False
def apply(self): def apply(self):
self.wizard_data['trezor_settings'] = self.settings_layout.get_settings() current_cosigner = self.wizard.current_cosigner(self.wizard_data)
current_cosigner['trezor_settings'] = self.settings_layout.get_settings()
class WCTrezorInit(WizardComponent, Logger): class WCTrezorInit(WalletWizardComponent, Logger):
def __init__(self, parent, wizard): def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup')) WalletWizardComponent.__init__(self, parent, wizard, title=_('Trezor Setup'))
Logger.__init__(self) Logger.__init__(self)
self.plugins = wizard.plugins self.plugins = wizard.plugins
self.plugin = self.plugins.get_plugin('trezor') self.plugin = self.plugins.get_plugin('trezor')
@ -892,9 +896,10 @@ class WCTrezorInit(WizardComponent, Logger):
self._busy = True self._busy = True
def on_ready(self): def on_ready(self):
settings = self.wizard_data['trezor_settings'] current_cosigner = self.wizard.current_cosigner(self.wizard_data)
method = self.wizard_data['trezor_init'] settings = current_cosigner['trezor_settings']
_name, _info = self.wizard_data['hardware_device'] method = current_cosigner['trezor_init']
_name, _info = current_cosigner['hardware_device']
device_id = _info.device.id_ device_id = _info.device.id_
client = self.plugins.device_manager.client_by_id(device_id, scan_now=False) client = self.plugins.device_manager.client_by_id(device_id, scan_now=False)
client.handler = self.plugin.create_handler(self.wizard) client.handler = self.plugin.create_handler(self.wizard)

Loading…
Cancel
Save