Fabcoin Core  0.16.2
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 FABCOIN_MERKLE
6 #define FABCOIN_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 = nullptr);
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 = nullptr);
24 
25 /*
26  * Compute the Merkle root of the witness transactions in a block.
27  * *mutated is set to true if a duplicated subtree was found.
28  */
29 uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = nullptr);
30 
31 /*
32  * Compute the Merkle branch for the tree of transactions in a block, for a
33  * given position.
34  * This can be verified using ComputeMerkleRootFromBranch.
35  */
36 std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position);
37 
38 #endif
uint256 ComputeMerkleRoot(const std::vector< uint256 > &leaves, bool *mutated=nullptr)
Definition: merkle.cpp:133
Definition: block.h:155
std::vector< uint256 > ComputeMerkleBranch(const std::vector< uint256 > &leaves, uint32_t position)
Definition: merkle.cpp:139
uint256 BlockWitnessMerkleRoot(const CBlock &block, bool *mutated=nullptr)
Definition: merkle.cpp:168
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated=nullptr)
Definition: merkle.cpp:158
256-bit opaque blob.
Definition: uint256.h:132
uint256 ComputeMerkleRootFromBranch(const uint256 &leaf, const std::vector< uint256 > &branch, uint32_t position)
Definition: merkle.cpp:145
std::vector< uint256 > BlockMerkleBranch(const CBlock &block, uint32_t position)
Definition: merkle.cpp:179