diff --git a/src/transaction_builder.js b/src/transaction_builder.js index 42a77bf..fc6a419 100644 --- a/src/transaction_builder.js +++ b/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] diff --git a/test/transaction_builder.js b/test/transaction_builder.js index fb2ae67..974f687 100644 --- a/test/transaction_builder.js +++ b/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())