Document and test OP_RESERVED weirdness
Seems it was forgotten about when IsPushOnly() and the unittests were written. A particular oddity is that OP_RESERVED doesn't count towards the >201 opcode limit unlike every other named opcode.
This commit is contained in:
parent
e9e2ef5fbd
commit
214d45b6b9
@ -327,6 +327,8 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
|
|||||||
return false;
|
return false;
|
||||||
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Note how OP_RESERVED does not count towards the opcode limit.
|
||||||
if (opcode > OP_16 && ++nOpCount > 201)
|
if (opcode > OP_16 && ++nOpCount > 201)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -543,6 +543,10 @@ public:
|
|||||||
opcodetype opcode;
|
opcodetype opcode;
|
||||||
if (!GetOp(pc, opcode))
|
if (!GetOp(pc, opcode))
|
||||||
return false;
|
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)
|
if (opcode > OP_16)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,7 @@
|
|||||||
["1","VER", "OP_VER is reserved"],
|
["1","VER", "OP_VER is reserved"],
|
||||||
["1","VERIF", "OP_VERIF is reserved"],
|
["1","VERIF", "OP_VERIF is reserved"],
|
||||||
["1","VERNOTIF", "OP_VERNOTIF is reserved"],
|
["1","VERNOTIF", "OP_VERNOTIF is reserved"],
|
||||||
|
["1","RESERVED", "OP_RESERVED is reserved"],
|
||||||
["1","RESERVED1", "OP_RESERVED1 is reserved"],
|
["1","RESERVED1", "OP_RESERVED1 is reserved"],
|
||||||
["1","RESERVED2", "OP_RESERVED2 is reserved"],
|
["1","RESERVED2", "OP_RESERVED2 is reserved"],
|
||||||
["1","0xba", "0xba == OP_NOP10 + 1"],
|
["1","0xba", "0xba == OP_NOP10 + 1"],
|
||||||
|
File diff suppressed because one or more lines are too long
@ -32,8 +32,12 @@ ParseScript(string s)
|
|||||||
|
|
||||||
if (mapOpNames.size() == 0)
|
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);
|
const char* name = GetOpName((opcodetype)op);
|
||||||
if (strcmp(name, "OP_UNKNOWN") == 0)
|
if (strcmp(name, "OP_UNKNOWN") == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -72,7 +76,7 @@ ParseScript(string s)
|
|||||||
}
|
}
|
||||||
else if (mapOpNames.count(w))
|
else if (mapOpNames.count(w))
|
||||||
{
|
{
|
||||||
// opcode, e.g. OP_ADD or OP_1:
|
// opcode, e.g. OP_ADD or ADD:
|
||||||
result << mapOpNames[w];
|
result << mapOpNames[w];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user