MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ComputeTaprootMerkleRoot

Function ComputeTaprootMerkleRoot

src/script/interpreter.cpp:1898–1911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1896}
1897
1898uint256 ComputeTaprootMerkleRoot(std::span<const unsigned char> control, const uint256& tapleaf_hash)
1899{
1900 assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE);
1901 assert(control.size() <= TAPROOT_CONTROL_MAX_SIZE);
1902 assert((control.size() - TAPROOT_CONTROL_BASE_SIZE) % TAPROOT_CONTROL_NODE_SIZE == 0);
1903
1904 const int path_len = (control.size() - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE;
1905 uint256 k = tapleaf_hash;
1906 for (int i = 0; i < path_len; ++i) {
1907 std::span node{std::span{control}.subspan(TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * i, TAPROOT_CONTROL_NODE_SIZE)};
1908 k = ComputeTapbranchHash(k, node);
1909 }
1910 return k;
1911}
1912
1913static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, const std::vector<unsigned char>& program, const uint256& tapleaf_hash)
1914{

Callers 2

InferTaprootTreeFunction · 0.85
VerifyTaprootCommitmentFunction · 0.85

Calls 2

ComputeTapbranchHashFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected