-
Notifications
You must be signed in to change notification settings - Fork 155
more DefiniteDescriptorKey
fixes and cleanups
#839
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
Open
apoelstra
wants to merge
8
commits into
rust-bitcoin:master
Choose a base branch
from
apoelstra:2025-07_more_key
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Our current API allows constructing a DefiniteDescriptorKey with hardened steps, which means that you can't actually derive a public key. However, the point of this type is to provide a DescriptorPublicKey which implements the ToPublicKey trait. The next commits will change the API to reflect this, but this commit is on its own to make it easier for me to backport it.
These have been deprecated since 2ad6555 which made it into the 9.x release. Fine to delete them.
There is no reason callers need to provide these types explicitly. Allow them to do so anyway for backward compatibility. (This commit I pulled out of my mega-refactor branch, but it seemed useful here, so I'm pulling it in now.)
e8a88ae
to
a05305a
Compare
Now that we are consistent about the rules that a DerivedDescriptor must obey, we no longer return a Result from derived_key(), which in turn eliminates a bunch of other unwraps.
Going forward, we should only derive Debug and whichever of Clone, PartialEq and Eq are possible. PartialEq is very useful for doing assertions, and Clone is often useful because it allows Results to be cloned. But the other traits are uncommon to implement on error types, have an unclear meaning, and limit our ability to compose types without breaking changes. Also adds a bunch of Eq bounds to error types that implement PartialEq. There is almost never a reason to implement PartialEq but not Eq. In the next commit I'm gonna replace ConversionError, an old error which derives all these things, with the new NonDefiniteKeyError, which will prevent these derives from working on UtxoUpdateError.
The new error type is now more descriptive and a strict superset of the old one. Furthermore, the new name is more appropriate since this error typically arises during construction of a DefiniteDescriptorKey rather than during conversion between different key types.
a05305a
to
f09bf48
Compare
apoelstra
added a commit
that referenced
this pull request
Jul 5, 2025
1374ae4 bump version to 12.3.4 (Andrew Poelstra) de73db9 key: fix DefiniteDescriptorKey construction from key with hardened step (Andrew Poelstra) Pull request description: ACKs for top commit: sanket1729: ACK 1374ae4 Tree-SHA512: 4f4faac8df85e137eb901a2df42780c1b5cfda31746b8906d628942d038bb16e44be88d07255e8f952ebbc2e43f37207c72d02952c34a3a619aa68d536bd98cc
apoelstra
added a commit
that referenced
this pull request
Jul 5, 2025
e8ce03c bump version to 11.2.3 (Andrew Poelstra) ca3282c key: fix DefiniteDescriptorKey construction from key with hardened step (Andrew Poelstra) Pull request description: ACKs for top commit: sanket1729: utACK e8ce03c Tree-SHA512: 7a3e6c864fecb5ec53805af02cae7856ba265d674c80f4520fabd8e4fa7dafb6e29d640a0a2fe383b70ed86bc476406458ecfa768f8ff50c1317c87985b138a3
apoelstra
added a commit
that referenced
this pull request
Jul 5, 2025
d61103f bump version to 10.2.3 (Andrew Poelstra) ac76ce0 key: fix DefiniteDescriptorKey construction from key with hardened step (Andrew Poelstra) Pull request description: ACKs for top commit: sanket1729: utACK d61103f Tree-SHA512: 364519c25c47ebc439ee927321bf058fce9047ca790c180e4df4c73b306c1b480ff7cb14f223bb031c31751c2f42d3b5ad79a2149b952dd608b98ea87440e063
apoelstra
commented
Jul 6, 2025
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.
On f09bf48 successfully ran local tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Again this one changes logic in a way that I need to backport, but the backport PRs will be much simpler since they are constrained not to change the API.
This one makes it impossible to construct a
DefiniteDescriptorKey
with hardened derivation steps. Previously this was usually impossible, but not always, which led to inconsistent error checks and a proliferance ofunwrap
s and generally hard-to-reason-about behavior.