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