Skip to content

Commit edf9373

Browse files
committed
Separate taptree in identifiers and docs
We use `TapTree` therefore the all lowercase version should be `tap_tree` not `taptree`.
1 parent ecf876e commit edf9373

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

examples/taproot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn main() {
101101
let real_desc = desc.translate_pk(&mut t).unwrap();
102102

103103
// Max satisfaction weight for compilation, corresponding to the script-path spend
104-
// `multi_a(2,PUBKEY_1,PUBKEY_2) at taptree depth 1, having:
104+
// `multi_a(2,PUBKEY_1,PUBKEY_2) at tap tree depth 1, having:
105105
//
106106
// max_witness_size = varint(control_block_size) + control_block size +
107107
// varint(script_size) + script_size + max_satisfaction_size

src/descriptor/tr.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,16 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
186186
}
187187

188188
/// Obtain the [`TapTree`] of the [`Tr`] descriptor
189-
pub fn taptree(&self) -> &Option<TapTree<Pk>> {
189+
pub fn tap_tree(&self) -> &Option<TapTree<Pk>> {
190190
&self.tree
191191
}
192192

193+
/// Obtain the [`TapTree`] of the [`Tr`] descriptor
194+
#[deprecated(since = "11.0.0", note = "use tap_tree instead")]
195+
pub fn taptree(&self) -> &Option<TapTree<Pk>> {
196+
self.tap_tree()
197+
}
198+
193199
/// Iterate over all scripts in merkle tree. If there is no script path, the iterator
194200
/// yields [`None`]
195201
pub fn iter_scripts(&self) -> TapTreeIter<Pk> {
@@ -258,7 +264,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
258264
/// # Errors
259265
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
260266
pub fn max_weight_to_satisfy(&self) -> Result<usize, Error> {
261-
let tree = match self.taptree() {
267+
let tree = match self.tap_tree() {
262268
None => {
263269
// key spend path
264270
// item: varint(sig+sigHash) + <sig(64)+sigHash(1)>
@@ -309,7 +315,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
309315
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
310316
#[deprecated(note = "use max_weight_to_satisfy instead")]
311317
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
312-
let tree = match self.taptree() {
318+
let tree = match self.tap_tree() {
313319
// key spend path:
314320
// scriptSigLen(4) + stackLen(1) + stack[Sig]Len(1) + stack[Sig](65)
315321
None => return Ok(4 + 1 + 1 + 65),

src/policy/concrete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
403403
compilation.sanity_check()?;
404404
leaf_compilations.push((OrdF64(prob), compilation));
405405
}
406-
let taptree = with_huffman_tree::<Pk>(leaf_compilations)?;
407-
Some(taptree)
406+
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations)?;
407+
Some(tap_tree)
408408
}
409409
},
410410
)?;
@@ -462,8 +462,8 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
462462
)
463463
})
464464
.collect();
465-
let taptree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
466-
Some(taptree)
465+
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
466+
Some(tap_tree)
467467
}
468468
},
469469
)?;

src/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ fn update_item_with_descriptor_helper<F: PsbtFields>(
12221222
match item.tap_tree() {
12231223
// Only set the tap_tree if the item supports it (it's an output) and the descriptor actually
12241224
// contains one, otherwise it'll just be empty
1225-
Some(tap_tree) if tr_derived.taptree().is_some() => {
1225+
Some(tap_tree) if tr_derived.tap_tree().is_some() => {
12261226
*tap_tree = Some(
12271227
taproot::TapTree::try_from(builder)
12281228
.expect("The tree should always be valid"),

0 commit comments

Comments
 (0)