Line data Source code
1 : // Copyright (c) 2010 Satoshi Nakamoto 2 : // Copyright (c) 2009-2021 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 <any> 10 : #include <string> 11 : 12 : #include <univalue.h> 13 : 14 : UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id); 15 : UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id); 16 : std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id); 17 : UniValue JSONRPCError(int code, const std::string& message); 18 : 19 : /** Generate a new RPC authentication cookie and write it to disk */ 20 : bool GenerateAuthCookie(std::string *cookie_out); 21 : /** Read the RPC authentication cookie from disk */ 22 : bool GetAuthCookie(std::string *cookie_out); 23 : /** Delete RPC authentication cookie from disk */ 24 : void DeleteAuthCookie(); 25 : /** Parse JSON-RPC batch reply into a vector */ 26 : std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in); 27 : 28 0 : class JSONRPCRequest 29 : { 30 : public: 31 : UniValue id; 32 : std::string strMethod; 33 : UniValue params; 34 0 : enum Mode { EXECUTE, GET_HELP, GET_ARGS } mode = EXECUTE; 35 : std::string URI; 36 : std::string authUser; 37 : std::string peerAddr; 38 : std::any context; 39 : 40 : void parse(const UniValue& valRequest); 41 : }; 42 : 43 : #endif // BITCOIN_RPC_REQUEST_H