TxBuilder: limit signatures depending on scriptType
This commit is contained in:
parent
e5618bb8bd
commit
8d5ef2dd06
2 changed files with 11 additions and 0 deletions
|
@ -251,6 +251,8 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT
|
||||||
scriptType: scriptType,
|
scriptType: scriptType,
|
||||||
signatures: []
|
signatures: []
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
assert.equal(scriptType, 'multisig', scriptType + ' doesn\'t support multiple signatures')
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = this.signatures[index]
|
var input = this.signatures[index]
|
||||||
|
|
|
@ -110,6 +110,15 @@ describe('TransactionBuilder', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('throws if scriptType doesn\'t support multiple signatures', function() {
|
||||||
|
txb.addInput(prevTxHash, 0)
|
||||||
|
txb.sign(0, privKey)
|
||||||
|
|
||||||
|
assert.throws(function() {
|
||||||
|
txb.sign(0, privKey)
|
||||||
|
}, /pubkeyhash doesn\'t support multiple signatures/)
|
||||||
|
})
|
||||||
|
|
||||||
describe('when redeemScript is undefined', function() {
|
describe('when redeemScript is undefined', function() {
|
||||||
it('throws if prevOutScript is P2SH', function() {
|
it('throws if prevOutScript is P2SH', function() {
|
||||||
var privScriptP2SH = scripts.scriptHashOutput(privScript.getHash())
|
var privScriptP2SH = scripts.scriptHashOutput(privScript.getHash())
|
||||||
|
|
Loading…
Add table
Reference in a new issue