more tx broadcast events.
This commit is contained in:
parent
5f21978a44
commit
fdd94a4e40
@ -25,9 +25,10 @@ bitcoind.start(function(err) {
|
||||
// });
|
||||
bitcoind.once('tx', function(tx) {
|
||||
console.log('Broadcasting tx...');
|
||||
tx.broadcast(function(err, hash) {
|
||||
tx.broadcast(function(err, hash, tx) {
|
||||
if (err) throw err;
|
||||
console.log('tx hash: %s', hash);
|
||||
print(tx);
|
||||
});
|
||||
});
|
||||
bitcoind.on('mptx', function(mptx) {
|
||||
|
||||
@ -474,7 +474,7 @@ Transaction.broadcast = function(tx, options, callback) {
|
||||
var own = options.ownOnly = options.ownOnly || false;
|
||||
|
||||
if (!callback) {
|
||||
callback = function() {};
|
||||
callback = utils.NOOP;
|
||||
}
|
||||
|
||||
if (!tx.hex) {
|
||||
@ -483,7 +483,12 @@ Transaction.broadcast = function(tx, options, callback) {
|
||||
}
|
||||
|
||||
return bitcoindjs.broadcastTx(tx, fee, own, function(err, hash, tx) {
|
||||
if (err) return callback(err);
|
||||
if (err) {
|
||||
if (callback === utils.NOOP) {
|
||||
bitcoin.global.emit('error', err);
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
tx = bitcoin.tx(tx);
|
||||
bitcoin.global.emit('broadcast', tx);
|
||||
return callback(null, hash, tx);
|
||||
@ -609,6 +614,8 @@ utils.varint = function(arr, value, off) {
|
||||
}
|
||||
};
|
||||
|
||||
utils.NOOP = function() {};
|
||||
|
||||
/**
|
||||
* Expose
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user