mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 12:33:26 -05:00
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
// Copyright (c) 2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2021 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 <any>
|
|
#include <string>
|
|
|
|
#include <univalue.h>
|
|
|
|
enum class JSONRPCVersion {
|
|
V1_LEGACY,
|
|
V2
|
|
};
|
|
|
|
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
|
|
UniValue JSONRPCReplyObj(UniValue result, UniValue error, UniValue id, JSONRPCVersion jsonrpc_version);
|
|
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 */
|
|
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in);
|
|
|
|
class JSONRPCRequest
|
|
{
|
|
public:
|
|
UniValue id;
|
|
std::string strMethod;
|
|
UniValue params;
|
|
enum Mode { EXECUTE, GET_HELP, GET_ARGS } mode = EXECUTE;
|
|
std::string URI;
|
|
std::string authUser;
|
|
std::string peerAddr;
|
|
std::any context;
|
|
JSONRPCVersion m_json_version = JSONRPCVersion::V1_LEGACY;
|
|
|
|
void parse(const UniValue& valRequest);
|
|
};
|
|
|
|
#endif // BITCOIN_RPC_REQUEST_H
|