Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per http://nodejs.org/api/assert.html#assert_assert_throws_block_error_message, error can be constructor, RegExp or validation function.
Please use RegExp: /Not enough pubKeys provided/.

edit: Also please add indentation

})
})

describe('2-of-2 Multisig scriptSig', function() {
Expand Down