From fdc9bca468758f5f4f4fc02ca8fc2702a012496f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 3 Jul 2017 02:34:56 -0700 Subject: [PATCH] script: minor. --- lib/script/script.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/script/script.js b/lib/script/script.js index 03b98d5e..6d960970 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -1867,6 +1867,7 @@ Script.prototype.isPubkey = function isPubkey(minimal) { } return this.code.length === 2 + && this.code[0].data && common.isKey(this.code[0].data) && this.code[1].value === opcodes.OP_CHECKSIG; }; @@ -1929,10 +1930,8 @@ Script.prototype.isMultisig = function isMultisig(minimal) { if (!common.isKey(op.data)) return false; - if (minimal) { - if (!op.isMinimal()) - return false; - } + if (minimal && !op.isMinimal()) + return false; } return true; @@ -2182,7 +2181,9 @@ Script.prototype.isPubkeyInput = function isPubkeyInput() { if (this.raw[0] > opcodes.OP_PUSHDATA4) return false; - return this.code.length === 1 && common.isSignature(this.code[0].data); + return this.code.length === 1 + && this.code[1].data + && common.isSignature(this.code[0].data); }; /** @@ -2202,7 +2203,9 @@ Script.prototype.isPubkeyhashInput = function isPubkeyhashInput() { return false; return this.code.length === 2 + && this.code[0].data && common.isSignature(this.code[0].data) + && this.code[1].data && common.isKey(this.code[1].data); }; @@ -2231,7 +2234,12 @@ Script.prototype.isMultisigInput = function isMultisigInput() { return false; for (let i = 1; i < this.code.length; i++) { - if (!common.isSignature(this.code[i].data)) + let op = this.code[i]; + + if (!op.data) + return false; + + if (!common.isSignature(op.data)) return false; }