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

Function CheckTxScriptsSanity

src/core_read.cpp:108–126  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

106
107// Check that all of the input and output scripts of a transaction contains valid opcodes
108static bool CheckTxScriptsSanity(const CMutableTransaction& tx)
109{
110 // Check input scripts for non-coinbase txs
111 if (!CTransaction(tx).IsCoinBase()) {
112 for (unsigned int i = 0; i < tx.vin.size(); i++) {
113 if (!tx.vin[i].scriptSig.HasValidOps() || tx.vin[i].scriptSig.size() > MAX_SCRIPT_SIZE) {
114 return false;
115 }
116 }
117 }
118 // Check output scripts
119 for (unsigned int i = 0; i < tx.vout.size(); i++) {
120 if (!tx.vout[i].scriptPubKey.HasValidOps() || tx.vout[i].scriptPubKey.size() > MAX_SCRIPT_SIZE) {
121 return false;
122 }
123 }
124
125 return true;
126}
127
128static bool DecodeTx(CMutableTransaction& tx, const std::vector<unsigned char>& tx_data, bool try_no_witness, bool try_witness)
129{

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