36 return request.
write() +
"\n";
54 return reply.
write() +
"\n";
61 error.push_back(
Pair(
"message", message));
75 if (!path.is_complete()) path =
GetDataDir() / path;
81 const size_t COOKIE_SIZE = 32;
82 unsigned char rand_pwd[COOKIE_SIZE];
92 file.open(filepath.string().c_str());
93 if (!
file.is_open()) {
94 LogPrintf(
"Unable to open cookie authentication file %s for writing\n", filepath.string());
99 LogPrintf(
"Generated RPC authentication cookie %s\n", filepath.string());
102 *cookie_out = cookie;
111 file.open(filepath.string().c_str());
114 std::getline(
file, cookie);
118 *cookie_out = cookie;
126 }
catch (
const boost::filesystem::filesystem_error& e) {
127 LogPrintf(
"%s: Unable to remove random auth cookie file: %s\n", __func__, e.what());
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
boost::filesystem::path GetAuthCookieFile()
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
string JSONRPCRequest(const string &strMethod, const UniValue ¶ms, const UniValue &id)
bool push_back(const UniValue &val)
bool GetAuthCookie(std::string *cookie_out)
static bool error(const char *format)
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
bool GenerateAuthCookie(std::string *cookie_out)
static const std::string COOKIEAUTH_USER
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
static const std::string COOKIEAUTH_FILE
const UniValue NullUniValue
void GetRandBytes(unsigned char *buf, int num)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
UniValue JSONRPCError(int code, const string &message)