Skip to content

Commit 37fea86

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 feae54c commit 37fea86

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ impl<Pk: MiniscriptKey> hash::Hash for Tr<Pk> {
110110
impl<Pk: MiniscriptKey> TapTree<Pk> {
111111
// Helper function to compute height
112112
// TODO: Instead of computing this every time we add a new leaf, we should
113-
// add height as a separate field in taptree
114-
fn taptree_height(&self) -> usize {
113+
// add height as a separate field in tap tree
114+
fn tap_tree_height(&self) -> usize {
115115
match *self {
116116
TapTree::Tree(ref left_tree, ref right_tree) => {
117-
1 + max(left_tree.taptree_height(), right_tree.taptree_height())
117+
1 + max(left_tree.tap_tree_height(), right_tree.tap_tree_height())
118118
}
119119
TapTree::Leaf(..) => 0,
120120
}
@@ -167,7 +167,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
167167
/// Create a new [`Tr`] descriptor from internal key and [`TapTree`]
168168
pub fn new(internal_key: Pk, tree: Option<TapTree<Pk>>) -> Result<Self, Error> {
169169
Tap::check_pk(&internal_key)?;
170-
let nodes = tree.as_ref().map(|t| t.taptree_height()).unwrap_or(0);
170+
let nodes = tree.as_ref().map(|t| t.tap_tree_height()).unwrap_or(0);
171171

172172
if nodes <= TAPROOT_CONTROL_MAX_NODE_COUNT {
173173
Ok(Self {
@@ -186,7 +186,7 @@ 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

@@ -258,7 +258,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
258258
/// # Errors
259259
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
260260
pub fn max_weight_to_satisfy(&self) -> Result<usize, Error> {
261-
let tree = match self.taptree() {
261+
let tree = match self.tap_tree() {
262262
None => {
263263
// key spend path
264264
// item: varint(sig+sigHash) + <sig(64)+sigHash(1)>
@@ -309,7 +309,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
309309
/// When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
310310
#[deprecated(note = "use max_weight_to_satisfy instead")]
311311
pub fn max_satisfaction_weight(&self) -> Result<usize, Error> {
312-
let tree = match self.taptree() {
312+
let tree = match self.tap_tree() {
313313
// key spend path:
314314
// scriptSigLen(4) + stackLen(1) + stack[Sig]Len(1) + stack[Sig](65)
315315
None => return Ok(4 + 1 + 1 + 65),

src/policy/concrete.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
387387
_ => {
388388
let (internal_key, policy) = self.clone().extract_key(unspendable_key)?;
389389
policy.check_num_tapleaves()?;
390-
let tree = Descriptor::new_tr(
390+
let tap_tree = Descriptor::new_tr(
391391
internal_key,
392392
match policy {
393393
Policy::Trivial => None,
@@ -403,12 +403,12 @@ 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 tree = with_huffman_tree::<Pk>(leaf_compilations)?;
407+
Some(tree)
408408
}
409409
},
410410
)?;
411-
Ok(tree)
411+
Ok(tap_tree)
412412
}
413413
}
414414
}
@@ -444,7 +444,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
444444
)),
445445
_ => {
446446
let (internal_key, policy) = self.clone().extract_key(unspendable_key)?;
447-
let tree = Descriptor::new_tr(
447+
let tap_tree = Descriptor::new_tr(
448448
internal_key,
449449
match policy {
450450
Policy::Trivial => None,
@@ -462,12 +462,12 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
462462
)
463463
})
464464
.collect();
465-
let taptree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
466-
Some(taptree)
465+
let tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
466+
Some(tree)
467467
}
468468
},
469469
)?;
470-
Ok(tree)
470+
Ok(tap_tree)
471471
}
472472
}
473473
}

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)