Bitcoin Core 31.99.0
P2P Digital Currency
Functions
merkle.cpp File Reference
#include <consensus/merkle.h>
#include <crypto/sha256.h>
#include <hash.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <util/check.h>
#include <cstddef>
#include <memory>
#include <utility>
Include dependency graph for merkle.cpp:

Go to the source code of this file.

Functions

uint256 ComputeMerkleRoot (std::vector< uint256 > hashes, bool *mutated)
 Compute a Merkle root from the provided leaf hashes. More...
 
uint256 BlockMerkleRoot (const CBlock &block, bool *mutated)
 
uint256 BlockWitnessMerkleRoot (const CBlock &block)
 
static void MerkleComputation (const std::vector< uint256 > &leaves, uint32_t leaf_pos, std::vector< uint256 > &path)
 
static std::vector< uint256ComputeMerklePath (const std::vector< uint256 > &leaves, uint32_t position)
 
std::vector< uint256TransactionMerklePath (const CBlock &block, uint32_t position)
 Compute merkle path to the specified transaction. More...
 

Function Documentation

◆ BlockMerkleRoot()

uint256 BlockMerkleRoot ( const CBlock block,
bool *  mutated 
)

Definition at line 77 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BlockWitnessMerkleRoot()

uint256 BlockWitnessMerkleRoot ( const CBlock block)

Definition at line 87 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeMerklePath()

static std::vector< uint256 > ComputeMerklePath ( const std::vector< uint256 > &  leaves,
uint32_t  position 
)
static

Definition at line 177 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeMerkleRoot()

uint256 ComputeMerkleRoot ( std::vector< uint256 hashes,
bool *  mutated = nullptr 
)

Compute a Merkle root from the provided leaf hashes.

If non-null, *mutated is set to true if two identical hashes are paired at any tree level before the odd-count hash duplication step, and false otherwise.

Definition at line 52 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MerkleComputation()

static void MerkleComputation ( const std::vector< uint256 > &  leaves,
uint32_t  leaf_pos,
std::vector< uint256 > &  path 
)
static

Definition at line 99 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransactionMerklePath()

std::vector< uint256 > TransactionMerklePath ( const CBlock block,
uint32_t  position 
)

Compute merkle path to the specified transaction.

Parameters
[in]blockthe block
[in]positiontransaction for which to calculate the merkle path (0 is the coinbase)
Returns
merkle path ordered from the deepest

Definition at line 183 of file merkle.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: