Skip to content

Implement descriptor checksums#130

Merged
achow101 merged 3 commits intobitcoin-core:masterfrom
achow101:desc-checksum
Feb 19, 2019
Merged

Implement descriptor checksums#130
achow101 merged 3 commits intobitcoin-core:masterfrom
achow101:desc-checksum

Conversation

@achow101
Copy link
Copy Markdown
Member

Adds checksums to the Descriptor class. Checksums are optional, but if provided, must be valid. getkeypool is also changed to use the descriptor class to return checksums. Tests are updated so that all descriptors used have checksums.

Closes #129

@Sjors
Copy link
Copy Markdown
Member

Sjors commented Feb 18, 2019

Concept ACK.

displayaddress also needs to support (optional?) checksums, since Bitcoin Core will automatically add them

Comment thread hwilib/descriptor.py
@@ -1,5 +1,54 @@
import re

# From: https://github.com/bitcoin/bitcoin/blob/master/src/script/descriptor.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not just copy test/functional/test_framework/descriptors.py which I think has more review than transliteration of the C++?

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.

Because I didn't know that file existed. I don't think it really matters either way. At least the C++ has code comments explaining how it works.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

meh ok as long as we're generally relying on the C++ code for generation/validation we should be fine.

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 also prefer using the upstream Python code, and copying comments. Not only does it have more review, it's used in the test suite to check against the c++ implementation. Our own test suite, since it clones Bitcoin Core anyway, could do a diff to make sure our implementation remains identical.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worst case let's just swap it out in a future PR.

@instagibbs
Copy link
Copy Markdown
Collaborator

@Sjors we should make sure we have a test covering that case as well

@achow101
Copy link
Copy Markdown
Member Author

displayaddress also needs to support (optional?) checksums, since Bitcoin Core will automatically add them

This change does that. Checkums are currently optional for displayaddress.

@achow101 achow101 added this to the 1.0 milestone Feb 18, 2019
Copy link
Copy Markdown
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

tACK 2d62204 though with a strong preference to switch the Python checksum code.

I tested displayaddress with and without checksum.

Comment thread hwilib/descriptor.py
@@ -1,5 +1,54 @@
import re

# From: https://github.com/bitcoin/bitcoin/blob/master/src/script/descriptor.cpp
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 also prefer using the upstream Python code, and copying comments. Not only does it have more review, it's used in the test suite to check against the c++ implementation. Our own test suite, since it clones Bitcoin Core anyway, could do a diff to make sure our implementation remains identical.

@Sjors
Copy link
Copy Markdown
Member

Sjors commented Feb 19, 2019

For anyone else having difficulty fetching this branch after the repo move, this works too:

wget https://patch-diff.githubusercontent.com/raw/bitcoin-core/HWI/pull/130.patch && git apply 130.patch

@instagibbs
Copy link
Copy Markdown
Collaborator

tACK 2d62204

with the same dissent as @Sjors . We can swap it out next.

@achow101 achow101 merged commit 2d62204 into bitcoin-core:master Feb 19, 2019
achow101 added a commit that referenced this pull request Feb 19, 2019
2d62204 Use descriptors with checksums in TestSignTx (Andrew Chow)
c2ff20b Use descriptor class in getkeypool (Andrew Chow)
f2aff4d Add descriptor checksums and tests (Andrew Chow)

Pull request description:

  Adds checksums to the Descriptor class. Checksums are optional, but if provided, must be valid. `getkeypool` is also changed to use the descriptor class to return checksums. Tests are updated so that all descriptors used have checksums.

  Closes #129

Tree-SHA512: f77b44a1edbc02d4dc6130fb4f6a97aadf2f12fef90f4b93e734df7374decb060e5486f0a5a03074aa696f6af3c772a52380bbce3ef045042e00597791aacbd1
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.

3 participants