Merge pull request #312 from pnagurny/bug/sendTransaction
don't crash when sendTransaction is called with bad data
This commit is contained in:
commit
77c10b3a09
|
@ -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)');
|
}).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) {
|
it('will emit "tx" events', function(done) {
|
||||||
var tx = bitcore.Transaction();
|
var tx = bitcore.Transaction();
|
||||||
tx.from(utxos[2]);
|
tx.from(utxos[2]);
|
||||||
|
|
|
@ -365,7 +365,6 @@ DB.prototype.sendTransaction = function(tx, callback) {
|
||||||
} else {
|
} else {
|
||||||
txString = tx;
|
txString = tx;
|
||||||
}
|
}
|
||||||
$.checkArgument(typeof txString === 'string', 'Argument must be a hex string or Transaction');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var txid = this.node.services.bitcoind.sendTransaction(txString);
|
var txid = this.node.services.bitcoind.sendTransaction(txString);
|
||||||
|
|
Loading…
Reference in New Issue