diff --git a/lib/script/script.js b/lib/script/script.js index a80b2d64..fd3d2e6f 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -1385,10 +1385,10 @@ Script.num = function num(value, flags, size) { * account negative zero, minimaldata, etc. * @example * assert.deepEqual(Script.array(0), new Buffer(0)); - * assert.deepEqual(Script.array(0xffee), new Buffer([0xee, 0xff, 0x00])); - * assert.deepEqual(Script.array(new bn(0xffee)), new Buffer([0xee, 0xff, 0x00])); - * assert.deepEqual(Script.array(new bn(0x1e).ineg()), new Buffer([0x9e])); - * @param {Buffer|Number|BN} value + * assert.deepEqual(Script.array(0xffee), new Buffer('eeff00', 'hex')); + * assert.deepEqual(Script.array(new bn(0xffee)), new Buffer('eeff00', 'hex')); + * assert.deepEqual(Script.array(new bn(0x1e).ineg()), new Buffer('9e', 'hex')); + * @param {Number|BN} value * @returns {Buffer} */ @@ -1889,26 +1889,25 @@ Script.prototype.isStandard = function isStandard() { var type = this.getType(); var m, n; - if (type === scriptTypes.MULTISIG) { - m = Script.getSmall(this.raw[0]); - n = Script.getSmall(this.raw[this.raw.length - 2]); + switch (type) { + case scriptTypes.MULTISIG: + m = this.getSmall(0); + n = this.getSmall(this.code.length - 2); - if (n < 1 || n > 3) - return false; + if (n < 1 || n > 3) + return false; - if (m < 1 || m > n) - return false; + if (m < 1 || m > n) + return false; - return true; + return true; + case scriptTypes.NULLDATA: + if (this.raw.length > constants.script.MAX_OP_RETURN_BYTES) + return false; + return true; + default: + return type !== scriptTypes.NONSTANDARD; } - - if (type === scriptTypes.NULLDATA) { - if (this.raw.length > constants.script.MAX_OP_RETURN_BYTES) - return false; - return true; - } - - return type !== scriptTypes.NONSTANDARD; }; /**