| 375 | }; |
| 376 | |
| 377 | void JSONRequest::parse(const Value& valRequest) { |
| 378 | // Parse request |
| 379 | if (valRequest.type() != obj_type) |
| 380 | throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); |
| 381 | |
| 382 | const Object& request = valRequest.get_obj(); |
| 383 | |
| 384 | // Parse id now so errors from here on will have the id |
| 385 | id = find_value(request, "id"); |
| 386 | |
| 387 | // Parse method |
| 388 | Value valMethod = find_value(request, "method"); |
| 389 | if (valMethod.type() == null_type) |
| 390 | throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); |
| 391 | |
| 392 | if (valMethod.type() != str_type) |
| 393 | throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); |
| 394 | |
| 395 | strMethod = valMethod.get_str(); |
| 396 | LogPrint(BCLog::RPC, "ThreadRPCServer method=%s\n", strMethod); |
| 397 | |
| 398 | // Parse params |
| 399 | Value valParams = find_value(request, "params"); |
| 400 | if (valParams.type() == array_type) |
| 401 | params = valParams.get_array(); |
| 402 | else if (valParams.type() == null_type) |
| 403 | params = Array(); |
| 404 | else |
| 405 | throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array"); |
| 406 | } |
| 407 | |
| 408 | Object JSONRPCExecOne(const Value& req) { |
| 409 | Object rpc_result; |
no test coverage detected