Bitcoin Core  0.19.99
P2P Digital Currency
request.h
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_RPC_REQUEST_H
7 #define BITCOIN_RPC_REQUEST_H
8 
9 #include <string>
10 
11 #include <univalue.h>
12 
13 UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
14 UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
15 std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
16 UniValue JSONRPCError(int code, const std::string& message);
17 
19 bool GenerateAuthCookie(std::string *cookie_out);
21 bool GetAuthCookie(std::string *cookie_out);
23 void DeleteAuthCookie();
25 std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num);
26 
28 {
29 public:
31  std::string strMethod;
33  bool fHelp;
34  std::string URI;
35  std::string authUser;
36  std::string peerAddr;
37 
38  JSONRPCRequest() : id(NullUniValue), params(NullUniValue), fHelp(false) {}
39  void parse(const UniValue& valRequest);
40 };
41 
42 #endif // BITCOIN_RPC_REQUEST_H
std::string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: request.cpp:45
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
Definition: request.cpp:124
std::string strMethod
Definition: request.h:31
UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue &params, const UniValue &id)
JSON-RPC protocol.
Definition: request.cpp:24
std::string peerAddr
Definition: request.h:36
bool GetAuthCookie(std::string *cookie_out)
Read the RPC authentication cookie from disk.
Definition: request.cpp:108
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:51
UniValue params
Definition: request.h:32
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: request.cpp:33
UniValue id
Definition: request.h:30
bool fHelp
Definition: request.h:33
void parse(const UniValue &valRequest)
Definition: request.cpp:153
bool GenerateAuthCookie(std::string *cookie_out)
Generate a new RPC authentication cookie and write it to disk.
Definition: request.cpp:76
JSONRPCRequest()
Definition: request.h:38
std::string URI
Definition: request.h:34
std::string authUser
Definition: request.h:35
const UniValue NullUniValue
Definition: univalue.cpp:13
std::vector< UniValue > JSONRPCProcessBatchReply(const UniValue &in, size_t num)
Parse JSON-RPC batch reply into a vector.
Definition: request.cpp:133
bool error(const char *fmt, const Args &... args)
Definition: system.h:49