aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Howie <me@chrishowie.com>2011-05-06 12:14:35 -0400
committerChris Howie <me@chrishowie.com>2011-07-14 15:56:21 -0400
commit5b2f35167f3060826e310145a34bc55bb2c8d3c1 (patch)
treed24dd139a56f8ea8b946b57d5f4d1d3a9b039d23 /src
parentf08736405e98d0f16ec294606dda782043d5ab3d (diff)
downloadbitcoin-5b2f35167f3060826e310145a34bc55bb2c8d3c1.tar.xz
Add listsinceblock command for retrieving all wallet transactions in blocks after the specified block
Diffstat (limited to 'src')
-rw-r--r--src/rpc.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/rpc.cpp b/src/rpc.cpp
index 6f951b7431..c6aa68d21e 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -1230,6 +1230,43 @@ Value listaccounts(const Array& params, bool fHelp)
return ret;
}
+Value listsinceblock(const Array& params, bool fHelp)
+{
+ if (fHelp)
+ throw runtime_error(
+ "listsinceblock [blockid]\n"
+ "Get all transactions in blocks since block [blockid], or all transactions if omitted");
+
+ CBlockIndex *pindex = NULL;
+
+ if (params.size() > 0)
+ {
+ uint256 blockId = 0;
+
+ blockId.SetHex(params[0].get_str());
+ pindex = CBlockLocator(blockId).GetBlockIndex();
+ }
+
+ int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1;
+
+ Array transactions;
+
+ CRITICAL_BLOCK(pwalletMain->cs_mapWallet)
+ for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++)
+ {
+ CWalletTx tx = (*it).second;
+
+ if (depth == -1 || tx.GetDepthInMainChain() < depth)
+ ListTransactions(tx, "*", 1, true, transactions);
+ }
+
+ Object ret;
+ ret.push_back(Pair("transactions", transactions));
+ ret.push_back(Pair("lastblock", hashBestChain.GetHex()));
+
+ return ret;
+}
+
Value gettransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
@@ -1470,6 +1507,7 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("getwork", &getwork),
make_pair("listaccounts", &listaccounts),
make_pair("settxfee", &settxfee),
+ make_pair("listsinceblock", &listsinceblock),
};
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));