Prevent TapTree from hidden parts
This commit is contained in:
parent
b0f3992db1
commit
77715311cf
|
@ -143,6 +143,8 @@ impl TapTree {
|
||||||
pub fn from_inner(inner: TaprootBuilder) -> Result<Self, IncompleteTapTree> {
|
pub fn from_inner(inner: TaprootBuilder) -> Result<Self, IncompleteTapTree> {
|
||||||
if !inner.is_finalized() {
|
if !inner.is_finalized() {
|
||||||
Err(IncompleteTapTree::NotFinalized(inner))
|
Err(IncompleteTapTree::NotFinalized(inner))
|
||||||
|
} else if inner.has_hidden_nodes() {
|
||||||
|
Err(IncompleteTapTree::HiddenParts(inner))
|
||||||
} else {
|
} else {
|
||||||
Ok(TapTree(inner))
|
Ok(TapTree(inner))
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ impl Deserialize for TapTree {
|
||||||
builder = builder.add_leaf_with_ver(*depth, script, leaf_version)
|
builder = builder.add_leaf_with_ver(*depth, script, leaf_version)
|
||||||
.map_err(|_| encode::Error::ParseFailed("Tree not in DFS order"))?;
|
.map_err(|_| encode::Error::ParseFailed("Tree not in DFS order"))?;
|
||||||
}
|
}
|
||||||
if builder.is_finalized() {
|
if builder.is_finalized() || !builder.has_hidden_nodes() {
|
||||||
Ok(TapTree(builder))
|
Ok(TapTree(builder))
|
||||||
} else {
|
} else {
|
||||||
Err(encode::Error::ParseFailed("Incomplete taproot Tree"))
|
Err(encode::Error::ParseFailed("Incomplete taproot Tree"))
|
||||||
|
|
Loading…
Reference in New Issue