New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Descriptor support for displayaddress #117
Descriptor support for displayaddress #117
Conversation
c161d8f
to
d29f0ae
Compare
d29f0ae
to
3b6e3bd
Compare
3b6e3bd
to
e22dc4c
Compare
Needs rebase |
e22dc4c
to
dfaf436
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you do --sh_wpkh --desc wpkh(...)
?
test/test_device.py
Outdated
process_commands(self.dev_args + ['displayaddress', '--path', 'm/44h/1h/0h/0/0']) | ||
process_commands(self.dev_args + ['displayaddress', '--sh_wpkh', '--path', 'm/49h/1h/0h/0/0']) | ||
process_commands(self.dev_args + ['displayaddress', '--wpkh', '--path', 'm/84h/1h/0h/0/0']) | ||
process_commands(self.dev_args + ['displayaddress', '--desc', 'wpkh(m/84h/1h/0h/0/0)']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's a valid descriptor.
if origin_match == None: | ||
return None | ||
|
||
return cls(origin_fingerprint, origin_path, base_key, path_suffix, testnet, sh_wpkh, wpkh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an error which points here: UnboundLocalError: local variable 'path_suffix' referenced before assignment
path_suffix
won't be set if the else branch above is taken.
80423aa
to
36ac3e0
Compare
Rebased. I added a check to prevent |
hwilib/commands.py
Outdated
xpub = client.get_pubkey_at_path(descriptor.m_path_base)['xpub'] | ||
if descriptor.base_key != xpub and descriptor.base_key != xpub_to_pub_hex(xpub): | ||
return {'error':'Key in descriptor does not match device: ' + desc,'code':BAD_ARGUMENT} | ||
client.display_address(descriptor.m_path, descriptor.sh_wpkh, descriptor.wpkh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a return
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to add a linter to Travis :-) Though I guess it's hard to tell because Python doesn't enforce return values.
36ac3e0
to
0c1f9f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing everything else, I think that's the last thing before I merge this
hwilib/commands.py
Outdated
if path is not None: | ||
if sh_wpkh == True and wpkh == True: | ||
return {'error':'Both `--wpkh` and `--sh_wpkh` can not be selected at the same time.','code':BAD_ARGUMENT} | ||
client.display_address(path, sh_wpkh, wpkh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
0c1f9f6
to
a71658c
Compare
ACK a71658c |
a71658c displayaddress: descriptor support, make --path a named argument (Sjors Provoost) 163f926 Add descriptor class (Sjors Provoost) 6fc1524 HardwareWalletClient: store fingerprint (Sjors Provoost) Pull request description: Adds a `Descriptor` class, which currently handles some of the descriptor functionality. Changes `displayaddress` to allow a descriptor argument. This means `--path` and `--desc` are now named arguments. When using a descriptor `displayaddress` performs additional checks to make sure the fingerprint and xpub match. To enable the fingerprint check, I'm storing the fingerprint on `HardwareWalletClient` instances. Tree-SHA512: f149481203c340b8e5347f42fd2924f1b2095197d6c25f39f94acfb11f430881412cce48c510260db4e773b662e8b2a0a747c413ba7fadfc6eb78a85f1ec4838
Adds a
Descriptor
class, which currently handles some of the descriptor functionality.Changes
displayaddress
to allow a descriptor argument. This means--path
and--desc
are now named arguments.When using a descriptor
displayaddress
performs additional checks to make sure the fingerprint and xpub match. To enable the fingerprint check, I'm storing the fingerprint onHardwareWalletClient
instances.