don't crash when sendTransaction is called with bad data

This commit is contained in:
Patrick Nagurny 2015-10-14 10:50:50 -04:00
parent 2fe83ac5a3
commit 236d44441e
2 changed files with 12 additions and 1 deletions

View File

@ -304,6 +304,18 @@ describe('Daemon Binding Functionality', function() {
}).should.throw('\x10: mandatory-script-verify-flag-failed (Operation not valid with the current stack size)');
});
it('will throw an error for unexpected types', function() {
var garbage = new Buffer('abcdef', 'hex');
(function() {
bitcoind.sendTransaction(garbage);
}).should.throw('TX decode failed');
var num = 23;
(function() {
bitcoind.sendTransaction(num);
}).should.throw('TX decode failed');
});
it('will emit "tx" events', function(done) {
var tx = bitcore.Transaction();
tx.from(utxos[2]);

View File

@ -365,7 +365,6 @@ DB.prototype.sendTransaction = function(tx, callback) {
} else {
txString = tx;
}
$.checkArgument(typeof txString === 'string', 'Argument must be a hex string or Transaction');
try {
var txid = this.node.services.bitcoind.sendTransaction(txString);