mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Add a valid opcode sanity check to CScript
Added a function in CScript that checks if the script contains valid opcodes. Add a test for that function
This commit is contained in:
@@ -267,3 +267,15 @@ std::string CScriptWitness::ToString() const
|
||||
}
|
||||
return ret + ")";
|
||||
}
|
||||
|
||||
bool CScript::HasValidOps() const
|
||||
{
|
||||
CScript::const_iterator it = begin();
|
||||
while (it < end()) {
|
||||
opcodetype opcode;
|
||||
if (!GetOp(it, opcode) || opcode > 0xb9) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -630,6 +630,9 @@ public:
|
||||
bool IsPushOnly(const_iterator pc) const;
|
||||
bool IsPushOnly() const;
|
||||
|
||||
/** Check if the script contains valid OP_CODES */
|
||||
bool HasValidOps() const;
|
||||
|
||||
/**
|
||||
* Returns whether the script is guaranteed to fail at execution,
|
||||
* regardless of the initial stack. This allows outputs to be pruned
|
||||
|
||||
Reference in New Issue
Block a user