fixes. emit broadcast event.
This commit is contained in:
parent
2b2d56dfea
commit
b681642132
@ -20,6 +20,10 @@ var bitcoin = Bitcoin;
|
|||||||
function Bitcoin(options) {
|
function Bitcoin(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
if (Bitcoin.global) {
|
||||||
|
throw new Error('bitcoindjs cannot be instantiated more than once.');
|
||||||
|
}
|
||||||
|
|
||||||
if (!(this instanceof Bitcoin)) {
|
if (!(this instanceof Bitcoin)) {
|
||||||
return new Bitcoin(options);
|
return new Bitcoin(options);
|
||||||
}
|
}
|
||||||
@ -27,6 +31,8 @@ function Bitcoin(options) {
|
|||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
|
Bitcoin.global = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitcoin.prototype.__proto__ = EventEmitter.prototype;
|
Bitcoin.prototype.__proto__ = EventEmitter.prototype;
|
||||||
@ -464,22 +470,31 @@ Transaction.broadcast = function(tx, options, callback) {
|
|||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
options.overrideFees = options.overrideFees || false;
|
var fee = options.overrideFees = options.overrideFees || false;
|
||||||
options.ownOnly = options.ownOnly || false;
|
var own = options.ownOnly = options.ownOnly || false;
|
||||||
|
|
||||||
|
if (!callback) {
|
||||||
|
callback = function() {};
|
||||||
|
}
|
||||||
|
|
||||||
if (!tx.hex) {
|
if (!tx.hex) {
|
||||||
tx = bitcoin.tx(tx);
|
tx = bitcoin.tx(tx);
|
||||||
tx.toHex();
|
tx.toHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitcoindjs.broadcastTx(tx,
|
return bitcoindjs.broadcastTx(tx, fee, own, function(err, hash) {
|
||||||
options.overrideFees,
|
if (err) return callback(err);
|
||||||
options.ownOnly,
|
bitcoin.global.emit('broadcast', hash);
|
||||||
callback);
|
return callback(null, err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.broadcast = function(callback) {
|
Transaction.prototype.broadcast = function(options, callback) {
|
||||||
return Transaction.broadcast(this, callback);
|
if (!callback) {
|
||||||
|
callback = options;
|
||||||
|
options = null;
|
||||||
|
}
|
||||||
|
return Transaction.broadcast(this, options, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user