Skip to content

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

coveralls commented Jul 26, 2025

Pull Request Test Coverage Report for Build 17544445237

Details

  • 59 of 67 (88.06%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+6.5%) to 8.628%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utils.rs 0 2 0.0%
src/handlers.rs 59 65 90.77%
Totals Coverage Status
Change from base Build 17324807959: 6.5%
Covered Lines: 105
Relevant Lines: 1217

💛 - 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

@va-an va-an requested a review from tvpeter August 14, 2025 18:13
@tvpeter tvpeter added this to the CLI 2.0.0 milestone Aug 25, 2025
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.

@va-an Please rebase so I can test.

Thank you.

src/handlers.rs Outdated
Comment on lines 1037 to 1038
assert!(EXPECTED_PK_A.contains(NUMS_UNSPENDABLE_KEY_HEX));
assert!(EXPECTED_AND_AB.contains(NUMS_UNSPENDABLE_KEY_HEX));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering how much value these assert statements add when we are in control of the expected values ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, fixed!

@tvpeter
Copy link
Collaborator

tvpeter commented Sep 4, 2025

@va-an , can you please make some time to update this PR? It will be great if it can get in the next release in few days.

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 @va-an for updating the PR.

I left minor comments.

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.

tACK 04d0301

Thank you @va-an for working on this.

nit: If you can squash your commits into one or two messages, it would be nice.

@va-an va-an force-pushed the feat/add-tr-to-compile-cmd branch from 04d0301 to 3bcec61 Compare September 8, 2025 08:21
@va-an
Copy link
Contributor Author

va-an commented Sep 8, 2025

tACK 04d0301

Thank you @va-an for working on this.

nit: If you can squash your commits into one or two messages, it would be nice.

Right, forgot about rebase.
Did it, now there's 1 commit in the branch.

@va-an va-an requested a review from tvpeter September 8, 2025 08:26
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 @va-an

@va-an
Copy link
Contributor Author

va-an commented Sep 8, 2025

Thank you @va-an

Thank you for your patience and help!

// 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 xonly_public_key = XOnlyPublicKey::from_str(NUMS_UNSPENDABLE_KEY_HEX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe technically the NUMS_UNSPENDABLE_KEY_HEX is not supposed to be used as is (privacy concerns), though for now it's fine. Per BIP-0431, should add an issue to do the following:

"In order to avoid leaking the information that key path spending is not possible it is recommended to pick a fresh integer r in the range 0...n-1 uniformly at random and use H + rG as internal key. It is possible to prove that this internal key does not have a known discrete logarithm with respect to G by revealing r to a verifier who can then reconstruct how the internal key was created."

Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 3bcec61

@tvpeter tvpeter merged commit a821a79 into bitcoindevkit:master Sep 8, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this to Done in BDK-CLI Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Update compile command to support creating taproot descriptors
5 participants