BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -22,6 +22,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.
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user