From a018a23b6b70d6bd543fcc7d4999c83296358d8f Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 30 Apr 2015 03:24:15 -0300 Subject: [PATCH] fix bug in recognizing p2sh input scripts --- lib/script/script.js | 2 +- test/script/script.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/script/script.js b/lib/script/script.js index 3f8f769..691c6f7 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -296,7 +296,7 @@ Script.prototype.isScriptHashOut = function() { * Note that these are frequently indistinguishable from pubkeyhashin */ Script.prototype.isScriptHashIn = function() { - if (this.chunks.length === 0) { + if (this.chunks.length <= 1) { return false; } var redeemChunk = this.chunks[this.chunks.length - 1]; diff --git a/test/script/script.js b/test/script/script.js index 0a0cb6d..14cf12c 100644 --- a/test/script/script.js +++ b/test/script/script.js @@ -322,6 +322,10 @@ describe('Script', function() { s.isScriptHashIn().should.equal(false); s2.isScriptHashIn().should.equal(false); }); + it('identifies this other problematic non-p2sh in', function() { + var s = Script.fromString('73 0x3046022100dc7a0a812de14acc479d98ae209402cc9b5e0692bc74b9fe0a2f083e2f9964b002210087caf04a711bebe5339fd7554c4f7940dc37be216a3ae082424a5e164faf549401'); + s.isScriptHashIn().should.equal(false); + }); }); describe('#isScripthashOut', function() {