Skip to content

Commit 5abc70c

Browse files
committed
tr: break Tr API in a couple ways
We fix the return value of Tr::tap_tree to return a Option<&T> instead of an &Option<T>; we already do this in Descriptor::tap_tree, which is likely to be more commonly called ... and both methods are pretty obscure. Also remove the iter_scripts method in favor of leaves. We did this rename in the previous PR. However, that PR broke its API anyway by making it yield an opaque struct rather than a tuple. Better to just do all the breakage at once. Maaybe we should backport the rename to 12.x as a pure rename, so that people will update their code and get nicer error messages.
1 parent d2e30d5 commit 5abc70c

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/descriptor/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
256256
/// returned value.
257257
pub fn tap_tree(&self) -> Option<&TapTree<Pk>> {
258258
if let Descriptor::Tr(ref tr) = self {
259-
tr.tap_tree().as_ref()
259+
tr.tap_tree()
260260
} else {
261261
None
262262
}
@@ -268,7 +268,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
268268
/// Taproot descriptor containing only a keyspend, returns an empty iterator.
269269
pub fn tap_tree_iter(&self) -> tr::TapTreeIter<Pk> {
270270
if let Descriptor::Tr(ref tr) = self {
271-
if let Some(ref tree) = tr.tap_tree() {
271+
if let Some(tree) = tr.tap_tree() {
272272
return tree.leaves();
273273
}
274274
}
@@ -988,7 +988,7 @@ impl<Pk: FromStrKey> FromStr for Descriptor<Pk> {
988988
// FIXME preserve weird/broken behavior from 12.x.
989989
// See https://github.com/rust-bitcoin/rust-miniscript/issues/734
990990
ret.sanity_check()?;
991-
for item in inner.iter_scripts() {
991+
for item in inner.leaves() {
992992
item.miniscript()
993993
.ext_check(&crate::miniscript::analyzable::ExtParams::sane())?;
994994
}

src/descriptor/tr/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
105105
pub fn internal_key(&self) -> &Pk { &self.internal_key }
106106

107107
/// Obtain the [`TapTree`] of the [`Tr`] descriptor
108-
pub fn tap_tree(&self) -> &Option<TapTree<Pk>> { &self.tree }
109-
110-
/// Obtain the [`TapTree`] of the [`Tr`] descriptor
111-
#[deprecated(since = "11.0.0", note = "use tap_tree instead")]
112-
pub fn taptree(&self) -> &Option<TapTree<Pk>> { self.tap_tree() }
113-
114-
/// Iterate over all scripts in merkle tree. If there is no script path, the iterator
115-
/// yields [`None`]
116-
#[deprecated(since = "TBD", note = "use `leaves` instead")]
117-
pub fn iter_scripts(&self) -> TapTreeIter<Pk> { self.leaves() }
108+
pub fn tap_tree(&self) -> Option<&TapTree<Pk>> { self.tree.as_ref() }
118109

119110
/// Iterates over all the leaves of the tree in depth-first preorder.
120111
///

0 commit comments

Comments
 (0)