Browse Source

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
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
d3fd87ebd0
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/base_wizard.py
  2. 6
      electrum/keystore.py
  3. 7
      electrum/plugins/hw_wallet/plugin.py

8
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,
}

6
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()

7
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()])

Loading…
Cancel
Save