From c97589f8de4f62e3448ec397df5db288ebe2b20c Mon Sep 17 00:00:00 2001 From: sanket1729 Date: Thu, 14 Apr 2022 10:04:46 -0700 Subject: [PATCH] Fix TapTree derserialization 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 --- src/util/psbt/serialize.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/psbt/serialize.rs b/src/util/psbt/serialize.rs index 438693f9..f541ea95 100644 --- a/src/util/psbt/serialize.rs +++ b/src/util/psbt/serialize.rs @@ -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"))