commit d3fd87ebd0f4d7b836f6e7f7360f047e330d5698
parent 68dad21fb467ddb172884048a50f87978e11d3f8
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 2 Dec 2019 19:31:17 +0100
hardware wallets: wizard no longer requests xpub at path "m"
This was done to calculate the bip32 root fingerprint but it broke
the digitalbitbox. The keystore already had a different way to get
the root fingerprint for existing wallets, specifically handling this
case; the code in base_wizard used when creating new wallets was
duplicating that code originally and was then forgotten to be updated.
Now these codepaths are unified.
closes #5816
Diffstat:
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py
@@ -418,21 +418,23 @@ class BaseWizard(Logger):
def on_hw_derivation(self, name, device_info, derivation, xtype):
from .keystore import hardware_keystore
+ devmgr = self.plugins.device_manager
try:
xpub = self.plugin.get_xpub(device_info.device.id_, derivation, xtype, self)
- root_xpub = self.plugin.get_xpub(device_info.device.id_, 'm', 'standard', self)
+ client = devmgr.client_by_id(device_info.device.id_)
+ if not client: raise Exception("failed to find client for device id")
+ root_fingerprint = client.request_root_fingerprint_from_device()
except ScriptTypeNotSupported:
raise # this is handled in derivation_dialog
except BaseException as e:
self.logger.exception('')
self.show_error(e)
return
- xfp = BIP32Node.from_xkey(root_xpub).calc_fingerprint_of_this_node().hex().lower()
d = {
'type': 'hardware',
'hw_type': name,
'derivation': derivation,
- 'root_fingerprint': xfp,
+ 'root_fingerprint': root_fingerprint,
'xpub': xpub,
'label': device_info.label,
}
diff --git a/electrum/keystore.py b/electrum/keystore.py
@@ -709,11 +709,7 @@ class Hardware_KeyStore(KeyStore, Xpub):
def opportunistically_fill_in_missing_info_from_device(self, client: 'HardwareClientBase'):
assert client is not None
if self._root_fingerprint is None:
- # digitalbitbox (at least) does not reveal xpubs corresponding to unhardened paths
- # so ask for a direct child, and read out fingerprint from that:
- child_of_root_xpub = client.get_xpub("m/0'", xtype='standard')
- root_fingerprint = BIP32Node.from_xkey(child_of_root_xpub).fingerprint.hex().lower()
- self._root_fingerprint = root_fingerprint
+ self._root_fingerprint = client.request_root_fingerprint_from_device()
self.is_requesting_to_be_rewritten_to_wallet_file = True
if self.label != client.label():
self.label = client.label()
diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py
@@ -175,6 +175,13 @@ class HardwareClientBase:
def get_xpub(self, bip32_path: str, xtype) -> str:
raise NotImplementedError()
+ def request_root_fingerprint_from_device(self) -> str:
+ # digitalbitbox (at least) does not reveal xpubs corresponding to unhardened paths
+ # so ask for a direct child, and read out fingerprint from that:
+ child_of_root_xpub = self.get_xpub("m/0'", xtype='standard')
+ root_fingerprint = BIP32Node.from_xkey(child_of_root_xpub).fingerprint.hex().lower()
+ return root_fingerprint
+
def is_any_tx_output_on_change_branch(tx: PartialTransaction) -> bool:
return any([txout.is_change for txout in tx.outputs()])