|
|
@ -913,12 +913,11 @@ WalletService.prototype._normalizeTxHistory = function(txs) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Retrieves all transactions (incoming & outgoing) in the range (maxTs-minTs) |
|
|
|
* Retrieves all transactions (incoming & outgoing) |
|
|
|
* Times are in UNIX EPOCH |
|
|
|
* |
|
|
|
* @param {Object} opts |
|
|
|
* @param {Number} opts.minTs (defaults to 0) |
|
|
|
* @param {Number} opts.maxTs (defaults to now) |
|
|
|
* @param {Number} opts.skip (defaults to 0) |
|
|
|
* @param {Number} opts.limit |
|
|
|
* @returns {TxProposal[]} Transaction proposals, first newer |
|
|
|
*/ |
|
|
@ -1003,17 +1002,14 @@ WalletService.prototype.getTxHistory = function(opts, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
function paginate(txs) { |
|
|
|
var limited = opts.limit && opts.limit != -1; |
|
|
|
var minTs = opts.minTs || 0; |
|
|
|
var maxTs = opts.maxTs || Math.ceil(Date.now() / 1000); |
|
|
|
var skip = opts.skip || 0; |
|
|
|
var limited = _.isNumber(opts.limit) && opts.limit != -1; |
|
|
|
|
|
|
|
var filtered = _.sortBy(_.filter(txs, function(tx) { |
|
|
|
return tx.time >= minTs && tx.time <= maxTs; |
|
|
|
}), function(tx) { |
|
|
|
var sliced = _.slice(_.sortBy(txs, function(tx) { |
|
|
|
return -tx.time; |
|
|
|
}); |
|
|
|
}), skip); |
|
|
|
|
|
|
|
return limited ? _.take(filtered, opts.limit) : filtered; |
|
|
|
return limited ? _.take(sliced, opts.limit) : sliced; |
|
|
|
}; |
|
|
|
|
|
|
|
// Get addresses for this wallet
|
|
|
|