server. one hash.
This commit is contained in:
parent
6fc3c15c77
commit
1ea23577e4
@ -239,9 +239,14 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!tx)
|
if (!tx)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
self.node.fillHistory(tx, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, tx.toJSON());
|
send(200, tx.toJSON());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// TX by address
|
// TX by address
|
||||||
this.get('/tx/address/:address', function(req, res, next, send) {
|
this.get('/tx/address/:address', function(req, res, next, send) {
|
||||||
@ -252,11 +257,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.node.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Bulk read TXs
|
// Bulk read TXs
|
||||||
this.post('/tx/address', function(req, res, next, send) {
|
this.post('/tx/address', function(req, res, next, send) {
|
||||||
@ -267,11 +279,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.node.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Block by hash/height
|
// Block by hash/height
|
||||||
this.get('/block/:hash', function(req, res, next, send) {
|
this.get('/block/:hash', function(req, res, next, send) {
|
||||||
@ -463,11 +482,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.walletdb.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wallet Pending TXs
|
// Wallet Pending TXs
|
||||||
this.get('/wallet/:id/tx/unconfirmed', function(req, res, next, send) {
|
this.get('/wallet/:id/tx/unconfirmed', function(req, res, next, send) {
|
||||||
@ -478,11 +504,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.walletdb.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wallet TXs within time range
|
// Wallet TXs within time range
|
||||||
this.get('/wallet/:id/tx/range', function(req, res, next, send) {
|
this.get('/wallet/:id/tx/range', function(req, res, next, send) {
|
||||||
@ -493,11 +526,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.walletdb.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wallet TXs within time range
|
// Wallet TXs within time range
|
||||||
this.get('/wallet/:id/tx/last', function(req, res, next, send) {
|
this.get('/wallet/:id/tx/last', function(req, res, next, send) {
|
||||||
@ -510,11 +550,18 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.walletdb.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wallet TX
|
// Wallet TX
|
||||||
this.get('/wallet/:id/tx/:hash', function(req, res, next, send) {
|
this.get('/wallet/:id/tx/:hash', function(req, res, next, send) {
|
||||||
@ -525,9 +572,13 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
if (!tx)
|
if (!tx)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
self.walletdb.fillHistory(tx, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
send(200, tx.toJSON());
|
send(200, tx.toJSON());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Broadcast TX
|
// Broadcast TX
|
||||||
this.post('/broadcast', function(req, res, next, send) {
|
this.post('/broadcast', function(req, res, next, send) {
|
||||||
@ -545,16 +596,23 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
this.get('/mempool', function(req, res, next, send) {
|
this.get('/mempool', function(req, res, next, send) {
|
||||||
self.node.mempool.getHistory(function(err, txs) {
|
self.node.mempool.getHistory(function(err, txs) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return next(err);
|
||||||
|
|
||||||
if (!txs.length)
|
if (!txs.length)
|
||||||
return send(404);
|
return send(404);
|
||||||
|
|
||||||
|
utils.forEach(txs, function(tx, next) {
|
||||||
|
self.node.fillHistory(tx, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
send(200, txs.map(function(tx) {
|
send(200, txs.map(function(tx) {
|
||||||
return tx.toJSON();
|
return tx.toJSON();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.server.on('error', function(err) {
|
this.server.on('error', function(err) {
|
||||||
self.emit('error', err);
|
self.emit('error', err);
|
||||||
|
|||||||
@ -558,7 +558,7 @@ exports.sequence = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
exports.ONE_HASH = new Buffer(
|
exports.ONE_HASH = new Buffer(
|
||||||
'0000000000000000000000000000000000000000000000000000000000000001',
|
'0100000000000000000000000000000000000000000000000000000000000000',
|
||||||
'hex'
|
'hex'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user