Raven Core  3.0.0
P2P Digital Currency
merkle.h
Go to the documentation of this file.
1 // Copyright (c) 2015 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_MERKLE
7 #define RAVEN_MERKLE
8 
9 #include <stdint.h>
10 #include <vector>
11 
12 #include "primitives/transaction.h"
13 #include "primitives/block.h"
14 #include "uint256.h"
15 
16 uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = nullptr);
17 std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
18 uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);
19 
20 /*
21  * Compute the Merkle root of the transactions in a block.
22  * *mutated is set to true if a duplicated subtree was found.
23  */
24 uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = nullptr);
25 
26 /*
27  * Compute the Merkle root of the witness transactions in a block.
28  * *mutated is set to true if a duplicated subtree was found.
29  */
30 uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = nullptr);
31 
32 /*
33  * Compute the Merkle branch for the tree of transactions in a block, for a
34  * given position.
35  * This can be verified using ComputeMerkleRootFromBranch.
36  */
37 std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position);
38 
39 #endif
uint256 ComputeMerkleRoot(const std::vector< uint256 > &leaves, bool *mutated=nullptr)
Definition: merkle.cpp:134
Definition: block.h:73
std::vector< uint256 > ComputeMerkleBranch(const std::vector< uint256 > &leaves, uint32_t position)
Definition: merkle.cpp:140
uint256 BlockWitnessMerkleRoot(const CBlock &block, bool *mutated=nullptr)
Definition: merkle.cpp:169
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated=nullptr)
Definition: merkle.cpp:159
256-bit opaque blob.
Definition: uint256.h:123
uint256 ComputeMerkleRootFromBranch(const uint256 &leaf, const std::vector< uint256 > &branch, uint32_t position)
Definition: merkle.cpp:146
std::vector< uint256 > BlockMerkleBranch(const CBlock &block, uint32_t position)
Definition: merkle.cpp:180