32 request.
pushKV(
"method", strMethod);
33 request.
pushKV(
"params", params);
44 reply.
pushKV(
"result", result);
53 return reply.
write() +
"\n";
59 error.pushKV(
"code", code);
60 error.pushKV(
"message", message);
83 const size_t COOKIE_SIZE = 32;
84 unsigned char rand_pwd[COOKIE_SIZE];
93 file.open(filepath_tmp);
94 if (!file.is_open()) {
109 *cookie_out = cookie;
121 std::getline(file, cookie);
125 *cookie_out = cookie;
133 }
catch (
const fs::filesystem_error& e) {
141 throw std::runtime_error(
"Batch must be an array");
143 const size_t num {in.
size()};
144 std::vector<UniValue> batch(num);
146 if (!rec.isObject()) {
147 throw std::runtime_error(
"Batch member must be an object");
149 size_t id = rec[
"id"].getInt<
int>();
151 throw std::runtime_error(
"Batch member id is larger than batch size");
172 if (!valMethod.
isStr())
185 else if (valParams.
isNull())
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
void parse(const UniValue &valRequest)
const std::string & get_str() const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
const UniValue & get_obj() const
const std::vector< UniValue > & getValues() const
void pushKV(std::string key, UniValue val)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
#define LogPrint(category,...)
bool error(const char *fmt, const Args &... args)
static std::string PathToString(const path &path)
Convert path object to a byte string.
std::string get_filesystem_error_message(const fs::filesystem_error &e)
void GetRandBytes(Span< unsigned char > bytes) noexcept
Overall design of the RNG and entropy sources.
static fs::path GetAuthCookieFile(bool temp=false)
Get name of RPC authentication cookie file.
std::vector< UniValue > JSONRPCProcessBatchReply(const UniValue &in)
Parse JSON-RPC batch reply into a vector.
bool GetAuthCookie(std::string *cookie_out)
Read the RPC authentication cookie from disk.
std::string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue ¶ms, const UniValue &id)
JSON-RPC protocol.
UniValue JSONRPCError(int code, const std::string &message)
static const char *const COOKIEAUTH_FILE
Default name for auth cookie file.
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
bool GenerateAuthCookie(std::string *cookie_out)
Generate a new RPC authentication cookie and write it to disk.
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
static const std::string COOKIEAUTH_USER
Username used when cookie authentication is in use (arbitrary, only for recognizability in debugging/...
@ RPC_INVALID_REQUEST
Standard JSON-RPC 2.0 errors.
const UniValue & find_value(const UniValue &obj, const std::string &name)
const UniValue NullUniValue
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string SanitizeString(std::string_view str, int rule)
Remove unsafe chars.
bool RenameOver(fs::path src, fs::path dest)
Rename src to dest.
fs::path AbsPathForConfigVal(const ArgsManager &args, const fs::path &path, bool net_specific)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...