script: improve isCode.

This commit is contained in:
Christopher Jeffrey 2017-08-24 23:46:33 -07:00
parent 47eb484657
commit 7145d21c9c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1397,8 +1397,8 @@ Script.prototype.indexOf = function indexOf(data) {
};
/**
* Test a script to see if it is valid
* script code (no non-existent opcodes).
* Test a script to see if it is likely
* to be script code (no weird opcodes).
* @returns {Boolean}
*/
@ -1407,7 +1407,22 @@ Script.prototype.isCode = function isCode() {
if (op.value === -1)
return false;
if (op.value > opcodes.OP_NOP10)
if (op.isDisabled())
return false;
switch (op.value) {
case opcodes.OP_RESERVED:
case opcodes.OP_NOP:
case opcodes.OP_VER:
case opcodes.OP_VERIF:
case opcodes.OP_VERNOTIF:
case opcodes.OP_RESERVED1:
case opcodes.OP_RESERVED2:
case opcodes.OP_NOP1:
return false;
}
if (op.value > opcodes.OP_NOP3)
return false;
}