mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
rpc: switch to using RPCHelpMan.Check()
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
|
||||
static UniValue getconnectioncount(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getconnectioncount",
|
||||
"\nReturns the number of connections to other nodes.\n",
|
||||
{},
|
||||
@@ -38,7 +36,7 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getconnectioncount", "")
|
||||
+ HelpExampleRpc("getconnectioncount", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -48,8 +46,6 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue ping(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"ping",
|
||||
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
|
||||
"Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
|
||||
@@ -60,7 +56,7 @@ static UniValue ping(const JSONRPCRequest& request)
|
||||
HelpExampleCli("ping", "")
|
||||
+ HelpExampleRpc("ping", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -74,8 +70,6 @@ static UniValue ping(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getpeerinfo",
|
||||
"\nReturns data about each connected network node as a json array of objects.\n",
|
||||
{},
|
||||
@@ -131,7 +125,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getpeerinfo", "")
|
||||
+ HelpExampleRpc("getpeerinfo", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -258,8 +252,6 @@ static UniValue addnode(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue disconnectnode(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() == 0 || request.params.size() >= 3)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"disconnectnode",
|
||||
"\nImmediately disconnects from the specified peer node.\n"
|
||||
"\nStrictly one out of 'address' and 'nodeid' can be provided to identify the node.\n"
|
||||
@@ -275,7 +267,7 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"")
|
||||
+ HelpExampleRpc("disconnectnode", "\"\", 1")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -304,8 +296,6 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getaddednodeinfo",
|
||||
"\nReturns information about the given added node, or all added nodes\n"
|
||||
"(note that onetry addnodes are not listed here)\n",
|
||||
@@ -331,7 +321,7 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"")
|
||||
+ HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -374,8 +364,6 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue getnettotals(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getnettotals",
|
||||
"\nReturns information about network traffic, including bytes in, bytes out,\n"
|
||||
"and current time.\n",
|
||||
@@ -400,7 +388,7 @@ static UniValue getnettotals(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getnettotals", "")
|
||||
+ HelpExampleRpc("getnettotals", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
@@ -443,8 +431,6 @@ static UniValue GetNetworksInfo()
|
||||
|
||||
static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getnetworkinfo",
|
||||
"Returns an object containing various state info regarding P2P networking.\n",
|
||||
{},
|
||||
@@ -485,7 +471,7 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getnetworkinfo", "")
|
||||
+ HelpExampleRpc("getnetworkinfo", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
LOCK(cs_main);
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
@@ -602,8 +588,6 @@ static UniValue setban(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue listbanned(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"listbanned",
|
||||
"\nList all banned IPs/Subnets.\n",
|
||||
{},
|
||||
@@ -612,7 +596,7 @@ static UniValue listbanned(const JSONRPCRequest& request)
|
||||
HelpExampleCli("listbanned", "")
|
||||
+ HelpExampleRpc("listbanned", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
|
||||
if(!g_banman) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||
@@ -639,8 +623,6 @@ static UniValue listbanned(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue clearbanned(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"clearbanned",
|
||||
"\nClear all banned IPs.\n",
|
||||
{},
|
||||
@@ -649,7 +631,7 @@ static UniValue clearbanned(const JSONRPCRequest& request)
|
||||
HelpExampleCli("clearbanned", "")
|
||||
+ HelpExampleRpc("clearbanned", "")
|
||||
},
|
||||
}.ToString());
|
||||
}.Check(request);
|
||||
if (!g_banman) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||
}
|
||||
@@ -661,8 +643,6 @@ static UniValue clearbanned(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue setnetworkactive(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 1) {
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"setnetworkactive",
|
||||
"\nDisable/enable all p2p network activity.\n",
|
||||
{
|
||||
@@ -670,9 +650,7 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
|
||||
},
|
||||
RPCResults{},
|
||||
RPCExamples{""},
|
||||
}.ToString()
|
||||
);
|
||||
}
|
||||
}.Check(request);
|
||||
|
||||
if (!g_connman) {
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
@@ -685,8 +663,6 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue getnodeaddresses(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() > 1) {
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getnodeaddresses",
|
||||
"\nReturn known addresses which can potentially be used to find new nodes in the network\n",
|
||||
{
|
||||
@@ -707,8 +683,7 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
|
||||
HelpExampleCli("getnodeaddresses", "8")
|
||||
+ HelpExampleRpc("getnodeaddresses", "8")
|
||||
},
|
||||
}.ToString());
|
||||
}
|
||||
}.Check(request);
|
||||
if (!g_connman) {
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user