diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-07-19 16:02:36 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2022-06-27 16:47:48 -0400 |
commit | ac7747585fb0629be502a089c9c9be876bd7107d (patch) | |
tree | 3ae648c00c5ba86f3e69690abc915aac04e24250 /src/psbt.cpp | |
parent | 25b6ae46e7249a1b363ef4fb12375f368903c58e (diff) | |
download | bitcoin-ac7747585fb0629be502a089c9c9be876bd7107d.tar.xz |
Fill PSBT Taproot output data to/from SignatureData
Diffstat (limited to 'src/psbt.cpp')
-rw-r--r-- | src/psbt.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp index ba32d7acae..e4bac4aa63 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -213,6 +213,15 @@ void PSBTOutput::FillSignatureData(SignatureData& sigdata) const for (const auto& key_pair : hd_keypaths) { sigdata.misc_pubkeys.emplace(key_pair.first.GetID(), key_pair); } + if (m_tap_tree.has_value() && m_tap_internal_key.IsFullyValid()) { + TaprootSpendData spenddata = m_tap_tree->GetSpendData(); + + sigdata.tr_spenddata.internal_key = m_tap_internal_key; + sigdata.tr_spenddata.Merge(spenddata); + } + for (const auto& [pubkey, leaf_origin] : m_tap_bip32_paths) { + sigdata.taproot_misc_pubkeys.emplace(pubkey, leaf_origin); + } } void PSBTOutput::FromSignatureData(const SignatureData& sigdata) @@ -226,6 +235,15 @@ void PSBTOutput::FromSignatureData(const SignatureData& sigdata) for (const auto& entry : sigdata.misc_pubkeys) { hd_keypaths.emplace(entry.second); } + if (!sigdata.tr_spenddata.internal_key.IsNull()) { + m_tap_internal_key = sigdata.tr_spenddata.internal_key; + } + if (sigdata.tr_builder.has_value()) { + m_tap_tree = sigdata.tr_builder; + } + for (const auto& [pubkey, leaf_origin] : sigdata.taproot_misc_pubkeys) { + m_tap_bip32_paths.emplace(pubkey, leaf_origin); + } } bool PSBTOutput::IsNull() const |