Browse Source

TxBuilder: limit signatures depending on scriptType

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
8d5ef2dd06
  1. 2
      src/transaction_builder.js
  2. 9
      test/transaction_builder.js

2
src/transaction_builder.js

@ -251,6 +251,8 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT
scriptType: scriptType,
signatures: []
}
} else {
assert.equal(scriptType, 'multisig', scriptType + ' doesn\'t support multiple signatures')
}
var input = this.signatures[index]

9
test/transaction_builder.js

@ -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() {
it('throws if prevOutScript is P2SH', function() {
var privScriptP2SH = scripts.scriptHashOutput(privScript.getHash())

Loading…
Cancel
Save