Browse Source

add method to get txids from a specified block

feat/estimateFee-limit
Ivan Socolsky 8 years ago
parent
commit
13472e147a
No known key found for this signature in database GPG Key ID: FAECE6A05FAA4F56
  1. 19
      lib/blockchainexplorers/insight.js
  2. 4
      lib/blockchainmonitor.js

19
lib/blockchainexplorers/insight.js

@ -112,7 +112,7 @@ Insight.prototype.getTransactions = function(addresses, from, to, cb) {
json: {
addrs: [].concat(addresses).join(',')
},
timeout: 120000,
timeout: 120000,
};
this._doRequest(args, function(err, res, txs) {
@ -122,7 +122,7 @@ Insight.prototype.getTransactions = function(addresses, from, to, cb) {
if (txs.totalItems)
total = txs.totalItems;
if (txs.items)
if (txs.items)
txs = txs.items;
}
@ -183,6 +183,21 @@ Insight.prototype.getBlockchainHeight = function(cb) {
});
};
Insight.prototype.getTxidsInBlock = function(blockHash, cb) {
var self = this;
var args = {
method: 'GET',
path: this.apiPrefix + '/blocks/' + hash,
json: true,
};
this._doRequest(args, function(err, res, body) {
if (err || res.statusCode !== 200) return cb(_parseErr(err, res));
return cb(null, body.tx);
});
};
Insight.prototype.initSocket = function() {
// sockets always use the first server on the pull

4
lib/blockchainmonitor.js

@ -25,7 +25,7 @@ BlockchainMonitor.prototype.start = function(opts, cb) {
async.parallel([
function(done) {
self.explorers = _.map(['livenet', 'testnet'], function(network) {
self.explorers = _.indexBy(_.map(['livenet', 'testnet'], function(network) {
var explorer;
if (opts.blockchainExplorers) {
explorer = opts.blockchainExplorers[network];
@ -44,7 +44,7 @@ BlockchainMonitor.prototype.start = function(opts, cb) {
$.checkState(explorer);
self._initExplorer(explorer);
return explorer;
});
}), 'network');
done();
},
function(done) {

Loading…
Cancel
Save