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

Method Combine

src/script/standard.cpp:370–390  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

368}
369
370/*static*/ TaprootBuilder::NodeInfo TaprootBuilder::Combine(NodeInfo&& a, NodeInfo&& b)
371{
372 NodeInfo ret;
373 /* Iterate over all tracked leaves in a, add b's hash to their Merkle branch, and move them to ret. */
374 for (auto& leaf : a.leaves) {
375 leaf.merkle_branch.push_back(b.hash);
376 ret.leaves.emplace_back(std::move(leaf));
377 }
378 /* Iterate over all tracked leaves in b, add a's hash to their Merkle branch, and move them to ret. */
379 for (auto& leaf : b.leaves) {
380 leaf.merkle_branch.push_back(a.hash);
381 ret.leaves.emplace_back(std::move(leaf));
382 }
383 /* Lexicographically sort a and b's hash, and compute parent hash. */
384 if (a.hash < b.hash) {
385 ret.hash = (CHashWriter(HASHER_TAPBRANCH_ELEMENTS) << a.hash << b.hash).GetSHA256();
386 } else {
387 ret.hash = (CHashWriter(HASHER_TAPBRANCH_ELEMENTS) << b.hash << a.hash).GetSHA256();
388 }
389 return ret;
390}
391
392void TaprootSpendData::Merge(TaprootSpendData other)
393{

Callers

nothing calls this directly

Calls 4

CHashWriterClass · 0.85
emplace_backMethod · 0.80
GetSHA256Method · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected