mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
[Consensus] Bury segwit deployment
Hardcode segwit deployment height to 481824 for mainnet.
This commit is contained in:
parent
1c93b9b31c
commit
0328dcdcfc
15 changed files with 71 additions and 113 deletions
|
|
@ -1608,7 +1608,7 @@ static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_
|
|||
// environment. See test/functional/p2p-segwit.py.
|
||||
static bool IsScriptWitnessEnabled(const Consensus::Params& params)
|
||||
{
|
||||
return params.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0;
|
||||
return params.SegwitHeight != std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
||||
|
|
@ -1649,7 +1649,8 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
|||
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
|
||||
}
|
||||
|
||||
if (IsNullDummyEnabled(pindex->pprev, consensusparams)) {
|
||||
// Start enforcing BIP147 NULLDUMMY (activated simultaneously with segwit)
|
||||
if (IsWitnessEnabled(pindex->pprev, consensusparams)) {
|
||||
flags |= SCRIPT_VERIFY_NULLDUMMY;
|
||||
}
|
||||
|
||||
|
|
@ -3045,14 +3046,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
|
|||
|
||||
bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE);
|
||||
}
|
||||
|
||||
bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE);
|
||||
int height = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
|
||||
return (height >= params.SegwitHeight);
|
||||
}
|
||||
|
||||
// Compute at which vout of the block's coinbase transaction the witness
|
||||
|
|
@ -3087,7 +3082,7 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc
|
|||
std::vector<unsigned char> commitment;
|
||||
int commitpos = GetWitnessCommitmentIndex(block);
|
||||
std::vector<unsigned char> ret(32, 0x00);
|
||||
if (consensusParams.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0) {
|
||||
if (consensusParams.SegwitHeight != std::numeric_limits<int>::max()) {
|
||||
if (commitpos == -1) {
|
||||
uint256 witnessroot = BlockWitnessMerkleRoot(block, nullptr);
|
||||
CHash256().Write(witnessroot.begin(), 32).Write(ret.data(), 32).Finalize(witnessroot.begin());
|
||||
|
|
@ -3222,7 +3217,7 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
|
|||
// {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, witness reserved value). In case there are
|
||||
// multiple, the last one is used.
|
||||
bool fHaveWitness = false;
|
||||
if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE) {
|
||||
if (nHeight >= consensusParams.SegwitHeight) {
|
||||
int commitpos = GetWitnessCommitmentIndex(block);
|
||||
if (commitpos != -1) {
|
||||
bool malleated = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue