Bitcoin ABC  0.24.7
P2P Digital Currency
request.h
Go to the documentation of this file.
1 // Copyright (c) 2018 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_RPC_REQUEST_H
6 #define BITCOIN_RPC_REQUEST_H
7 
8 #include <string>
9 
10 #include <univalue.h>
11 
12 namespace util {
13 class Ref;
14 } // namespace util
15 
16 UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue &params,
17  const UniValue &id);
18 UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error,
19  const UniValue &id);
20 std::string JSONRPCReply(const UniValue &result, const UniValue &error,
21  const UniValue &id);
22 UniValue JSONRPCError(int code, const std::string &message);
23 
25 bool GenerateAuthCookie(std::string *cookie_out);
27 bool GetAuthCookie(std::string *cookie_out);
29 void DeleteAuthCookie();
31 std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in);
32 
34 public:
36  std::string strMethod;
38  bool fHelp;
39  std::string URI;
40  std::string authUser;
41  std::string peerAddr;
43 
44  JSONRPCRequest(const util::Ref &contextIn)
46  context(contextIn) {}
47 
51  JSONRPCRequest(const JSONRPCRequest &other, const util::Ref &contextIn)
52  : id(other.id), strMethod(other.strMethod), params(other.params),
53  fHelp(other.fHelp), URI(other.URI), authUser(other.authUser),
54  peerAddr(other.peerAddr), context(contextIn) {}
55 
56  void parse(const UniValue &valRequest);
57 };
58 
59 #endif // BITCOIN_RPC_REQUEST_H
JSONRPCRequest::JSONRPCRequest
JSONRPCRequest(const util::Ref &contextIn)
Definition: request.h:44
JSONRPCRequest::context
const util::Ref & context
Definition: request.h:42
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
JSONRPCRequest::JSONRPCRequest
JSONRPCRequest(const JSONRPCRequest &other, const util::Ref &contextIn)
Initializes request information from another request object and the given context.
Definition: request.h:51
JSONRPCReply
std::string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: request.cpp:46
UniValue
Definition: univalue.h:23
DeleteAuthCookie
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
Definition: request.cpp:128
JSONRPCRequest::peerAddr
std::string peerAddr
Definition: request.h:41
util::Ref
Type-safe dynamic reference.
Definition: ref.h:21
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:52
JSONRPCRequest::id
UniValue id
Definition: request.h:35
JSONRPCRequest::strMethod
std::string strMethod
Definition: request.h:36
univalue.h
JSONRPCProcessBatchReply
std::vector< UniValue > JSONRPCProcessBatchReply(const UniValue &in)
Parse JSON-RPC batch reply into a vector.
Definition: request.cpp:137
JSONRPCRequest::fHelp
bool fHelp
Definition: request.h:38
JSONRPCRequestObj
UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue &params, const UniValue &id)
JSON-RPC protocol.
Definition: request.cpp:24
JSONRPCReplyObj
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: request.cpp:33
GetAuthCookie
bool GetAuthCookie(std::string *cookie_out)
Read the RPC authentication cookie from disk.
Definition: request.cpp:111
JSONRPCRequest::parse
void parse(const UniValue &valRequest)
Definition: request.cpp:157
JSONRPCRequest::params
UniValue params
Definition: request.h:37
JSONRPCRequest::URI
std::string URI
Definition: request.h:39
JSONRPCRequest
Definition: request.h:33
GenerateAuthCookie
bool GenerateAuthCookie(std::string *cookie_out)
Generate a new RPC authentication cookie and write it to disk.
Definition: request.cpp:76
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
util
Definition: httprpc.h:13
JSONRPCRequest::authUser
std::string authUser
Definition: request.h:40