From 5be46df3ed4449d4f897958a1ad88096ef458315 Mon Sep 17 00:00:00 2001 From: Jimmy Kiselak Date: Thu, 15 Jan 2015 18:02:30 -0500 Subject: [PATCH] enable limiting output of listnameclaims to transactions which have a minimum number of confirmations --- src/rpcclient.cpp | 1 + src/rpcwallet.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 170561bbb..383f8fa87 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -92,6 +92,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "updatename", 2}, { "abandonname", 2}, { "listnameclaims", 0}, + { "listnameclaims", 1}, }; class CRPCConvertTable diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 2e0edfba6..3430493ee 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -612,12 +612,13 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept Value listnameclaims(const Array& params, bool fHelp) { - if (fHelp || params.size() > 1) + if (fHelp || params.size() > 2) throw runtime_error( - "listnameclaims activeonly\n" + "listnameclaims activeonly minconf\n" "Return a list of all transactions claiming names.\n" "\nArguments\n" "1. activeonly (bool, optional, not implemented) Whether to only include transactions which are still active, i.e. have not been spent. Default is false.\n" + "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many time.\n" "\nResult:\n" "[\n" " {\n" @@ -649,6 +650,11 @@ Value listnameclaims(const Array& params, bool fHelp) fListSpent = !params[0].get_bool(); isminefilter ncc_filter = ISMINE_NCC; + // Minimum confirmations + int nMinDepth = 1; + if (params.size() > 1) + nMinDepth = params[1].get_int(); + Array ret; std::list acentries; @@ -657,7 +663,7 @@ Value listnameclaims(const Array& params, bool fHelp) for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; - if (pwtx != 0) + if (pwtx != 0 && pwtx->GetDepthInMainChain() >= nMinDepth) ListNameClaims(*pwtx, strAccount, 0, ret, ncc_filter, fListSpent); }