diff options
author | Andrew Chow <github@achow101.com> | 2022-10-13 13:24:37 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-10-13 13:31:54 -0400 |
commit | 885366c67addd86bf06629919aaa6f74a76f44f4 (patch) | |
tree | 33a4783ec25bd9754bf28bcfb1fa737ca3d2d20f /src/psbt.cpp | |
parent | 3f385c912ea351ab90ba09f8793b499e91a36d74 (diff) | |
parent | e2e4c2969ba753a94587985582123a596f57067b (diff) |
Merge bitcoin/bitcoin#26133: [24.x] Backports for rc2
e2e4c2969ba753a94587985582123a596f57067b tests: Test that PSBT_OUT_TAP_TREE is included correctly (Andrew Chow)
4d42c3a2401c63084bf94433609240daa366753e psbt: Only include m_tap_tree if it has scripts (Andrew Chow)
d810fde8ea64b71567f8b50895ac76bcb7afbfbc psbt: Change m_tap_tree to store just the tuples (Andrew Chow)
a9419eff0cc21d21755165e66cc0e496aab65650 tests: Test that PSBT_OUT_TAP_TREE is combined correctly (Andrew Chow)
4abd2ab18e26999e2dafcb15a58a7979de90af34 psbt: Fix merging of m_tap_tree (Andrew Chow)
1390c96c8e9c56e0d8348ef056f18e3e04f0f63f [BugFix]: Do not allow deserializing PSBT with empty PSBT_OUT_TAP_TREE (Jeremy Rubin)
9b438f06ecfc3fb21d2c5219b71fb4aa77875b8c refactor: revert m_next_resend to not be std::atomic (stickies-v)
43ced0b436b05ed12489a99bbac89f3b4c9ac035 wallet: only update m_next_resend when actually resending (stickies-v)
fc8f2bfa3abc284ae3c1127fcf36535603ecc891 refactor: carve out tx resend timer logic into ShouldResend (stickies-v)
a6fb674f966df27c09dc3d2b81040ce2965b2d7e refactor: remove unused locks for ResubmitWalletTransactions (stickies-v)
5ad82a09b409d416236092062a4201e238dfd68b index: Improve BaseIndex::BlockUntilSyncedToCurrentChain reliability (Ryan Ofsky)
997faf6b6c774dc87ae730f2f08d7f4f08bdfd04 contrib: Fix capture_output in getcoins.py (willcl-ark)
7e0bcfbfef61cb688bc92a96003c1219cad67935 p2p: ProcessHeadersMessage(): fix received_new_header (Larry Ruane)
c97d924880eaad136c5f7776f05bf887657ccca7 Correct sanity-checking script_size calculation (Pieter Wuille)
da6fba6fe785ba2c54f9b88dd5b1b4ceb02c18c9 docs: Add 371 to bips.md (Andrew Chow)
Pull request description:
Will collect backports for rc2 as they become available. Currently:
* https://github.com/bitcoin/bitcoin/pull/25858
* https://github.com/bitcoin/bitcoin/pull/26124
* https://github.com/bitcoin/bitcoin/pull/26149
* https://github.com/bitcoin/bitcoin/pull/26172
* https://github.com/bitcoin/bitcoin/pull/26205
* https://github.com/bitcoin/bitcoin/pull/26212
* https://github.com/bitcoin/bitcoin/pull/26215
ACKs for top commit:
dergoegge:
ACK e2e4c2969ba753a94587985582123a596f57067b
achow101:
ACK e2e4c2969ba753a94587985582123a596f57067b
instagibbs:
ACK https://github.com/bitcoin/bitcoin/pull/26133/commits/e2e4c2969ba753a94587985582123a596f57067b
Tree-SHA512: b6374fe202561057dbe1430d4c40f06f721eb568f91e7275ae1ee7747edf780ce64620382d13ecc4b9571d931dc25d226af8284987cf35ff6a6182c5f64eb10c
Diffstat (limited to 'src/psbt.cpp')
-rw-r--r-- | src/psbt.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp index 36fec74bc9..cbf2f88788 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -218,8 +218,14 @@ 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(); + if (!m_tap_tree.empty() && m_tap_internal_key.IsFullyValid()) { + TaprootBuilder builder; + for (const auto& [depth, leaf_ver, script] : m_tap_tree) { + builder.Add((int)depth, script, (int)leaf_ver, /*track=*/true); + } + assert(builder.IsComplete()); + builder.Finalize(m_tap_internal_key); + TaprootSpendData spenddata = builder.GetSpendData(); sigdata.tr_spenddata.internal_key = m_tap_internal_key; sigdata.tr_spenddata.Merge(spenddata); @@ -243,8 +249,8 @@ 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()) { - m_tap_tree = sigdata.tr_builder; + 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) { m_tap_bip32_paths.emplace(pubkey, leaf_origin); @@ -265,7 +271,7 @@ void PSBTOutput::Merge(const PSBTOutput& output) if (redeem_script.empty() && !output.redeem_script.empty()) redeem_script = output.redeem_script; if (witness_script.empty() && !output.witness_script.empty()) witness_script = output.witness_script; if (m_tap_internal_key.IsNull() && !output.m_tap_internal_key.IsNull()) m_tap_internal_key = output.m_tap_internal_key; - if (m_tap_tree.has_value() && !output.m_tap_tree.has_value()) m_tap_tree = output.m_tap_tree; + if (m_tap_tree.empty() && !output.m_tap_tree.empty()) m_tap_tree = output.m_tap_tree; } bool PSBTInputSigned(const PSBTInput& input) { |