Merge pull request #198 from thallium205/master
ensure pubkeys length greater than m
This commit is contained in:
commit
cf4d7bb0f3
2 changed files with 6 additions and 0 deletions
|
@ -304,6 +304,8 @@ Script.createP2SHScriptPubKey = function(hash) {
|
||||||
|
|
||||||
// m [pubKeys ...] n OP_CHECKMULTISIG
|
// m [pubKeys ...] n OP_CHECKMULTISIG
|
||||||
Script.createMultisigScriptPubKey = function(m, pubKeys) {
|
Script.createMultisigScriptPubKey = function(m, pubKeys) {
|
||||||
|
assert(Array.isArray(pubKeys), 'Expected Array, got: ' + pubKeys)
|
||||||
|
assert(pubKeys.length >= m, 'Not enough pubKeys provided')
|
||||||
var script = new Script()
|
var script = new Script()
|
||||||
var n = pubKeys.length
|
var n = pubKeys.length
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,10 @@ describe('Script', function() {
|
||||||
|
|
||||||
assert.equal(multisigAddress.toString(), '32vYjxBb7pHJJyXgNk8UoK3BdRDxBzny2v')
|
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() {
|
describe('2-of-2 Multisig scriptSig', function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue