commit
9ff2d9c99b
|
@ -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',
|
||||
|
|
|
@ -35,6 +35,7 @@ var blockchainExplorerOpts;
|
|||
var messageBroker;
|
||||
var serviceVersion;
|
||||
|
||||
var HISTORY_LIMIT = 10;
|
||||
|
||||
/**
|
||||
* Creates an instance of the Bitcore Wallet Service.
|
||||
|
@ -1972,6 +1973,11 @@ WalletService.prototype._normalizeTxHistory = function(txs) {
|
|||
WalletService.prototype.getTxHistory = function(opts, cb) {
|
||||
var self = this;
|
||||
|
||||
opts = opts || {};
|
||||
opts.limit = (_.isUndefined(opts.limit) ? HISTORY_LIMIT : opts.limit);
|
||||
if (opts.limit > HISTORY_LIMIT)
|
||||
return cb(Errors.HISTORY_LIMIT_EXCEEDED);
|
||||
|
||||
function decorate(txs, addresses, proposals) {
|
||||
|
||||
var indexedAddresses = _.indexBy(addresses, 'address');
|
||||
|
@ -2094,7 +2100,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
|
|||
},
|
||||
function(next) {
|
||||
var from = opts.skip || 0;
|
||||
var to = from + (_.isUndefined(opts.limit) ? 100 : opts.limit);
|
||||
var to = from + opts.limit;
|
||||
bc.getTransactions(addressStrs, from, to, function(err, txs) {
|
||||
if (err) return cb(err);
|
||||
next(null, self._normalizeTxHistory(txs));
|
||||
|
|
|
@ -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…
Reference in New Issue