mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 11:44:14 +01:00
rpc: migrate JSONRPCRequest functionality into request.cpp
This commit is contained in:
@@ -329,39 +329,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");
|
||||
|
||||
Reference in New Issue
Block a user