Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/protocol.h
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_RPC_PROTOCOL_H | #ifndef BITCOIN_RPC_PROTOCOL_H | ||||
#define BITCOIN_RPC_PROTOCOL_H | #define BITCOIN_RPC_PROTOCOL_H | ||||
#include <fs.h> | |||||
#include <cstdint> | |||||
#include <list> | |||||
#include <map> | |||||
#include <string> | |||||
#include <univalue.h> | |||||
//! HTTP status codes | //! HTTP status codes | ||||
enum HTTPStatusCode { | enum HTTPStatusCode { | ||||
HTTP_OK = 200, | HTTP_OK = 200, | ||||
HTTP_BAD_REQUEST = 400, | HTTP_BAD_REQUEST = 400, | ||||
HTTP_UNAUTHORIZED = 401, | HTTP_UNAUTHORIZED = 401, | ||||
HTTP_FORBIDDEN = 403, | HTTP_FORBIDDEN = 403, | ||||
HTTP_NOT_FOUND = 404, | HTTP_NOT_FOUND = 404, | ||||
HTTP_BAD_METHOD = 405, | HTTP_BAD_METHOD = 405, | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | enum RPCErrorCode { | ||||
RPC_WALLET_INVALID_ACCOUNT_NAME = RPC_WALLET_INVALID_LABEL_NAME, | RPC_WALLET_INVALID_ACCOUNT_NAME = RPC_WALLET_INVALID_LABEL_NAME, | ||||
//! Unused reserved codes, kept around for backwards compatibility. Do not | //! Unused reserved codes, kept around for backwards compatibility. Do not | ||||
//! reuse. | //! reuse. | ||||
//! Server is in safe mode, and command is not allowed in safe mode | //! Server is in safe mode, and command is not allowed in safe mode | ||||
RPC_FORBIDDEN_BY_SAFE_MODE = -2, | RPC_FORBIDDEN_BY_SAFE_MODE = -2, | ||||
}; | }; | ||||
UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue ¶ms, | |||||
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 */ | |||||
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num); | |||||
#endif // BITCOIN_RPC_PROTOCOL_H | #endif // BITCOIN_RPC_PROTOCOL_H |