MCPcopy Create free account
hub / github.com/ElementsProject/elements / parse

Method parse

src/rpc/request.cpp:203–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203void JSONRPCRequest::parse(const UniValue& valRequest)
204{
205 // Parse request
206 if (!valRequest.isObject())
207 throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
208 const UniValue& request = valRequest.get_obj();
209
210 // Parse id now so errors from here on will have the id
211 id = find_value(request, "id");
212
213 // Parse method
214 UniValue valMethod = find_value(request, "method");
215 if (valMethod.isNull())
216 throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
217 if (!valMethod.isStr())
218 throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
219 strMethod = valMethod.get_str();
220 if (fLogIPs)
221 LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s peeraddr=%s\n", SanitizeString(strMethod),
222 this->authUser, this->peerAddr);
223 else
224 LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s\n", SanitizeString(strMethod), this->authUser);
225
226 // Parse params
227 UniValue valParams = find_value(request, "params");
228 if (valParams.isArray() || valParams.isObject())
229 params = valParams;
230 else if (valParams.isNull())
231 params = UniValue(UniValue::VARR);
232 else
233 throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object");
234}

Callers 5

security-check.pyFile · 0.45
symbol-check.pyFile · 0.45
get_archFunction · 0.45
HTTPReq_JSONRPCFunction · 0.45
JSONRPCExecOneFunction · 0.45

Calls 7

JSONRPCErrorFunction · 0.85
SanitizeStringFunction · 0.85
isObjectMethod · 0.80
isStrMethod · 0.80
isArrayMethod · 0.80
UniValueClass · 0.70
isNullMethod · 0.45

Tested by 1

get_archFunction · 0.36