Merge 5bf65ec66e into merged_master (Bitcoin PR bitcoin/bitcoin#22558)

This commit is contained in:
Byron Hambly 2024-09-19 13:24:19 +02:00
commit 2d07ef8fc1
No known key found for this signature in database
GPG key ID: DE8F6EA20A661697
17 changed files with 710 additions and 31 deletions

View file

@ -519,6 +519,7 @@ WitnessV1Taproot TaprootBuilder::GetOutput() { return WitnessV1Taproot{m_output_
TaprootSpendData TaprootBuilder::GetSpendData() const
{
assert(IsComplete());
assert(m_output_key.IsFullyValid());
TaprootSpendData spd;
spd.merkle_root = m_branch.size() == 0 ? uint256() : m_branch[0]->hash;
spd.internal_key = m_internal_key;
@ -676,3 +677,19 @@ std::optional<std::vector<std::tuple<int, CScript, int>>> InferTaprootTree(const
return ret;
}
std::vector<std::tuple<uint8_t, uint8_t, CScript>> TaprootBuilder::GetTreeTuples() const
{
assert(IsComplete());
std::vector<std::tuple<uint8_t, uint8_t, CScript>> tuples;
if (m_branch.size()) {
const auto& leaves = m_branch[0]->leaves;
for (const auto& leaf : leaves) {
assert(leaf.merkle_branch.size() <= TAPROOT_CONTROL_MAX_NODE_COUNT);
uint8_t depth = (uint8_t)leaf.merkle_branch.size();
uint8_t leaf_ver = (uint8_t)leaf.leaf_version;
tuples.push_back(std::make_tuple(depth, leaf_ver, leaf.script));
}
}
return tuples;
}