From 5aef2c0d55f2bb0de071642a944c97022d11231c Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Fri, 15 Apr 2011 08:24:59 +0200 Subject: add parameter from to listtransactions this allows querying for ranges, i.e. transactions [from, from+count) --- rpc.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rpc.cpp b/rpc.cpp index 93df5c22a4..69db71a80f 100644 --- a/rpc.cpp +++ b/rpc.cpp @@ -1084,8 +1084,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 ."); + "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) @@ -1093,6 +1093,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; @@ -1117,7 +1120,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) -- cgit v1.2.3 From ec86134a0daa116dfbcc3403fae78ebb5d57368a Mon Sep 17 00:00:00 2001 From: Carlo Alberto Ferraris Date: Sat, 7 May 2011 18:34:32 +0200 Subject: Allow using the [from] parameter also from command-line --- rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rpc.cpp b/rpc.cpp index 69db71a80f..e8335cd51f 100644 --- a/rpc.cpp +++ b/rpc.cpp @@ -2087,6 +2087,7 @@ int CommandLineRPC(int argc, char *argv[]) if (strMethod == "sendfrom" && n > 2) ConvertTo(params[2]); if (strMethod == "sendfrom" && n > 3) ConvertTo(params[3]); if (strMethod == "listtransactions" && n > 1) ConvertTo(params[1]); + if (strMethod == "listtransactions" && n > 2) ConvertTo(params[2]); if (strMethod == "listaccounts" && n > 0) ConvertTo(params[0]); if (strMethod == "sendmany" && n > 1) { -- cgit v1.2.3