PIVX Core  5.6.99
P2P Digital Currency
protocol.h
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2017-2020 The PIVX Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef PIVX_RPC_PROTOCOL_H
8 #define PIVX_RPC_PROTOCOL_H
9 
10 #include "fs.h"
11 
12 #include <list>
13 #include <map>
14 #include <stdint.h>
15 #include <string>
16 
17 #include <univalue.h>
18 
21  HTTP_OK = 200,
29 };
30 
38  RPC_PARSE_ERROR = -32700,
39 
52  RPC_IN_WARMUP = -28,
54 
59 
68 
81 };
82 
83 UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
84 UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
85 std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
86 UniValue JSONRPCError(int code, const std::string& message);
87 
89 fs::path GetAuthCookieFile();
91 bool GenerateAuthCookie(std::string *cookie_out);
93 bool GetAuthCookie(std::string *cookie_out);
95 void DeleteAuthCookie();
96 
97 #endif // PIVX_RPC_PROTOCOL_H
bool GetAuthCookie(std::string *cookie_out)
Read the RPC authentication cookie from disk.
Definition: protocol.cpp:100
fs::path GetAuthCookieFile()
Get name of RPC authentication cookie file.
Definition: protocol.cpp:68
std::string JSONRPCReply(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: protocol.cpp:47
UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue &params, const UniValue &id)
JSON-RPC protocol.
Definition: protocol.cpp:26
UniValue JSONRPCError(int code, const std::string &message)
Definition: protocol.cpp:53
void DeleteAuthCookie()
Delete RPC authentication cookie from disk.
Definition: protocol.cpp:116
HTTPStatusCode
HTTP status codes.
Definition: protocol.h:20
@ HTTP_BAD_REQUEST
Definition: protocol.h:22
@ HTTP_BAD_METHOD
Definition: protocol.h:26
@ HTTP_OK
Definition: protocol.h:21
@ HTTP_SERVICE_UNAVAILABLE
Definition: protocol.h:28
@ HTTP_UNAUTHORIZED
Definition: protocol.h:23
@ HTTP_NOT_FOUND
Definition: protocol.h:25
@ HTTP_FORBIDDEN
Definition: protocol.h:24
@ HTTP_INTERNAL_SERVER_ERROR
Definition: protocol.h:27
bool GenerateAuthCookie(std::string *cookie_out)
Generate a new RPC authentication cookie and write it to disk.
Definition: protocol.cpp:74
UniValue JSONRPCReplyObj(const UniValue &result, const UniValue &error, const UniValue &id)
Definition: protocol.cpp:35
RPCErrorCode
PIVX RPC error codes.
Definition: protocol.h:32
@ RPC_CLIENT_NODE_NOT_CONNECTED
Node has not been added before.
Definition: protocol.h:65
@ RPC_WALLET_NOT_SPECIFIED
No wallet specified (error when there are multiple wallets loaded)
Definition: protocol.h:80
@ RPC_VERIFY_ALREADY_IN_CHAIN
Transaction or block was rejected by network rules.
Definition: protocol.h:51
@ RPC_WALLET_INVALID_LABEL_NAME
Not enough funds in wallet.
Definition: protocol.h:72
@ RPC_WALLET_UNLOCK_NEEDED
Keypool ran out, call keypoolrefill first.
Definition: protocol.h:74
@ RPC_WALLET_ALREADY_UNLOCKED
Failed to encrypt the wallet.
Definition: protocol.h:78
@ RPC_OUT_OF_MEMORY
Invalid address or key.
Definition: protocol.h:45
@ RPC_PARSE_ERROR
Definition: protocol.h:38
@ RPC_FORBIDDEN_BY_SAFE_MODE
std::exception thrown in command handling
Definition: protocol.h:42
@ RPC_CLIENT_INVALID_IP_OR_SUBNET
Node to disconnect not found in connected nodes.
Definition: protocol.h:66
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:41
@ RPC_WALLET_INSUFFICIENT_FUNDS
Unspecified problem with wallet (key not found etc.)
Definition: protocol.h:71
@ RPC_CLIENT_NODE_ALREADY_ADDED
Still downloading initial blocks.
Definition: protocol.h:63
@ RPC_WALLET_WRONG_ENC_STATE
The wallet passphrase entered was incorrect.
Definition: protocol.h:76
@ RPC_METHOD_NOT_FOUND
Definition: protocol.h:35
@ RPC_INVALID_PARAMS
Definition: protocol.h:36
@ RPC_WALLET_ENCRYPTION_FAILED
Command given in wrong wallet encryption state (encrypting an encrypted wallet etc....
Definition: protocol.h:77
@ RPC_TRANSACTION_ALREADY_IN_CHAIN
Definition: protocol.h:58
@ RPC_TYPE_ERROR
Server is in safe mode, and command is not allowed in safe mode.
Definition: protocol.h:43
@ RPC_TRANSACTION_REJECTED
Definition: protocol.h:57
@ RPC_TRANSACTION_ERROR
RPC method is deprecated.
Definition: protocol.h:56
@ RPC_METHOD_DEPRECATED
Client still warming up.
Definition: protocol.h:53
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
Definition: protocol.h:61
@ RPC_INVALID_PARAMETER
Ran out of memory during operation.
Definition: protocol.h:46
@ RPC_IN_WARMUP
Transaction already in chain.
Definition: protocol.h:52
@ RPC_WALLET_ERROR
No valid connection manager instance found.
Definition: protocol.h:70
@ RPC_VERIFY_ERROR
Error parsing or validating structure in raw format.
Definition: protocol.h:49
@ RPC_WALLET_NOT_FOUND
Wallet is already unlocked.
Definition: protocol.h:79
@ RPC_INTERNAL_ERROR
Definition: protocol.h:37
@ RPC_WALLET_KEYPOOL_RAN_OUT
Invalid label name.
Definition: protocol.h:73
@ RPC_DATABASE_ERROR
Invalid, missing or duplicate parameter.
Definition: protocol.h:47
@ RPC_CLIENT_IN_INITIAL_DOWNLOAD
PIVX is not connected.
Definition: protocol.h:62
@ RPC_CLIENT_NODE_NOT_ADDED
Node is already added.
Definition: protocol.h:64
@ RPC_DESERIALIZATION_ERROR
Database error.
Definition: protocol.h:48
@ RPC_WALLET_PASSPHRASE_INCORRECT
Enter the wallet passphrase with walletpassphrase first.
Definition: protocol.h:75
@ RPC_INVALID_REQUEST
Standard JSON-RPC 2.0 errors.
Definition: protocol.h:34
@ RPC_VERIFY_REJECTED
General error during transaction or block submission.
Definition: protocol.h:50
@ RPC_INVALID_ADDRESS_OR_KEY
Unexpected type was passed as parameter.
Definition: protocol.h:44
@ RPC_CLIENT_P2P_DISABLED
Invalid IP/Subnet.
Definition: protocol.h:67
bool error(const char *fmt, const Args &... args)
Definition: system.h:77