MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetBlockScriptFlags

Function GetBlockScriptFlags

src/validation.cpp:1787–1836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785}
1786
1787static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) {
1788 AssertLockHeld(cs_main);
1789
1790 unsigned int flags = SCRIPT_VERIFY_NONE;
1791
1792 // BIP16 didn't become active until Apr 1 2012 (on mainnet, and
1793 // retroactively applied to testnet)
1794 // However, only one historical block violated the P2SH rules (on both
1795 // mainnet and testnet), so for simplicity, always leave P2SH
1796 // on except for the one violating block.
1797 if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain
1798 pindex->phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity()
1799 *pindex->phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception
1800 {
1801 flags |= SCRIPT_VERIFY_P2SH;
1802 }
1803
1804 // Enforce WITNESS rules whenever P2SH is in effect (and the segwit
1805 // deployment is defined).
1806 if (flags & SCRIPT_VERIFY_P2SH && IsScriptWitnessEnabled(consensusparams)) {
1807 flags |= SCRIPT_VERIFY_WITNESS;
1808 }
1809
1810 // Start enforcing the DERSIG (BIP66) rule
1811 if (pindex->nHeight >= consensusparams.BIP66Height) {
1812 flags |= SCRIPT_VERIFY_DERSIG;
1813 }
1814
1815 // Start enforcing CHECKLOCKTIMEVERIFY (BIP65) rule
1816 if (pindex->nHeight >= consensusparams.BIP65Height) {
1817 flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
1818 }
1819
1820 // Start enforcing BIP68 (sequence locks) and BIP112 (CHECKSEQUENCEVERIFY) using versionbits logic.
1821 if (VersionBitsState(pindex->pprev, consensusparams, Consensus::DEPLOYMENT_CSV, versionbitscache) == ThresholdState::ACTIVE) {
1822 flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
1823 }
1824
1825 if (IsNullDummyEnabled(pindex->pprev, consensusparams)) {
1826 flags |= SCRIPT_VERIFY_NULLDUMMY;
1827 }
1828
1829 if (IsBTGHardForkEnabled(pindex->pprev, consensusparams)) {
1830 flags |= SCRIPT_VERIFY_STRICTENC;
1831 } else {
1832 flags |= SCRIPT_FORKID_DISABLED;
1833 }
1834
1835 return flags;
1836}
1837
1838
1839

Callers 2

AcceptToMemoryPoolWorkerFunction · 0.85
ConnectBlockMethod · 0.85

Calls 5

IsScriptWitnessEnabledFunction · 0.85
VersionBitsStateFunction · 0.85
IsNullDummyEnabledFunction · 0.85
IsBTGHardForkEnabledFunction · 0.85
IsNullMethod · 0.45

Tested by

no test coverage detected