Skip to content

Commit 30ff25c

Browse files
committed
psbt: Only include m_tap_tree if it has scripts
1 parent 0577d42 commit 30ff25c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/psbt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void PSBTOutput::FromSignatureData(const SignatureData& sigdata)
249249
if (!sigdata.tr_spenddata.internal_key.IsNull()) {
250250
m_tap_internal_key = sigdata.tr_spenddata.internal_key;
251251
}
252-
if (sigdata.tr_builder.has_value()) {
252+
if (sigdata.tr_builder.has_value() && sigdata.tr_builder->HasScripts()) {
253253
m_tap_tree = sigdata.tr_builder->GetTreeTuples();
254254
}
255255
for (const auto& [pubkey, leaf_origin] : sigdata.taproot_misc_pubkeys) {

src/script/standard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ class TaprootBuilder
315315
TaprootSpendData GetSpendData() const;
316316
/** Returns a vector of tuples representing the depth, leaf version, and script */
317317
std::vector<std::tuple<uint8_t, uint8_t, CScript>> GetTreeTuples() const;
318+
/** Returns true if there are any tapscripts */
319+
bool HasScripts() const { return !m_branch.empty(); }
318320
};
319321

320322
/** Given a TaprootSpendData and the output key, reconstruct its script tree.

0 commit comments

Comments
 (0)