Merge pull request #312 from pnagurny/bug/sendTransaction

don't crash when sendTransaction is called with bad data
This commit is contained in:
Braydon Fuller 2015-10-14 11:11:47 -04:00
commit 77c10b3a09
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);