AddressHistory API: query option 'latest'
- using latest option will query the latest 1000 (MAX_ITEM_LIMIT) of the address - Allowed values: 0 or false => false (DEFAULT) 1 or true => true *nothing* => true (ie, just leave the query as ?latest) - Address history API now also gives initItem (oldest tx in itemlist). initList is undefined if no confirmed tx available in item list
This commit is contained in:
parent
f63922b84e
commit
e6ced26b51
@ -313,6 +313,16 @@ AddressController.prototype.multitxs = function(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!_.isUndefined(req.query.latest)){
|
||||
let latest_query_int = parseInt(req.query.latest);
|
||||
if(!isNaN(latest_query_int))
|
||||
options.reverse = ( latest_query_int ? true : false);
|
||||
else if(req.query.latest == 'true' || req.query.latest == '') //empty string (ie, ?latest)
|
||||
options.reverse = true;
|
||||
else if(req.query.latest == 'false')
|
||||
options.reverse = false;
|
||||
}
|
||||
|
||||
//Temporary support
|
||||
if(req.query.from || req.body.from) {
|
||||
options.from = parseInt(req.query.from) || parseInt(req.body.from) || undefined;
|
||||
@ -339,12 +349,16 @@ AddressController.prototype.multitxs = function(req, res) {
|
||||
return self.common.handleErrors(err, res);
|
||||
}
|
||||
|
||||
var lastItem = items.find(a => a.confirmations !== 0), //assuming items is recent tx first order
|
||||
lastItem = typeof lastItem === 'object' ? lastItem.txid: undefined
|
||||
var lastItem = items.find(a => a.confirmations !== 0); //assuming items is recent tx first order
|
||||
lastItem = typeof lastItem === 'object' ? lastItem.txid: undefined;
|
||||
|
||||
var initItem = items[items.length -1]; //oldest tx in array
|
||||
initItem = (typeof initItem === 'object' && initItem.confirmations !== 0) ? initItem.txid : undefined;
|
||||
|
||||
var ret = {
|
||||
totalItems: result.totalCount,
|
||||
lastItem: lastItem,
|
||||
initItem: initItem,
|
||||
//from: options.from,
|
||||
//to: Math.min(options.to, result.totalCount),
|
||||
items: items
|
||||
|
||||
Loading…
Reference in New Issue
Block a user