46 bool mutation =
false;
47 while (hashes.size() > 1) {
49 for (
size_t pos = 0; pos + 1 < hashes.size(); pos += 2) {
50 if (hashes[pos] == hashes[pos + 1]) mutation =
true;
53 if (hashes.size() & 1) {
54 hashes.push_back(hashes.back());
56 SHA256D64(hashes[0].begin(), hashes[0].begin(), hashes.size() / 2);
57 hashes.resize(hashes.size() / 2);
59 if (mutated) *mutated = mutation;
60 if (hashes.size() == 0)
return uint256();
67 std::vector<uint256> leaves;
68 leaves.resize(block.
vtx.size());
69 for (
size_t s = 0; s < block.
vtx.size(); s++) {
70 leaves[s] = block.
vtx[s]->GetHash();
77 std::vector<uint256> leaves;
78 leaves.resize(block.
vtx.size());
80 for (
size_t s = 1; s < block.
vtx.size(); s++) {
81 leaves[s] = block.
vtx[s]->GetWitnessHash();
std::vector< CTransactionRef > vtx
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
uint256 BlockWitnessMerkleRoot(const CBlock &block, bool *mutated)
void SHA256D64(unsigned char *out, const unsigned char *in, size_t blocks)
Compute multiple double-SHA256's of 64-byte blobs.