diff --git a/src/script.js b/src/script.js index 8a28f1032..3952b2c1a 100644 --- a/src/script.js +++ b/src/script.js @@ -304,6 +304,9 @@ Script.createP2SHScriptPubKey = function(hash) { // m [pubKeys ...] n OP_CHECKMULTISIG Script.createMultisigScriptPubKey = function(m, pubKeys) { + assert(pubKeys instanceof Array, 'pubKeys not instance of an array') + assert(pubKeys.length >= m, 'Not enough pubKeys provided') + var script = new Script() var n = pubKeys.length diff --git a/test/script.js b/test/script.js index 41efcbd7c..1e60eb1c3 100644 --- a/test/script.js +++ b/test/script.js @@ -120,6 +120,10 @@ describe('Script', function() { assert.equal(multisigAddress.toString(), '32vYjxBb7pHJJyXgNk8UoK3BdRDxBzny2v') }) + + it('should throw on not enough pubKeys provided', function() { + assert.throws(function() {Script.createMultisigScriptPubKey(4, pubKeys)}, 'Not enough pubKeys provided') + }) }) describe('2-of-2 Multisig scriptSig', function() {