diff options
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/merkle.cpp | 11 | ||||
-rw-r--r-- | src/consensus/merkle.h | 6 | ||||
-rw-r--r-- | src/consensus/params.h | 1 | ||||
-rw-r--r-- | src/consensus/validation.h | 3 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/consensus/merkle.cpp b/src/consensus/merkle.cpp index 22eb7159a2..35f7d2e05a 100644 --- a/src/consensus/merkle.cpp +++ b/src/consensus/merkle.cpp @@ -165,6 +165,17 @@ uint256 BlockMerkleRoot(const CBlock& block, bool* mutated) return ComputeMerkleRoot(leaves, mutated); } +uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated) +{ + std::vector<uint256> leaves; + leaves.resize(block.vtx.size()); + leaves[0].SetNull(); // The witness hash of the coinbase is 0. + for (size_t s = 1; s < block.vtx.size(); s++) { + leaves[s] = block.vtx[s].GetWitnessHash(); + } + return ComputeMerkleRoot(leaves, mutated); +} + std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position) { std::vector<uint256> leaves; diff --git a/src/consensus/merkle.h b/src/consensus/merkle.h index 6ef59745ac..194aea9b75 100644 --- a/src/consensus/merkle.h +++ b/src/consensus/merkle.h @@ -23,6 +23,12 @@ uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint2 uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = NULL); /* + * Compute the Merkle root of the witness transactions in a block. + * *mutated is set to true if a duplicated subtree was found. + */ +uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = NULL); + +/* * Compute the Merkle branch for the tree of transactions in a block, for a * given position. * This can be verified using ComputeMerkleRootFromBranch. diff --git a/src/consensus/params.h b/src/consensus/params.h index 6c4cc49479..822ec87d69 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -16,6 +16,7 @@ enum DeploymentPos { DEPLOYMENT_TESTDUMMY, DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113. + DEPLOYMENT_SEGWIT, // Deployment of BIP141 and BIP143 // NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp MAX_VERSION_BITS_DEPLOYMENTS }; diff --git a/src/consensus/validation.h b/src/consensus/validation.h index d7e57f5b5e..000b197270 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -77,6 +77,9 @@ public: bool CorruptionPossible() const { return corruptionPossible; } + void SetCorruptionPossible() { + corruptionPossible = true; + } unsigned int GetRejectCode() const { return chRejectCode; } std::string GetRejectReason() const { return strRejectReason; } std::string GetDebugMessage() const { return strDebugMessage; } |