Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

va-an
Copy link
Contributor

@va-an va-an commented Jul 26, 2025

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 descriptor tr(unspendable(), TREE).

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@coveralls
Copy link

Pull Request Test Coverage Report for Build 16540773857

Details

  • 24 of 36 (66.67%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.1%) to 7.773%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utils.rs 0 2 0.0%
src/main.rs 0 3 0.0%
src/handlers.rs 24 31 77.42%
Totals Coverage Status
Change from base Build 15731603419: 5.1%
Covered Lines: 67
Relevant Lines: 862

💛 - Coveralls

Copy link
Collaborator

@tvpeter tvpeter left a 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

Comment on lines +75 to +76
/// 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.
Copy link
Collaborator

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.

// 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))
Copy link
Collaborator

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.

// 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"),
Copy link
Collaborator

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?

let json_result = result.unwrap();
let descriptor = json_result.get("descriptor").unwrap().as_str().unwrap();
assert_eq!(descriptor, EXPECTED_AND_AB);
}
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Update compile command to support creating taproot descriptors
3 participants