scripts: add error for >n signatures with multisig
This commit is contained in:
parent
8d5ef2dd06
commit
e1479b6fa5
2 changed files with 20 additions and 3 deletions
|
@ -238,9 +238,13 @@ function multisigInput(signatures, scriptPubKey) {
|
|||
if (scriptPubKey) {
|
||||
assert(isMultisigOutput.call(scriptPubKey))
|
||||
|
||||
var m = scriptPubKey.chunks[0]
|
||||
var k = m - (opcodes.OP_1 - 1)
|
||||
assert(k <= signatures.length, 'Not enough signatures provided')
|
||||
var mOp = scriptPubKey.chunks[0]
|
||||
var nOp = scriptPubKey.chunks[scriptPubKey.chunks.length - 2]
|
||||
var m = mOp - (opcodes.OP_1 - 1)
|
||||
var n = nOp - (opcodes.OP_1 - 1)
|
||||
|
||||
assert(signatures.length >= m, 'Not enough signatures provided')
|
||||
assert(signatures.length <= n, 'Too many signatures provided')
|
||||
}
|
||||
|
||||
return Script.fromChunks([].concat(opcodes.OP_0, signatures))
|
||||
|
|
13
test/fixtures/scripts.json
vendored
13
test/fixtures/scripts.json
vendored
|
@ -101,6 +101,19 @@
|
|||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
|
||||
],
|
||||
"scriptPubKey": false
|
||||
},
|
||||
{
|
||||
"exception": "Too many signatures provided",
|
||||
"pubKeys": [
|
||||
"02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a"
|
||||
],
|
||||
"signatures": [
|
||||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501",
|
||||
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
|
||||
],
|
||||
"scriptPubKey": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue