aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/server.cpp')
-rw-r--r--src/rpc/server.cpp43
1 files changed, 2 insertions, 41 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 145b99b567..18f7426bcf 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -178,8 +178,6 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
static UniValue uptime(const JSONRPCRequest& jsonRequest)
{
- if (jsonRequest.fHelp || jsonRequest.params.size() > 0)
- throw std::runtime_error(
RPCHelpMan{"uptime",
"\nReturns the total uptime of the server.\n",
{},
@@ -190,15 +188,13 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
HelpExampleCli("uptime", "")
+ HelpExampleRpc("uptime", "")
},
- }.ToString());
+ }.Check(jsonRequest);
return GetTime() - GetStartupTime();
}
static UniValue getrpcinfo(const JSONRPCRequest& request)
{
- if (request.fHelp || request.params.size() > 0) {
- throw std::runtime_error(
RPCHelpMan{"getrpcinfo",
"\nReturns details of the RPC server.\n",
{},
@@ -217,9 +213,7 @@ static UniValue getrpcinfo(const JSONRPCRequest& request)
RPCExamples{
HelpExampleCli("getrpcinfo", "")
+ HelpExampleRpc("getrpcinfo", "")},
- }.ToString()
- );
- }
+ }.Check(request);
LOCK(g_rpc_server_info.mutex);
UniValue active_commands(UniValue::VARR);
@@ -334,39 +328,6 @@ bool RPCIsInWarmup(std::string *outStatus)
return fRPCInWarmup;
}
-void JSONRPCRequest::parse(const UniValue& valRequest)
-{
- // Parse request
- if (!valRequest.isObject())
- throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
- const UniValue& request = valRequest.get_obj();
-
- // Parse id now so errors from here on will have the id
- id = find_value(request, "id");
-
- // Parse method
- UniValue valMethod = find_value(request, "method");
- if (valMethod.isNull())
- throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
- if (!valMethod.isStr())
- throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
- strMethod = valMethod.get_str();
- if (fLogIPs)
- LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s peeraddr=%s\n", SanitizeString(strMethod),
- this->authUser, this->peerAddr);
- else
- LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s\n", SanitizeString(strMethod), this->authUser);
-
- // Parse params
- UniValue valParams = find_value(request, "params");
- if (valParams.isArray() || valParams.isObject())
- params = valParams;
- else if (valParams.isNull())
- params = UniValue(UniValue::VARR);
- else
- throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object");
-}
-
bool IsDeprecatedRPCEnabled(const std::string& method)
{
const std::vector<std::string> enabled_methods = gArgs.GetArgs("-deprecatedrpc");