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:
Andrew Chow
2017-05-30 15:42:10 -07:00
parent 9fec4da0be
commit 5b75c47784
3 changed files with 29 additions and 0 deletions

View File

@@ -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;
}