diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-05-09 09:42:29 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-05-09 09:42:29 -0700 |
commit | 6244e449994afc38001cf6863d7ad2644c5b040a (patch) | |
tree | 7e36139a573f1c632c0412489332654902fe9080 | |
parent | 752e598a166953fce2f1164047bedc17f850aed0 (diff) | |
parent | ec86134a0daa116dfbcc3403fae78ebb5d57368a (diff) |
Merge pull request #160 from CAFxX/listtransactions-from
add parameter "from" to listtransactions (range queries)
-rw-r--r-- | rpc.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1083,8 +1083,8 @@ Value listtransactions(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( - "listtransactions [account] [count=10]\n" - "Returns up to [count] most recent transactions for account <account>."); + "listtransactions [account] [count=10] [from=0]\n" + "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]."); string strAccount = "*"; if (params.size() > 0) @@ -1092,6 +1092,9 @@ Value listtransactions(const Array& params, bool fHelp) int nCount = 10; if (params.size() > 1) nCount = params[1].get_int(); + int nFrom = 0; + if (params.size() > 2) + nFrom = params[2].get_int(); Array ret; CWalletDB walletdb; @@ -1116,7 +1119,7 @@ Value listtransactions(const Array& params, bool fHelp) } // Now: iterate backwards until we have nCount items to return: - for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it) + for (TxItems::reverse_iterator it = txByTime.rbegin(), std::advance(it, nFrom); it != txByTime.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) @@ -2088,6 +2091,7 @@ int CommandLineRPC(int argc, char *argv[]) if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]); if (strMethod == "sendfrom" && n > 3) ConvertTo<boost::int64_t>(params[3]); if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]); + if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]); if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]); if (strMethod == "sendmany" && n > 1) { |