2019-06-19 13:39:38 -04:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
|
|
|
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_RPC_REQUEST_H
|
|
|
|
#define BITCOIN_RPC_REQUEST_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <univalue.h>
|
|
|
|
|
2020-04-17 11:28:45 -04:00
|
|
|
namespace util {
|
|
|
|
class Ref;
|
|
|
|
} // namespace util
|
|
|
|
|
2019-06-19 13:39:38 -04:00
|
|
|
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
|
|
|
|
UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
|
|
|
|
std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
|
|
|
|
UniValue JSONRPCError(int code, const std::string& message);
|
|
|
|
|
|
|
|
/** Generate a new RPC authentication cookie and write it to disk */
|
|
|
|
bool GenerateAuthCookie(std::string *cookie_out);
|
|
|
|
/** Read the RPC authentication cookie from disk */
|
|
|
|
bool GetAuthCookie(std::string *cookie_out);
|
|
|
|
/** Delete RPC authentication cookie from disk */
|
|
|
|
void DeleteAuthCookie();
|
|
|
|
/** Parse JSON-RPC batch reply into a vector */
|
2020-04-12 15:46:16 -04:00
|
|
|
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in);
|
2019-06-19 13:39:38 -04:00
|
|
|
|
|
|
|
class JSONRPCRequest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UniValue id;
|
|
|
|
std::string strMethod;
|
|
|
|
UniValue params;
|
|
|
|
bool fHelp;
|
|
|
|
std::string URI;
|
|
|
|
std::string authUser;
|
|
|
|
std::string peerAddr;
|
2020-04-17 11:28:45 -04:00
|
|
|
const util::Ref& context;
|
2019-06-19 13:39:38 -04:00
|
|
|
|
2020-04-17 11:28:45 -04:00
|
|
|
JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), fHelp(false), context(context) {}
|
2019-06-19 13:39:38 -04:00
|
|
|
void parse(const UniValue& valRequest);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_RPC_REQUEST_H
|