public void ValidationTransactionScript(Chain newChain, BlockTx tx, TxInput txInput, int txInputIndex, PrevTxOutput prevTxOutput)
{
var chainedHeader = newChain.LastBlock;
// BIP16 didn't become active until Apr 1 2012
var nBIP16SwitchTime = DateTimeOffset.FromUnixTimeSeconds(1333238400U);
var strictPayToScriptHash = chainedHeader.Time >= nBIP16SwitchTime;
var flags = strictPayToScriptHash ? verify_flags_type.verify_flags_p2sh : verify_flags_type.verify_flags_none;
// Start enforcing the DERSIG (BIP66) rules, for block.nVersion=3 blocks,
// when 75% of the network has upgraded:
if (chainedHeader.Version >= 3 &&
IsSuperMajority(3, newChain, ChainParams.MajorityEnforceBlockUpgrade))
{
flags |= verify_flags_type.verify_flags_dersig;
}
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
// blocks, when 75% of the network has upgraded:
if (chainedHeader.Version >= 4 &&
IsSuperMajority(4, newChain, ChainParams.MajorityEnforceBlockUpgrade))
{
flags |= verify_flags_type.verify_flags_checklocktimeverify;
}
var result = LibbitcoinConsensus.VerifyScript(
tx.TxBytes,
prevTxOutput.ScriptPublicKey,
txInputIndex,
flags);
if (!result)
{
logger.Debug($"Script did not pass in block: {chainedHeader.Hash}, tx: {tx.Index}, {tx.Hash}, input: {txInputIndex}");
throw new ValidationException(chainedHeader.Hash);
}
}