added from & to args to #getTransactions call

This commit is contained in:
Ivan Socolsky 2014-11-26 12:27:38 -03:00
commit e77c7d90b1

View file

@ -44,9 +44,9 @@ var Insight = function(opts) {
}; };
if (opts.transports) { if (opts.transports) {
this.opts['transports'] = opts.transports; this.opts['transports'] = opts.transports;
} }
this.socket = this.getSocket(); this.socket = this.getSocket();
} }
@ -267,16 +267,21 @@ Insight.prototype.getTransaction = function(txid, cb) {
}); });
}; };
Insight.prototype.getTransactions = function (addresses, from, to, cb) { Insight.prototype.getTransactions = function(addresses, from, to, cb) {
preconditions.shouldBeArray(addresses); preconditions.shouldBeArray(addresses);
preconditions.shouldBeFunction(cb); preconditions.shouldBeFunction(cb);
var qs = '?from=' + (from || 0); var qs = '';
if (to) qs += '&to=' + to; if (_.isNumber(from)) {
qs += '?from=' + from;
if (_.isNumber(to)) {
qs += '&to=' + to;
}
}
this.requestPost('/api/addrs/txs' + qs, { this.requestPost('/api/addrs/txs' + qs, {
addrs: addresses.join(',') addrs: addresses.join(',')
}, function (err, res, txs) { }, function(err, res, txs) {
if (err || res.statusCode != 200) return cb(err || res); if (err || res.statusCode != 200) return cb(err || res);
cb(null, txs); cb(null, txs);
}); });
@ -303,7 +308,7 @@ Insight.prototype.getUnspent = function(addresses, cb) {
Insight.prototype.getActivity = function(addresses, cb) { Insight.prototype.getActivity = function(addresses, cb) {
preconditions.shouldBeArray(addresses); preconditions.shouldBeArray(addresses);
this.getTransactions(addresses, function then(err, txs) { this.getTransactions(addresses, null, null, function then(err, txs) {
if (err) return cb(err); if (err) return cb(err);
var flatArray = function(xss) { var flatArray = function(xss) {