Skip to content

Commit eae8bcf

Browse files
committed
fix isMultisigOutput
1 parent 85a399d commit eae8bcf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/script.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,10 @@ function isMultisigOutput (script) {
225225
if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG) return false
226226

227227
var mOp = chunks[0]
228-
if (mOp === OPS.OP_0) return false
229228
if (mOp < OPS.OP_1) return false
230229
if (mOp > OPS.OP_16) return false
231230

232231
var nOp = chunks[chunks.length - 2]
233-
if (nOp === OPS.OP_0) return false
234232
if (nOp < OPS.OP_1) return false
235233
if (nOp > OPS.OP_16) return false
236234

@@ -239,7 +237,7 @@ function isMultisigOutput (script) {
239237
if (n < m) return false
240238

241239
var pubKeys = chunks.slice(1, -2)
242-
if (n < pubKeys.length) return false
240+
if (n !== pubKeys.length) return false
243241

244242
return pubKeys.every(isCanonicalPubKey)
245243
}

test/fixtures/script.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@
241241
"description": "n < len(pubKeys)",
242242
"scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG"
243243
},
244+
{
245+
"description": "n > len(pubKeys)",
246+
"scriptPubKey": "OP_1 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG"
247+
},
244248
{
245249
"description": "non-canonical pubKey (bad length)",
246250
"scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ffff OP_1 OP_CHECKMULTISIG"

0 commit comments

Comments
 (0)