| 547 | } |
| 548 | |
| 549 | void JSONRequest::parse(const UniValue& valRequest) |
| 550 | { |
| 551 | // Parse request |
| 552 | if (!valRequest.isObject()) |
| 553 | throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); |
| 554 | const UniValue& request = valRequest.get_obj(); |
| 555 | |
| 556 | // Parse id now so errors from here on will have the id |
| 557 | id = find_value(request, "id"); |
| 558 | |
| 559 | // Parse method |
| 560 | UniValue valMethod = find_value(request, "method"); |
| 561 | if (valMethod.isNull()) |
| 562 | throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); |
| 563 | if (!valMethod.isStr()) |
| 564 | throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); |
| 565 | strMethod = valMethod.get_str(); |
| 566 | if (strMethod != "getblocktemplate") |
| 567 | LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod)); |
| 568 | |
| 569 | // Parse params |
| 570 | UniValue valParams = find_value(request, "params"); |
| 571 | if (valParams.isArray()) |
| 572 | params = valParams.get_array(); |
| 573 | else if (valParams.isNull()) |
| 574 | params = UniValue(UniValue::VARR); |
| 575 | else |
| 576 | throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array"); |
| 577 | } |
| 578 | |
| 579 | |
| 580 | static UniValue JSONRPCExecOne(const UniValue& req) |
no test coverage detected