MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSpendData

Method GetSpendData

src/script/standard.cpp:498–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496WitnessV1Taproot TaprootBuilder::GetOutput() { return WitnessV1Taproot{m_output_key}; }
497
498TaprootSpendData TaprootBuilder::GetSpendData() const
499{
500 assert(IsComplete());
501 TaprootSpendData spd;
502 spd.merkle_root = m_branch.size() == 0 ? uint256() : m_branch[0]->hash;
503 spd.internal_key = m_internal_key;
504 if (m_branch.size()) {
505 // If any script paths exist, they have been combined into the root m_branch[0]
506 // by now. Compute the control block for each of its tracked leaves, and put them in
507 // spd.scripts.
508 for (const auto& leaf : m_branch[0]->leaves) {
509 std::vector<unsigned char> control_block;
510 control_block.resize(TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * leaf.merkle_branch.size());
511 control_block[0] = leaf.leaf_version | (m_parity ? 1 : 0);
512 std::copy(m_internal_key.begin(), m_internal_key.end(), control_block.begin() + 1);
513 if (leaf.merkle_branch.size()) {
514 std::copy(leaf.merkle_branch[0].begin(),
515 leaf.merkle_branch[0].begin() + TAPROOT_CONTROL_NODE_SIZE * leaf.merkle_branch.size(),
516 control_block.begin() + TAPROOT_CONTROL_BASE_SIZE);
517 }
518 spd.scripts[{leaf.script, leaf.leaf_version}].insert(std::move(control_block));
519 }
520 }
521 return spd;
522}
523
524std::optional<std::vector<std::tuple<int, CScript, int>>> InferTaprootTree(const TaprootSpendData& spenddata, const XOnlyPubKey& output)
525{

Callers 2

MakeScriptsMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 6

uint256Class · 0.70
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64