Skip to content

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
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

apoelstra
Copy link
Member

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 of unwraps and generally hard-to-reason-about behavior.

apoelstra added 4 commits July 5, 2025 20:50
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.)
apoelstra added 4 commits July 5, 2025 21:52
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.
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
Copy link
Member Author

@apoelstra apoelstra left a 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant