diff --git a/lib/server.js b/lib/server.js index a920eaf..eea6bf6 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1009,7 +1009,9 @@ WalletService.prototype.getTxHistory = function(opts, cb) { var filtered = _.sortBy(_.filter(txs, function(tx) { return tx.time >= minTs && tx.time <= maxTs; - }), 'time'); + }), function(tx) { + return -tx.time; + }); return limited ? _.take(filtered, opts.limit) : filtered; }; diff --git a/test/integration/server.js b/test/integration/server.js index 8f81a6a..433615f 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2351,30 +2351,30 @@ describe('Copay server', function() { minTs: 15, maxTs: 45, }, - expected: [20, 30, 40], + expected: [40, 30, 20], }, { opts: { minTs: 15, maxTs: 45, limit: 2, }, - expected: [20, 30], + expected: [40, 30], }, { opts: { maxTs: 35, }, - expected: [10, 20, 30], + expected: [30, 20, 10], }, { opts: { minTs: 15, }, - expected: [20, 30, 40, 50], + expected: [50, 40, 30, 20], }, { opts: { minTs: 15, limit: 3, }, - expected: [20, 30, 40], + expected: [50, 40, 30], }]; server._normalizeTxHistory = sinon.stub().returnsArg(0);