-
Notifications
You must be signed in to change notification settings - Fork 138
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
Implement GetKey
for KeyMap
#765
base: master
Are you sure you want to change the base?
Conversation
ba5b2bf
to
4a3bd7e
Compare
cc @LLFourn |
81b4923
to
00342a1
Compare
Nice! Yeah, this is probably the right approach. In 00342a1 you have a bunch of Alternately, you could make |
Thanks @tcharding. It might be nice to be able to |
Yes I threw the |
Concept ACK |
Maybe in the longer term, a cleaner solution is to implement rust-bitcoin to implement impl_get_key_tuple!((T1, T2))
impl GetKey for Vec<T> where T: GetKey {
}
impl GetKey for BtreeSet<T>... |
Concept ACK. |
00342a1
to
4920626
Compare
Implemented Also made new take only the secret key. I did not remove any |
4920626
to
a97c37a
Compare
Create a `KeyMay` type to replace the current `BTreeMap` alias and implement `bitcoin::psbt::GetKey` for it. Close: rust-bitcoin#709
a97c37a
to
d2c954a
Compare
Copilot
AI
left a comment
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
src/descriptor/key_map.rs:143
- The use of the
unreachable!
macro can be problematic if assumptions change. Consider handling this case more gracefully.
unreachable!("XPrv maps to XPrv")
src/descriptor/key_map.rs:22
- [nitpick] The name
KeyMap
is quite generic. Consider renaming it to something more descriptive likeDescriptorKeyMap
.
pub struct KeyMap {
if pk == request { | ||
match v { | ||
DescriptorSecretKey::Single(ref sk) => Some(sk.key), | ||
_ => unreachable!("Single maps to Single"), |
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.
The use of the unreachable!
macro can be problematic if assumptions change. Consider handling this case more gracefully.
_ => unreachable!("Single maps to Single"), | |
_ => return Err(GetKeyError::InvalidKey), |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
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.
Lol, no
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.
AI is so awesome I think we are all going to be out of a job soon.
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.
Not if your job is to have fun :)
None | ||
} | ||
} | ||
_ => unreachable!("XPrv maps to XPrv"), |
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.
The use of the unreachable!
macro can be problematic if assumptions change. Consider handling this case more gracefully.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
DescriptorSecretKey::MultiXPrv(xpriv) => { | ||
Some(xpriv.xkey.to_priv()) | ||
} | ||
_ => unreachable!("MultiXPrv maps to MultiXPrv"), |
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.
The use of the unreachable!
macro can be problematic if assumptions change. Consider handling this case more gracefully.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Too bad. copilot has been around long enough that you'd think it would work, but 100% of its suggestions are wrong and it's full of irritating woke language like "harmful" and "problematic". |
Ok(self.map.iter().find_map(|(k, v)| { | ||
match k { | ||
DescriptorPublicKey::Single(ref pk) => match key_request { | ||
KeyRequest::Pubkey(ref request) => match pk.key { |
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 d2c954a:
I think if you replace
match k {
Thing => match key_request {
Thing2 => ...
with
match (k, key_request) {
(Thing, Thing) => {
you can reduce the amount of indentation and should be able to reduce the number of branches.
:) . Still too far. Let's try it in another 6 months. |
@apoelstra @tcharding wdyt about #765 (comment)? I think that would solve future API requests like extend, merge etc |
concept ACK, though we haven't really looked at |
Create a
KeyMap
type to replace the currentBTreeMap
alias and implementbitcoin::psbt::GetKey
for it.Close: #709