2017-11-09 19:34:51 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2015 The Bitcoin Core developers
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2015-11-17 17:35:40 +01:00
|
|
|
|
2018-01-16 10:47:52 +00:00
|
|
|
#ifndef FLOWEE_MERKLE
|
|
|
|
|
#define FLOWEE_MERKLE
|
2015-11-17 17:35:40 +01:00
|
|
|
|
2017-08-17 20:53:23 -06:00
|
|
|
#include <cstdint>
|
2015-11-17 17:35:40 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
2021-11-02 10:08:27 +01:00
|
|
|
#include "primitives/MutableBlock.h"
|
2026-04-14 23:43:29 +02:00
|
|
|
#include "primitives/Block.h"
|
2015-11-17 17:35:40 +01:00
|
|
|
#include "uint256.h"
|
|
|
|
|
|
2018-08-11 12:07:28 +03:00
|
|
|
uint256 ComputeMerkleRoot(std::vector<uint256> hashes, bool* mutated);
|
2015-11-17 17:35:40 +01:00
|
|
|
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
|
|
|
|
|
uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);
|
|
|
|
|
|
2015-11-17 17:35:44 +01:00
|
|
|
/*
|
|
|
|
|
* Compute the Merkle root of the transactions in a block.
|
|
|
|
|
* *mutated is set to true if a duplicated subtree was found.
|
|
|
|
|
*/
|
2026-04-14 23:43:29 +02:00
|
|
|
uint256 BlockMerkleRoot(const MutableBlock& block, bool* mutated = nullptr);
|
|
|
|
|
uint256 BlockMerkleRoot(const Block &block, bool* mutated = nullptr);
|
2015-11-17 17:35:44 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Compute the Merkle branch for the tree of transactions in a block, for a
|
|
|
|
|
* given position.
|
|
|
|
|
* This can be verified using ComputeMerkleRootFromBranch.
|
|
|
|
|
*/
|
2021-11-02 09:36:09 +01:00
|
|
|
std::vector<uint256> BlockMerkleBranch(const MutableBlock& block, uint32_t position);
|
2015-11-17 17:35:44 +01:00
|
|
|
|
2015-11-17 17:35:40 +01:00
|
|
|
#endif
|