MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckTxScriptsSanity

Function CheckTxScriptsSanity

src/core_io.cpp:134–152  ·  view source on GitHub ↗

Check that all of the input and output scripts of a transaction contain valid opcodes

Source from the content-addressed store, hash-verified

132
133/// Check that all of the input and output scripts of a transaction contain valid opcodes
134static bool CheckTxScriptsSanity(const CMutableTransaction& tx)
135{
136 // Check input scripts for non-coinbase txs
137 if (!CTransaction(tx).IsCoinBase()) {
138 for (unsigned int i = 0; i < tx.vin.size(); i++) {
139 if (!tx.vin[i].scriptSig.HasValidOps() || tx.vin[i].scriptSig.size() > MAX_SCRIPT_SIZE) {
140 return false;
141 }
142 }
143 }
144 // Check output scripts
145 for (unsigned int i = 0; i < tx.vout.size(); i++) {
146 if (!tx.vout[i].scriptPubKey.HasValidOps() || tx.vout[i].scriptPubKey.size() > MAX_SCRIPT_SIZE) {
147 return false;
148 }
149 }
150
151 return true;
152}
153
154static bool DecodeTx(CMutableTransaction& tx, const std::vector<unsigned char>& tx_data, bool try_no_witness, bool try_witness)
155{

Callers 1

DecodeTxFunction · 0.85

Calls 4

HasValidOpsMethod · 0.80
CTransactionClass · 0.70
IsCoinBaseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected