-
Notifications
You must be signed in to change notification settings - Fork 163
feat(descriptor): backport GetKey
impl from #851
#860
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
base: release-12.x
Are you sure you want to change the base?
feat(descriptor): backport GetKey
impl from #851
#860
Conversation
61512c1
to
9d752e5
Compare
- it's required in order to have all the added variants for `KeyRequest` type.
9d752e5
to
bfeae8e
Compare
- add `KeyMapWrapper` with `GetKey` trait for PSBT signing - implement `GetKey` for `DescriptorSecretKey` - add `From<KeyMap>` conversion - export new `KeyMapWrapper` for downstream crate usage
bfeae8e
to
c7d4171
Compare
In c7d4171: Wait, why can't we directly implement |
As it's a type alias for |
Ohh, derp. Yes, I forgot that |
.find_map(|(_desc_pk, desc_sk)| -> Option<PrivateKey> { | ||
match desc_sk.get_key(key_request.clone(), secp) { | ||
Ok(Some(pk)) => Some(pk), | ||
Ok(None) | Err(_) => None, |
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.
In c7d4171:
Here (and below) you swallow the error from DescriptorSecretKey::get_key
and turn it into a "key not found" by returning None
.
This is an issue with the code on master. I will open a fix PR and then I'd like you to also backport that.
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.
Actually, now I'm unsure. We did not discuss this at all in #851 but I think your original code was correct. These errors occur if you try to get an x-only key from an xpriv (even this I'm unsure of, now..). But when doing a lookup in a map where we may have a combination of xprivs and bare secret keys, then individual errors aren't actually errors. They're just "key not found".
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.
Lemme PR some unit tests and I'll just ask you to backport those :P.
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.
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.
Thanks, I've cherry-picked the commits and updated the required types for KeyMapWrapper
.
Claude 4 wrote the original tests; I then replaced its fix (which incorrectly also propagated errors in GetKey for KeyMap), updated the tests, and removed some extra tests which seemed uninformative and just noisy. To backport this to 12.x, just do s/KeyMap/KeyMapWrapper/ on the new tests. Oh, and add some `let keymap = KeyMapWrapper::from(keymap)` lines. Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>
Also, I've discussed with Tobin, and should I go ahead and add a commit already deprecating the type, or should it be done when the v13.0.0 release is closer? |
Yeah I suggested deprecating
I'm late to the party but on EDIT: derp, its an alias on this branch - woops. |
Yes, on master it's already the correct type because of #851. But in release/12.x it's still the old type alias. Indeed, the docs are wrong, will create a commit to fix it. |
Is the next release |
Yeah I suggested deprecating the |
FWIW everything else looks fine to me, I did not review closely that the backport patch mirrors the original. |
I think we would need 12.3.6 then, but I'm not sure what @apoelstra had in mind, so I'll leave it to him to answer. |
Interesting question. Yeah, let's do 12.4.0. I think that's the right thing to do anyway since we are adding functionality. |
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.
ACK 08fa87a; successfully ran local tests
backports #851 to release/12.x
Description
It's an initial attempt to backport the implementation of GetKey for KeyMap introduced in #851.
Notes to the reviewers
I noticed that the type
KeyMapWrapper
is already being used internally for parse_descriptor, though, as it's not part of the public API, there's no conflict, but I'm fine with changing it to another name if needed.Changelog Notice