mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
hw wallets: during wallet creation, make sure to save correct label
When initialising a Trezor as part of the wallet creation, device_info.label is still the old (None) label in on_hw_derivation. This is because device_info was created during the initial scan. related: #6063
This commit is contained in:
parent
570f7b7790
commit
18d245ad5c
2 changed files with 6 additions and 5 deletions
|
@ -332,7 +332,7 @@ class BaseWizard(Logger):
|
||||||
self.choice_dialog(title=title, message=msg, choices=choices,
|
self.choice_dialog(title=title, message=msg, choices=choices,
|
||||||
run_next=lambda *args: self.on_device(*args, purpose=purpose, storage=storage))
|
run_next=lambda *args: self.on_device(*args, purpose=purpose, storage=storage))
|
||||||
|
|
||||||
def on_device(self, name, device_info, *, purpose, storage=None):
|
def on_device(self, name, device_info: 'DeviceInfo', *, purpose, storage=None):
|
||||||
self.plugin = self.plugins.get_plugin(name)
|
self.plugin = self.plugins.get_plugin(name)
|
||||||
assert isinstance(self.plugin, HW_PluginBase)
|
assert isinstance(self.plugin, HW_PluginBase)
|
||||||
devmgr = self.plugins.device_manager
|
devmgr = self.plugins.device_manager
|
||||||
|
@ -414,7 +414,7 @@ class BaseWizard(Logger):
|
||||||
self.show_error(e)
|
self.show_error(e)
|
||||||
# let the user choose again
|
# let the user choose again
|
||||||
|
|
||||||
def on_hw_derivation(self, name, device_info, derivation, xtype):
|
def on_hw_derivation(self, name, device_info: 'DeviceInfo', derivation, xtype):
|
||||||
from .keystore import hardware_keystore
|
from .keystore import hardware_keystore
|
||||||
devmgr = self.plugins.device_manager
|
devmgr = self.plugins.device_manager
|
||||||
try:
|
try:
|
||||||
|
@ -422,6 +422,7 @@ class BaseWizard(Logger):
|
||||||
client = devmgr.client_by_id(device_info.device.id_)
|
client = devmgr.client_by_id(device_info.device.id_)
|
||||||
if not client: raise Exception("failed to find client for device id")
|
if not client: raise Exception("failed to find client for device id")
|
||||||
root_fingerprint = client.request_root_fingerprint_from_device()
|
root_fingerprint = client.request_root_fingerprint_from_device()
|
||||||
|
label = client.label() # use this as device_info.label might be outdated!
|
||||||
except ScriptTypeNotSupported:
|
except ScriptTypeNotSupported:
|
||||||
raise # this is handled in derivation_dialog
|
raise # this is handled in derivation_dialog
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
@ -434,7 +435,7 @@ class BaseWizard(Logger):
|
||||||
'derivation': derivation,
|
'derivation': derivation,
|
||||||
'root_fingerprint': root_fingerprint,
|
'root_fingerprint': root_fingerprint,
|
||||||
'xpub': xpub,
|
'xpub': xpub,
|
||||||
'label': device_info.label,
|
'label': label,
|
||||||
}
|
}
|
||||||
k = hardware_keystore(d)
|
k = hardware_keystore(d)
|
||||||
self.on_keystore(k)
|
self.on_keystore(k)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Dict, List, Union, Tuple, Sequence, Optional, Type
|
from typing import TYPE_CHECKING, Dict, List, Union, Tuple, Sequence, Optional, Type
|
||||||
|
|
||||||
from electrum.plugin import BasePlugin, hook, Device, DeviceMgr
|
from electrum.plugin import BasePlugin, hook, Device, DeviceMgr, DeviceInfo
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.bitcoin import is_address, opcodes
|
from electrum.bitcoin import is_address, opcodes
|
||||||
from electrum.util import bfh, versiontuple, UserFacingException
|
from electrum.util import bfh, versiontuple, UserFacingException
|
||||||
|
@ -64,7 +64,7 @@ class HW_PluginBase(BasePlugin):
|
||||||
if isinstance(keystore, self.keystore_class):
|
if isinstance(keystore, self.keystore_class):
|
||||||
self.device_manager().unpair_xpub(keystore.xpub)
|
self.device_manager().unpair_xpub(keystore.xpub)
|
||||||
|
|
||||||
def setup_device(self, device_info, wizard: 'BaseWizard', purpose):
|
def setup_device(self, device_info: DeviceInfo, wizard: 'BaseWizard', purpose):
|
||||||
"""Called when creating a new wallet or when using the device to decrypt
|
"""Called when creating a new wallet or when using the device to decrypt
|
||||||
an existing wallet. Select the device to use. If the device is
|
an existing wallet. Select the device to use. If the device is
|
||||||
uninitialized, go through the initialization process.
|
uninitialized, go through the initialization process.
|
||||||
|
|
Loading…
Add table
Reference in a new issue