MCPcopy Create free account
hub / github.com/ElementsProject/elements / ConsensusScriptChecks

Method ConsensusScriptChecks

src/validation.cpp:1094–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1092}
1093
1094bool MemPoolAccept::ConsensusScriptChecks(const ATMPArgs& args, Workspace& ws)
1095{
1096 AssertLockHeld(cs_main);
1097 AssertLockHeld(m_pool.cs);
1098 const CTransaction& tx = *ws.m_ptx;
1099 const uint256& hash = ws.m_hash;
1100 TxValidationState& state = ws.m_state;
1101 const CChainParams& chainparams = args.m_chainparams;
1102
1103 // Check again against the current block tip's script verification
1104 // flags to cache our script execution flags. This is, of course,
1105 // useless if the next block has different script flags from the
1106 // previous one, but because the cache tracks script flags for us it
1107 // will auto-invalidate and we'll just have a few blocks of extra
1108 // misses on soft-fork activation.
1109 //
1110 // This is also useful in case of bugs in the standard flags that cause
1111 // transactions to pass as valid when they're actually invalid. For
1112 // instance the STRICTENC flag was incorrectly allowing certain
1113 // CHECKSIG NOT scripts to pass, even though they were invalid.
1114 //
1115 // There is a similar check in CreateNewBlock() to prevent creating
1116 // invalid blocks (using TestBlockValidity), however allowing such
1117 // transactions into the mempool can be exploited as a DoS attack.
1118 unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(m_active_chainstate.m_chain.Tip(), chainparams.GetConsensus());
1119 if (!CheckInputsFromMempoolAndCache(tx, state, m_view, m_pool, currentBlockScriptVerifyFlags,
1120 ws.m_precomputed_txdata, m_active_chainstate.CoinsTip())) {
1121 LogPrintf("BUG! PLEASE REPORT THIS! CheckInputScripts failed against latest-block but not STANDARD flags %s, %s\n", hash.ToString(), state.ToString());
1122 return Assume(false);
1123 }
1124
1125 return true;
1126}
1127
1128bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
1129{

Callers

nothing calls this directly

Calls 3

GetBlockScriptFlagsFunction · 0.85
TipMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected