From 30ff25cf37eec4b09ab40424eb5d6a4a80410955 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 16 Aug 2022 15:26:19 -0400 Subject: [PATCH] psbt: Only include m_tap_tree if it has scripts --- src/psbt.cpp | 2 +- src/script/standard.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/psbt.cpp b/src/psbt.cpp index 6c6ea6a555e..cbf2f887884 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -249,7 +249,7 @@ void PSBTOutput::FromSignatureData(const SignatureData& sigdata) if (!sigdata.tr_spenddata.internal_key.IsNull()) { m_tap_internal_key = sigdata.tr_spenddata.internal_key; } - if (sigdata.tr_builder.has_value()) { + if (sigdata.tr_builder.has_value() && sigdata.tr_builder->HasScripts()) { m_tap_tree = sigdata.tr_builder->GetTreeTuples(); } for (const auto& [pubkey, leaf_origin] : sigdata.taproot_misc_pubkeys) { diff --git a/src/script/standard.h b/src/script/standard.h index 1e6769782a3..966a52b2c78 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -315,6 +315,8 @@ public: TaprootSpendData GetSpendData() const; /** Returns a vector of tuples representing the depth, leaf version, and script */ std::vector> GetTreeTuples() const; + /** Returns true if there are any tapscripts */ + bool HasScripts() const { return !m_branch.empty(); } }; /** Given a TaprootSpendData and the output key, reconstruct its script tree.