Browse Source

enforce txhistory limit

activeAddress
Matias Alejo Garcia 9 years ago
parent
commit
0968de59dd
  1. 1
      lib/errors/errordefinitions.js
  2. 3
      lib/server.js
  3. 9
      test/integration/server.js

1
lib/errors/errordefinitions.js

@ -17,6 +17,7 @@ var errors = {
INVALID_ADDRESS: 'Invalid address',
KEY_IN_COPAYER: 'Key already registered',
LOCKED_FUNDS: 'Funds are locked by pending transaction proposals',
HISTORY_LIMIT_EXCEEDED: 'Requested page limit is above allowed maximum',
MAIN_ADDRESS_GAP_REACHED: 'Maximum number of consecutive addresses without activity reached',
NOT_AUTHORIZED: 'Not authorized',
TOO_MANY_KEYS: 'Too many keys registered',

3
lib/server.js

@ -1975,7 +1975,8 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
opts = opts || {};
opts.limit = (_.isUndefined(opts.limit) ? HISTORY_LIMIT : opts.limit);
if (opts.limit > HISTORY_LIMIT) opts.limit = HISTORY_LIMIT;
if (opts.limit > HISTORY_LIMIT)
return cb(Errors.HISTORY_LIMIT_EXCEEDED);
function decorate(txs, addresses, proposals) {

9
test/integration/server.js

@ -4415,7 +4415,7 @@ describe('Wallet service', function() {
}, {
opts: {
skip: 4,
limit: 20,
limit: 10,
},
expected: [10],
}, {
@ -4479,6 +4479,13 @@ describe('Wallet service', function() {
done();
});
});
it('should handle exceeded limit', function(done) {
server.getTxHistory({limit:1000}, function(err, txs) {
err.code.should.equal('HISTORY_LIMIT_EXCEEDED');
done();
});
});
});
describe('#scan', function() {

Loading…
Cancel
Save