Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 20 additions & 40 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,52 +107,24 @@ UniValue masternode_connect(const JSONRPCRequest& request)
void masternode_count_help()
{
throw std::runtime_error(
"masternode count (\"mode\")\n"
" Get information about number of masternodes. Mode\n"
" usage is depricated, call without mode params returns\n"
" all values in JSON format.\n"
"\nArguments:\n"
"1. \"mode\" (string, optional, DEPRICATED) Option to get number of masternodes in different states\n"
"\nAvailable modes:\n"
" total - total number of masternodes"
" cj - number of CoinJoin compatible masternodes"
" enabled - number of enabled masternodes"
" qualify - number of qualified masternodes"
" all - all above in one string"
"masternode count\n"
"Get information about number of masternodes.\n"
);
}

UniValue masternode_count(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() > 2)
if (request.fHelp || request.params.size() > 1)
masternode_count_help();

auto mnList = deterministicMNManager->GetListAtChainTip();
int total = mnList.GetAllMNsCount();
int enabled = mnList.GetValidMNsCount();

if (request.params.size() == 1) {
UniValue obj(UniValue::VOBJ);

obj.pushKV("total", total);
obj.pushKV("enabled", enabled);

return obj;
}

std::string strMode = request.params[1].get_str();

if (strMode == "total")
return total;

if (strMode == "enabled")
return enabled;

if (strMode == "all")
return strprintf("Total: %d (Enabled: %d)",
total, enabled);

throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown mode value");
UniValue obj(UniValue::VOBJ);
obj.pushKV("total", total);
obj.pushKV("enabled", enabled);
return obj;
}

UniValue GetNextMasternodeForPayment(int heightShift)
Expand All @@ -179,6 +151,10 @@ UniValue GetNextMasternodeForPayment(int heightShift)

void masternode_winner_help()
{
if (!IsDeprecatedRPCEnabled("masternode_winner")) {
throw std::runtime_error("DEPRECATED: set -deprecatedrpc=masternode_winner to enable it");
}

throw std::runtime_error(
"masternode winner\n"
"Print info on next masternode winner to vote for\n"
Expand All @@ -187,14 +163,18 @@ void masternode_winner_help()

UniValue masternode_winner(const JSONRPCRequest& request)
{
if (request.fHelp)
if (request.fHelp || !IsDeprecatedRPCEnabled("masternode_winner"))
masternode_winner_help();

return GetNextMasternodeForPayment(10);
}

void masternode_current_help()
{
if (!IsDeprecatedRPCEnabled("masternode_current")) {
throw std::runtime_error("DEPRECATED: set -deprecatedrpc=masternode_current to enable it");
}

throw std::runtime_error(
"masternode current\n"
"Print info on current masternode winner to be paid the next block (calculated locally)\n"
Expand All @@ -203,7 +183,7 @@ void masternode_current_help()

UniValue masternode_current(const JSONRPCRequest& request)
{
if (request.fHelp)
if (request.fHelp || !IsDeprecatedRPCEnabled("masternode_current"))
masternode_current_help();

return GetNextMasternodeForPayment(1);
Expand Down Expand Up @@ -522,15 +502,15 @@ UniValue masternode_payments(const JSONRPCRequest& request)
"\nArguments:\n"
"1. \"command\" (string or set of strings, required) The command to execute\n"
"\nAvailable commands:\n"
" count - Get information about number of masternodes (DEPRECATED options: 'total', 'ps', 'enabled', 'qualify', 'all')\n"
" current - Print info on current masternode winner to be paid the next block (calculated locally)\n"
" count - Get information about number of masternodes\n"
" current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n"
#ifdef ENABLE_WALLET
" outputs - Print masternode compatible outputs\n"
#endif // ENABLE_WALLET
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" payments - Return information about masternode payments in a mined block\n"
" winner - Print info on next masternode winner to vote for\n"
" winner - DEPRECATED Print info on next masternode winner to vote for\n"
" winners - Print list of masternode winners\n"
);
}
Expand Down