-
Notifications
You must be signed in to change notification settings - Fork 80
Update compile
command to support creating taproot descriptors
#208
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: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 16973164527Details
💛 - Coveralls |
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.
Thank you for working on this @va-an .
I have left a few comments for you.
Thank you
src/handlers.rs
Outdated
/// Well-known unspendable key used for Taproot descriptors when only script path is intended. | ||
/// This is a NUMS (Nothing Up My Sleeve) point that ensures the key path cannot be used. |
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.
since you provided detailed comments in the usage block, this documentation seems redundant.
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.
Deleted.
src/handlers.rs
Outdated
// This ensures the key path is effectively disabled and only script path can be used. | ||
// See https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs | ||
let tree = TapTree::Leaf(Arc::new(taproot_policy)); | ||
Descriptor::new_tr(NUMS_UNSPENDABLE_KEY.to_string(), Some(tree)) |
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.
I guess the NUMS_UNSPENDABLE_KEY represents XonlyPublicKey, so it is better to parse it into an XonlyPublicKey and not used as a string (since strings are used for key placeholders) to avoid type mismatch.
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.
I've added validation that NUMS_UNSPENDABLE_KEY
is parsed as XOnlyPublicKey
.
Do you mean that nums_key should be passed as XOnlyPublicKey
to the new_tr
function?
src/handlers.rs
Outdated
// See https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs | ||
let tree = TapTree::Leaf(Arc::new(taproot_policy)); | ||
Descriptor::new_tr(NUMS_UNSPENDABLE_KEY.to_string(), Some(tree)) | ||
} | ||
_ => panic!("Invalid type"), |
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.
can you help and change from panic to a graceful handling of the error?
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.
Changed, pls have a look.
let json_result = result.unwrap(); | ||
let descriptor = json_result.get("descriptor").unwrap().as_str().unwrap(); | ||
assert_eq!(descriptor, EXPECTED_AND_AB); | ||
} |
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.
can you also add test cases for invalid/invalid policies and other edge cases?
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.
Added some cases as separated test.
Description
Resolves #204.
Notes to the reviewers
For creating the tr descriptor, I used the NUMS pubkey proposed in BIP-341.
There is discussion about adding NUMS key to
rust-bicoin
, we can use it in the future from there.Also there is BIP draft for new descriptor key expression
unspendable()
for exacly this use case - we will simply use descriptortr(unspendable(), TREE)
.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
CHANGELOG.md