Use P2SH consensus rules for all blocks

This commit moves P2SH activation back to the genesis block, with
a hardcoded exception for the one historical block in the chain that
violated this rule.
This commit is contained in:
Suhas Daftuar
2017-09-12 11:38:20 -04:00
committed by Suhas Daftuar
parent 94deb09349
commit ce650182f4
3 changed files with 14 additions and 7 deletions

View File

@@ -1730,8 +1730,15 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
unsigned int flags = SCRIPT_VERIFY_NONE;
// Start enforcing P2SH (BIP16)
if (pindex->nHeight >= consensusparams.BIP16Height) {
// BIP16 didn't become active until Apr 1 2012 (on mainnet, and
// retroactively applied to testnet)
// However, only one historical block violated the P2SH rules (on both
// mainnet and testnet), so for simplicity, always leave P2SH
// on except for the one violating block.
if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain
pindex->phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity()
*pindex->phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception
{
flags |= SCRIPT_VERIFY_P2SH;
}