Changeset View
Changeset View
Standalone View
Standalone View
src/httprpc.cpp
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | static bool HTTPReq_JSONRPC(Config &config, HTTPRequest *req, | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
JSONErrorReply(req, JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); | JSONErrorReply(req, JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static bool InitRPCAuthentication() { | static bool InitRPCAuthentication() { | ||||
if (GetArg("-rpcpassword", "") == "") { | if (gArgs.GetArg("-rpcpassword", "") == "") { | ||||
LogPrintf("No rpcpassword set - using random cookie authentication\n"); | LogPrintf("No rpcpassword set - using random cookie authentication\n"); | ||||
if (!GenerateAuthCookie(&strRPCUserColonPass)) { | if (!GenerateAuthCookie(&strRPCUserColonPass)) { | ||||
// Same message as AbortNode. | // Same message as AbortNode. | ||||
uiInterface.ThreadSafeMessageBox( | uiInterface.ThreadSafeMessageBox( | ||||
_("Error: A fatal internal error occurred, see debug.log for " | _("Error: A fatal internal error occurred, see debug.log for " | ||||
"details"), | "details"), | ||||
"", CClientUIInterface::MSG_ERROR); | "", CClientUIInterface::MSG_ERROR); | ||||
return false; | return false; | ||||
} | } | ||||
} else { | } else { | ||||
LogPrintf("Config options rpcuser and rpcpassword will soon be " | LogPrintf("Config options rpcuser and rpcpassword will soon be " | ||||
"deprecated. Locally-run instances may remove rpcuser to use " | "deprecated. Locally-run instances may remove rpcuser to use " | ||||
"cookie-based auth, or may be replaced with rpcauth. Please " | "cookie-based auth, or may be replaced with rpcauth. Please " | ||||
"see share/rpcuser for rpcauth auth generation.\n"); | "see share/rpcuser for rpcauth auth generation.\n"); | ||||
strRPCUserColonPass = | strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + | ||||
GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", ""); | gArgs.GetArg("-rpcpassword", ""); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool StartHTTPRPC() { | bool StartHTTPRPC() { | ||||
LogPrint(BCLog::RPC, "Starting HTTP RPC server\n"); | LogPrint(BCLog::RPC, "Starting HTTP RPC server\n"); | ||||
if (!InitRPCAuthentication()) return false; | if (!InitRPCAuthentication()) return false; | ||||
Show All 25 Lines |