static*/
| 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 | |
| 392 | void TaprootSpendData::Merge(TaprootSpendData other) |
| 393 | { |
nothing calls this directly
no test coverage detected