Skip to content

Commit

Permalink
[RPC] Add optional bool arg to listdelegators to show blacklisted addrs
Browse files Browse the repository at this point in the history
Github-Pull: #1238
Rebased-From: 34e871c
  • Loading branch information
random-zebra authored and Fuzzbawls committed Jan 11, 2020
1 parent 8f01bce commit 7e32b1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Expand Up @@ -48,6 +48,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{"getreceivedbyaddress", 1},
{"getreceivedbyaccount", 1},
{"listcoldutxos", 0},
{"listdelegators", 0},
{"listreceivedbyaddress", 0},
{"listreceivedbyaddress", 1},
{"listreceivedbyaddress", 2},
Expand Down
15 changes: 11 additions & 4 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -237,15 +237,19 @@ UniValue ListaddressesForPurpose(const std::string strPurpose)

UniValue listdelegators(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
if (fHelp || params.size() > 1)
throw std::runtime_error(
"listdelegators \"addr\"\n"
"listdelegators ( fBlacklist )\n"
"\nShows the list of allowed delegator addresses for cold staking.\n"

"\nArguments:\n"
"1. fBlacklist (boolean, optional, default = false) Show addresses removed\n"
" from the delegators whitelist\n"

"\nResult:\n"
"[\n"
" {\n"
" \"label\": \"yyy\", (string) account label\n"
" \"label\": \"yyy\", (string) account label\n"
" \"address\": \"xxx\", (string) PIVX address string\n"
" }\n"
" ...\n"
Expand All @@ -255,7 +259,10 @@ UniValue listdelegators(const UniValue& params, bool fHelp)
HelpExampleCli("listdelegators" , "") +
HelpExampleRpc("listdelegators", ""));

return ListaddressesForPurpose("delegator");
const bool fBlacklist = (params.size() > 0 ? params[0].get_bool() : false);
return (fBlacklist ?
ListaddressesForPurpose(AddressBook::AddressBookPurpose::DELEGABLE) :
ListaddressesForPurpose(AddressBook::AddressBookPurpose::DELEGATOR));
}

UniValue liststakingaddresses(const UniValue& params, bool fHelp)
Expand Down

0 comments on commit 7e32b1e

Please sign in to comment.