Skip to content

Commit

Permalink
Fix TapTree derserialization
Browse files Browse the repository at this point in the history
Trees should only be serialized if both of the following conditions
hold:
1) Tree is complete binary tree(is_finalized)
2) Tree does not have any hidden nodes
  • Loading branch information
ChallengeDev210 committed Apr 14, 2022
1 parent 8efc9a1 commit 2f5a46e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/psbt/serialize.rs
Expand Up @@ -355,7 +355,7 @@ impl Deserialize for TapTree {
builder = builder.add_leaf_with_ver(*depth, script, leaf_version)
.map_err(|_| encode::Error::ParseFailed("Tree not in DFS order"))?;
}
if builder.is_finalized() || !builder.has_hidden_nodes() {
if builder.is_finalized() && !builder.has_hidden_nodes() {
Ok(TapTree(builder))
} else {
Err(encode::Error::ParseFailed("Incomplete taproot Tree"))
Expand Down

0 comments on commit 2f5a46e

Please sign in to comment.