Dash Core  0.12.2.1
P2P Digital Currency
merkle.h
Go to the documentation of this file.
1 // Copyright (c) 2015 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_MERKLE
6 #define BITCOIN_MERKLE
7 
8 #include <stdint.h>
9 #include <vector>
10 
11 #include "primitives/transaction.h"
12 #include "primitives/block.h"
13 #include "uint256.h"
14 
15 uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = NULL);
16 std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
17 uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);
18 
19 /*
20  * Compute the Merkle root of the transactions in a block.
21  * *mutated is set to true if a duplicated subtree was found.
22  */
23 uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = NULL);
24 
25 /*
26  * Compute the Merkle branch for the tree of transactions in a block, for a
27  * given position.
28  * This can be verified using ComputeMerkleRootFromBranch.
29  */
30 std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position);
31 
32 #endif
uint256 ComputeMerkleRoot(const std::vector< uint256 > &leaves, bool *mutated=NULL)
Definition: merkle.cpp:129
std::vector< uint256 > ComputeMerkleBranch(const std::vector< uint256 > &leaves, uint32_t position)
Definition: merkle.cpp:135
uint256 ComputeMerkleRootFromBranch(const uint256 &leaf, const std::vector< uint256 > &branch, uint32_t position)
Definition: merkle.cpp:141
Definition: block.h:73
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated=NULL)
Definition: merkle.cpp:154
std::vector< uint256 > BlockMerkleBranch(const CBlock &block, uint32_t position)
Definition: merkle.cpp:164