| 40 | static bool g_rpc_whitelist_default = false; |
| 41 | |
| 42 | static UniValue JSONErrorReply(UniValue objError, const JSONRPCRequest& jreq, HTTPStatusCode& nStatus) |
| 43 | { |
| 44 | // HTTP errors should never be returned if JSON-RPC v2 was requested. This |
| 45 | // function should only be called when a v1 request fails or when a request |
| 46 | // cannot be parsed, so the version is unknown. |
| 47 | Assume(jreq.m_json_version != JSONRPCVersion::V2); |
| 48 | |
| 49 | // Send error reply from json-rpc error object |
| 50 | nStatus = HTTP_INTERNAL_SERVER_ERROR; |
| 51 | int code = objError.find_value("code").getInt<int>(); |
| 52 | |
| 53 | if (code == RPC_INVALID_REQUEST) |
| 54 | nStatus = HTTP_BAD_REQUEST; |
| 55 | else if (code == RPC_METHOD_NOT_FOUND) |
| 56 | nStatus = HTTP_NOT_FOUND; |
| 57 | |
| 58 | return JSONRPCReplyObj(NullUniValue, std::move(objError), jreq.id, jreq.m_json_version); |
| 59 | } |
| 60 | |
| 61 | //This function checks username and password against -rpcauth |
| 62 | //entries from config file. |
no test coverage detected