api/transactions.js
function getAccountTransactions(api, options, callback) {
  try {
    validate.address(options.account);
  } catch(err) {
    return callback(err);
  }

  if (!options.min) {
    options.min = module.exports.DEFAULT_RESULTS_PER_PAGE;
  }
  if (!options.max) {
    options.max = Math.max(options.min,
      module.exports.DEFAULT_RESULTS_PER_PAGE);
  }
  if (!options.limit) {
    options.limit = module.exports.DEFAULT_LIMIT;
  }

  function queryTransactions(async_callback) {
    getLocalAndRemoteTransactions(api, options, async_callback);
  }

  function filterTransactions(transactions, async_callback) {
    async_callback(null, transactionFilter(transactions, options));
  }

  function sortTransactions(transactions, async_callback) {
    var compare = options.earliestFirst ? utils.compareTransactions :
      _.rearg(utils.compareTransactions, 1, 0);
    transactions.sort(compare);
    async_callback(null, transactions);
  }

  function mergeAndTruncateResults(transactions, async_callback) {
    if (options.previous_transactions
        && options.previous_transactions.length > 0) {
      transactions = options.previous_transactions.concat(transactions);
    }
    if (options.offset && options.offset > 0) {
      var offset_remaining = options.offset - transactions.length;
      transactions = transactions.slice(options.offset);
      options.offset = offset_remaining;
    }
    if (transactions.length > options.max) {
      transactions = transactions.slice(0, options.max);
    }
    async_callback(null, transactions);
  }

  function asyncWaterfallCallback(error, transactions) {
    if (error) {
      return callback(error);
    }
    if (!options.min || transactions.length >= options.min || !options.marker) {
      callback(null, transactions);
    } else {
      options.previous_transactions = transactions;
      setImmediate(function() {
        getAccountTransactions(api, options, callback);
      });
    }
  }

  var steps = [
    queryTransactions,
    filterTransactions,
    sortTransactions,
    mergeAndTruncateResults
  ];

  async.waterfall(steps, asyncWaterfallCallback);
}
function getAccountTransactions(api, options, callback) {
  try {
    validate.address(options.account);
  } catch(err) {
    return callback(err);
  }

  if (!options.min) {
    options.min = module.exports.DEFAULT_RESULTS_PER_PAGE;
  }
  if (!options.max) {
    options.max = Math.max(options.min,
      module.exports.DEFAULT_RESULTS_PER_PAGE);
  }
  if (!options.limit) {
    options.limit = module.exports.DEFAULT_LIMIT;
  }

  function queryTransactions(async_callback) {
    getLocalAndRemoteTransactions(api, options, async_callback);
  }

  function filterTransactions(transactions, async_callback) {
    async_callback(null, transactionFilter(transactions, options));
  }

  function sortTransactions(transactions, async_callback) {
    var compare = options.earliestFirst ? utils.compareTransactions :
      _.rearg(utils.compareTransactions, 1, 0);
    transactions.sort(compare);
    async_callback(null, transactions);
  }

  function mergeAndTruncateResults(transactions, async_callback) {
    if (options.previous_transactions
        && options.previous_transactions.length > 0) {
      transactions = options.previous_transactions.concat(transactions);
    }
    if (options.offset && options.offset > 0) {
      var offset_remaining = options.offset - transactions.length;
      transactions = transactions.slice(options.offset);
      options.offset = offset_remaining;
    }
    if (transactions.length > options.max) {
      transactions = transactions.slice(0, options.max);
    }
    async_callback(null, transactions);
  }

  function asyncWaterfallCallback(error, transactions) {
    if (error) {
      return callback(error);
    }
    if (!options.min || transactions.length >= options.min || !options.marker) {
      callback(null, transactions);
    } else {
      options.previous_transactions = transactions;
      setImmediate(function() {
        getAccountTransactions(api, options, callback);
      });
    }
  }

  var steps = [
    queryTransactions,
    filterTransactions,
    sortTransactions,
    mergeAndTruncateResults
  ];

  async.waterfall(steps, asyncWaterfallCallback);
}
function getAccountTransactions ( api , options , callback ) { try { validate . address ( options . account ) ; } catch ( err ) { return callback ( err ) ; } if ( ! options . min ) { options . min = module . exports . DEFAULT_RESULTS_PER_PAGE ; } if ( ! options . max ) { options . max = Math . max ( options . min , module . exports . DEFAULT_RESULTS_PER_PAGE ) ; } if ( ! options . limit ) { options . limit = module . exports . DEFAULT_LIMIT ; } function queryTransactions ( async_callback ) { getLocalAndRemoteTransactions ( api , options , async_callback ) ; } function filterTransactions ( transactions , async_callback ) { async_callback ( null , transactionFilter ( transactions , options ) ) ; } function sortTransactions ( transactions , async_callback ) { var compare = options . earliestFirst ? utils . compareTransactions : _ . rearg ( utils . compareTransactions , 1 , 0 ) ; transactions . sort ( compare ) ; async_callback ( null , transactions ) ; } function mergeAndTruncateResults ( transactions , async_callback ) { if ( options . previous_transactions && options . previous_transactions . length > 0 ) { transactions = options . previous_transactions . concat ( transactions ) ; } if ( options . offset && options . offset > 0 ) { var offset_remaining = options . offset - transactions . length ; transactions = transactions . slice ( options . offset ) ; options . offset = offset_remaining ; } if ( transactions . length > options . max ) { transactions = transactions . slice ( 0 , options . max ) ; } async_callback ( null , transactions ) ; } function asyncWaterfallCallback ( error , transactions ) { if ( error ) { return callback ( error ) ; } if ( ! options . min || transactions . length >= options . min || ! options . marker ) { callback ( null , transactions ) ; } else { options . previous_transactions = transactions ; setImmediate ( function ( ) { getAccountTransactions ( api , options , callback ) ; } ) ; } } var steps = [ queryTransactions , filterTransactions , sortTransactions , mergeAndTruncateResults ] ; async . waterfall ( steps , asyncWaterfallCallback ) ; }
Recursively get transactions for the specified account from
the Remote and local database. If options.min is set, this will
recurse until it has retrieved that number of transactions or
it has reached the end of the account's transaction history.

@param {Remote} remote
@param {/lib/db-interface} dbinterface
@param {RippleAddress} options.account
@param {Number} [-1] options.ledger_index_min
@param {Number} [-1] options.ledger_index_max
@param {Boolean} [false] options.earliestFirst
@param {Boolean} [false] options.binary
@param {Boolean} [false] options.exclude_failed
@param {Number} [DEFAULT_RESULTS_PER_PAGE] options.min
@param {Number} [DEFAULT_RESULTS_PER_PAGE] options.max
@param {Array of Strings} options.types Possible values are "payment",
"offercreate", "offercancel", "trustset", "accountset"
@param {opaque value} options.marker
@param {Array of Transactions} options.previous_transactions
Included automatically when this function is called recursively
@param {Express.js Response} res
@param {Function} callback

@callback
@param {Error} error
@param {Array of transactions in JSON format} transactions
Recursively get transactions for the specified account from the Remote and local database . If options . min is set this will recurse until it has retrieved that number of transactions or it has reached the end of the account s transaction history .