| 350 | } |
| 351 | |
| 352 | void JSONRPCRequest::parse(const UniValue& valRequest) |
| 353 | { |
| 354 | // Parse request |
| 355 | if (!valRequest.isObject()) |
| 356 | throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); |
| 357 | const UniValue& request = valRequest.get_obj(); |
| 358 | |
| 359 | // Parse id now so errors from here on will have the id |
| 360 | id = find_value(request, "id"); |
| 361 | |
| 362 | // Parse method |
| 363 | UniValue valMethod = find_value(request, "method"); |
| 364 | if (valMethod.isNull()) |
| 365 | throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); |
| 366 | if (!valMethod.isStr()) |
| 367 | throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); |
| 368 | strMethod = valMethod.get_str(); |
| 369 | if (fLogIPs) |
| 370 | LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s peeraddr=%s\n", SanitizeString(strMethod), |
| 371 | this->authUser, this->peerAddr); |
| 372 | else |
| 373 | LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s\n", SanitizeString(strMethod), this->authUser); |
| 374 | |
| 375 | // Parse params |
| 376 | UniValue valParams = find_value(request, "params"); |
| 377 | if (valParams.isArray() || valParams.isObject()) |
| 378 | params = valParams; |
| 379 | else if (valParams.isNull()) |
| 380 | params = UniValue(UniValue::VARR); |
| 381 | else |
| 382 | throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object"); |
| 383 | } |
| 384 | |
| 385 | bool IsDeprecatedRPCEnabled(const std::string& method) |
| 386 | { |
no test coverage detected