 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
36 request.
push_back(Pair(
"method", strMethod));
37 request.
push_back(Pair(
"params", params));
39 return request.
write() +
"\n";
57 return reply.
write() +
"\n";
63 error.push_back(Pair(
"code", code));
64 error.push_back(Pair(
"message", message));
72 static const std::string COOKIEAUTH_USER =
"__cookie__";
74 static const std::string COOKIEAUTH_FILE =
".cookie";
78 fs::path path(
GetArg(
"-rpccookiefile", COOKIEAUTH_FILE));
84 unsigned char rand_pwd[32];
86 std::string cookie = COOKIEAUTH_USER +
":" +
EncodeBase64(&rand_pwd[0],32);
93 file.open(filepath.string().c_str());
94 if (!file.is_open()) {
95 LogPrintf(
"Unable to open cookie authentication file %s for writing\n", filepath.string());
100 LogPrintf(
"Generated RPC authentication cookie %s\n", filepath.string());
103 *cookie_out = cookie;
112 file.open(filepath.string().c_str());
115 std::getline(file, cookie);
119 *cookie_out = cookie;
127 }
catch (
const fs::filesystem_error& e) {
128 LogPrintf(
"%s: Unable to remove random auth cookie file: %s\n", __func__, e.what());
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
const UniValue NullUniValue
bool GenerateAuthCookie(std::string *cookie_out)
Generate a new RPC authentication cookie and write it to disk.
void GetRandBytes(unsigned char *buf, int num)
Functions to gather random data via the OpenSSL PRNG.
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific)
UniValue JSONRPCError(int code, const std::string &message)
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
std::string EncodeBase64(const unsigned char *pch, size_t len)
std::string JSONRPCRequest(const std::string &strMethod, const UniValue ¶ms, const UniValue &id)
JSON-RPC protocol.
std::string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
bool push_back(const UniValue &val)
fs::path GetAuthCookieFile()
Get name of RPC authentication cookie file.
bool GetAuthCookie(std::string *cookie_out)
Read the RPC authentication cookie from disk.
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
bool error(const char *fmt, const Args &... args)