MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / parse

Method parse

src/rpcserver.cpp:439–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439void JSONRequest::parse(const UniValue& valRequest)
440{
441 // Parse request
442 if (!valRequest.isObject())
443 throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
444 const UniValue& request = valRequest.get_obj();
445
446 // Parse id now so errors from here on will have the id
447 id = find_value(request, "id");
448
449 // Parse method
450 UniValue valMethod = find_value(request, "method");
451 if (valMethod.isNull())
452 throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
453 if (!valMethod.isStr())
454 throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
455 strMethod = valMethod.get_str();
456 if (strMethod != "getblocktemplate")
457 LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
458
459 // Parse params
460 UniValue valParams = find_value(request, "params");
461 if (valParams.isArray())
462 params = valParams.get_array();
463 else if (valParams.isNull())
464 params = UniValue(UniValue::VARR);
465 else
466 throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
467}
468
469static UniValue JSONRPCExecOne(const UniValue& req)
470{

Callers 3

postprocess_translationsFunction · 0.45
HTTPReq_JSONRPCFunction · 0.45
JSONRPCExecOneFunction · 0.45

Calls 8

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

Tested by

no test coverage detected