Merge pull request #2938 from petertodd/op-reserved-weirdness

Document and test OP_RESERVED weirdness
This commit is contained in:
Gavin Andresen 2013-08-25 18:17:59 -07:00
commit b62dc051aa
5 changed files with 18 additions and 3 deletions

View file

@ -327,6 +327,8 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
return false;
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
return false;
// Note how OP_RESERVED does not count towards the opcode limit.
if (opcode > OP_16 && ++nOpCount > 201)
return false;

View file

@ -543,6 +543,10 @@ public:
opcodetype opcode;
if (!GetOp(pc, opcode))
return false;
// Note that IsPushOnly() *does* consider OP_RESERVED to be a
// push-type opcode, however execution of OP_RESERVED fails, so
// it's not relevant to P2SH as the scriptSig would fail prior to
// the P2SH special validation code being executed.
if (opcode > OP_16)
return false;
}

View file

@ -251,6 +251,7 @@
["1","VER", "OP_VER is reserved"],
["1","VERIF", "OP_VERIF is reserved"],
["1","VERNOTIF", "OP_VERNOTIF is reserved"],
["1","RESERVED", "OP_RESERVED is reserved"],
["1","RESERVED1", "OP_RESERVED1 is reserved"],
["1","RESERVED2", "OP_RESERVED2 is reserved"],
["1","0xba", "0xba == OP_NOP10 + 1"],

File diff suppressed because one or more lines are too long

View file

@ -32,8 +32,12 @@ ParseScript(string s)
if (mapOpNames.size() == 0)
{
for (int op = OP_NOP; op <= OP_NOP10; op++)
for (int op = 0; op <= OP_NOP10; op++)
{
// Allow OP_RESERVED to get into mapOpNames
if (op < OP_NOP && op != OP_RESERVED)
continue;
const char* name = GetOpName((opcodetype)op);
if (strcmp(name, "OP_UNKNOWN") == 0)
continue;
@ -72,7 +76,7 @@ ParseScript(string s)
}
else if (mapOpNames.count(w))
{
// opcode, e.g. OP_ADD or OP_1:
// opcode, e.g. OP_ADD or ADD:
result << mapOpNames[w];
}
else