mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
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;
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user