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) {
|
bitcoind.once('tx', function(tx) {
|
||||||
console.log('Broadcasting tx...');
|
console.log('Broadcasting tx...');
|
||||||
tx.broadcast(function(err, hash) {
|
tx.broadcast(function(err, hash, tx) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log('tx hash: %s', hash);
|
console.log('tx hash: %s', hash);
|
||||||
|
print(tx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
bitcoind.on('mptx', function(mptx) {
|
bitcoind.on('mptx', function(mptx) {
|
||||||
|
|||||||
@ -474,7 +474,7 @@ Transaction.broadcast = function(tx, options, callback) {
|
|||||||
var own = options.ownOnly = options.ownOnly || false;
|
var own = options.ownOnly = options.ownOnly || false;
|
||||||
|
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
callback = function() {};
|
callback = utils.NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tx.hex) {
|
if (!tx.hex) {
|
||||||
@ -483,7 +483,12 @@ Transaction.broadcast = function(tx, options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bitcoindjs.broadcastTx(tx, fee, own, function(err, hash, tx) {
|
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);
|
tx = bitcoin.tx(tx);
|
||||||
bitcoin.global.emit('broadcast', tx);
|
bitcoin.global.emit('broadcast', tx);
|
||||||
return callback(null, hash, tx);
|
return callback(null, hash, tx);
|
||||||
@ -609,6 +614,8 @@ utils.varint = function(arr, value, off) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
utils.NOOP = function() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user