|
Ran
|
Jobs
1
|
Files
87
|
Run time
7s
|
Badge
README BADGES
|
push
github
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
| ID | Job ID | Ran | Files | Coverage | |
|---|---|---|---|---|---|
| 1 | 7892264908.1 | 0 |
84.04 |
GitHub Action Run |