• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rust-bitcoin / rust-bitcoin / 7892264908
83%

Build:
DEFAULT BRANCH: master
Ran 13 Feb 2024 08:24PM UTC
Jobs 1
Files 87
Run time 7s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

13 Feb 2024 08:18PM UTC coverage: 84.038% (-0.007%) from 84.045%
7892264908

push

github

apoelstra
Merge rust-bitcoin/rust-bitcoin#2467: taproot: add TapNodeHash getter method on TapTree and NodeInfo

138433002 taproot: add TapNodeHash getter method on TapTree and NodeInfo (conduition)

Pull request description:

  Submitting this to fix what I think is an API hole. Please correct me if I'm mistaken here and there is an easier way to do what I'm after.

  ## Problem

  From what I can tell of the existing 0.31.1 API, there doesn't seem to be any way for a consumer to build a taproot tree using `TaprootBuilder` and then simply output the resulting tap tree merkle root `TapNodeHash`.

  Instead, the API forces me to do `TaprootBuilder::finalize(secp_ctx, internal_key)` first to get a `TaprootSpendInfo`, and then call `TaprootSpendInfo::merkle_root()` to get the root `TapNodehash`. This requires ECC point addition/multiplication for the tweak operation (inside `TaprootBuilder::finalize`), so it is a lot less performant than the simple hashing operations needed to build a taproot tree.

  Obviously if I want to spend the taproot tree, I'll need to tweak an internal key. But if all I want is to examine the merkle root hashes of taproot trees (e.g. for quick validation), there should be a faster and more direct option for me.

  ## Suggested Solution

  My suggestion, demonstrated in this PR, would be to add a couple of simple getter methods:

  - `TapTree::node_hash() -> TapNodeHash`
  - `NodeInfo::node_hash() -> TapNodeHash`

  These rhyme with the existing `LeafNode::node_hash()` method. These provide a roundabout way for downstream consumers to extract a taptree merkle root `TapNodeHash` while still using the safe API provided by `TaprootBuilder`. I would simply use `TaprootBuilder` to build a `TapTree` or `NodeInfo`, and then invoke the `node_hash` method on that object. No point addition required.

  ## Footguns

  This does open up more opportunities for consumers to footgun themselves by, for example, committing a P... (continued)

19433 of 23124 relevant lines covered (84.04%)

16776.18 hits per line

Jobs
ID Job ID Ran Files Coverage
1 7892264908.1 13 Feb 2024 08:24PM UTC 0
84.04
GitHub Action Run
Source Files on build 7892264908
Detailed source file information is not available for this build.
  • Back to Repo
  • Github Actions Build #7892264908
  • 668df1d2 on github
  • Prev Build on master (#7879164707)
  • Next Build on master (#7917967798)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc