Skip to content

Descriptor support for displayaddress#117

Merged
achow101 merged 3 commits into
bitcoin-core:masterfrom
Sjors:2019/02/displayaddress_descriptor
Feb 15, 2019
Merged

Descriptor support for displayaddress#117
achow101 merged 3 commits into
bitcoin-core:masterfrom
Sjors:2019/02/displayaddress_descriptor

Conversation

@Sjors
Copy link
Copy Markdown
Member

@Sjors Sjors commented Feb 2, 2019

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.

Comment thread hwilib/cli.py Outdated
@Sjors Sjors force-pushed the 2019/02/displayaddress_descriptor branch from 3b6e3bd to e22dc4c Compare February 5, 2019 09:25
@achow101
Copy link
Copy Markdown
Member

Needs rebase

@Sjors Sjors force-pushed the 2019/02/displayaddress_descriptor branch from e22dc4c to dfaf436 Compare February 10, 2019 15:24
@Sjors
Copy link
Copy Markdown
Member Author

Sjors commented Feb 10, 2019

Rebased

Copy link
Copy Markdown
Member

@achow101 achow101 left a 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(...)?

Comment thread 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)'])
Copy link
Copy Markdown
Member

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.

Comment thread hwilib/descriptor.py
if origin_match == None:
return None

return cls(origin_fingerprint, origin_path, base_key, path_suffix, testnet, sh_wpkh, wpkh)
Copy link
Copy Markdown
Member

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.

@Sjors Sjors force-pushed the 2019/02/displayaddress_descriptor branch 5 times, most recently from 80423aa to 36ac3e0 Compare February 13, 2019 16:01
@Sjors
Copy link
Copy Markdown
Member Author

Sjors commented Feb 13, 2019

Rebased. I added a check to prevent --sh_wpkh and --wpkh from being used in combination with --desc. Fixed path_suffix. Added a bunch more tests.

Comment thread 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)
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

@Sjors Sjors Feb 14, 2019

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.

@Sjors Sjors force-pushed the 2019/02/displayaddress_descriptor branch from 36ac3e0 to 0c1f9f6 Compare February 14, 2019 08:35
@Sjors Sjors mentioned this pull request Feb 14, 2019
12 tasks
Copy link
Copy Markdown
Member

@achow101 achow101 left a 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

Comment thread 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return here too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@achow101 achow101 added this to the 1.0 milestone Feb 14, 2019
@Sjors Sjors force-pushed the 2019/02/displayaddress_descriptor branch from 0c1f9f6 to a71658c Compare February 15, 2019 07:44
@achow101
Copy link
Copy Markdown
Member

ACK a71658c

@achow101 achow101 merged commit a71658c into bitcoin-core:master Feb 15, 2019
achow101 added a commit that referenced this pull request Feb 15, 2019
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
@Sjors Sjors deleted the 2019/02/displayaddress_descriptor branch February 16, 2019 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants