http: add to mempool and broadcast.
This commit is contained in:
parent
819b75e21b
commit
94f7bf000b
@ -28,6 +28,7 @@ function NodeServer(options) {
|
||||
assert(this.node, 'HTTP requires a Node.');
|
||||
|
||||
this.walletdb = this.node.walletdb;
|
||||
this.mempool = this.node.mempool;
|
||||
this.pool = this.node.pool;
|
||||
this.loaded = false;
|
||||
|
||||
@ -310,7 +311,7 @@ NodeServer.prototype._init = function _init() {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
self.pool.sendTX(tx, function(err) {
|
||||
addTX(tx, function(err) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
@ -320,6 +321,20 @@ NodeServer.prototype._init = function _init() {
|
||||
});
|
||||
});
|
||||
|
||||
function addMempool(tx, callback) {
|
||||
if (!self.mempool)
|
||||
return callback();
|
||||
self.mempool.addTX(tx, callback);
|
||||
}
|
||||
|
||||
function addTX(tx, callback) {
|
||||
addMempool(tx, function(err) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
self.pool.broadcast(tx, callback);
|
||||
});
|
||||
}
|
||||
|
||||
// Zap Wallet TXs
|
||||
this.post('/wallet/:id/zap', function(req, res, next, send) {
|
||||
var id = req.options.id;
|
||||
@ -498,7 +513,7 @@ NodeServer.prototype._init = function _init() {
|
||||
|
||||
// Broadcast TX
|
||||
this.post('/broadcast', function(req, res, next, send) {
|
||||
self.pool.sendTX(tx, function(err) {
|
||||
self.pool.sendTX(req.options.tx, function(err) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user