Bitcoin Core 31.99.0
P2P Digital Currency
protocol.h
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2009-present 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_PROTOCOL_H
7#define BITCOIN_RPC_PROTOCOL_H
8
11{
12 HTTP_OK = 200,
22};
23
26inline std::string_view HTTPStatusReasonString(HTTPStatusCode code)
27{
28 switch (code) {
29 case HTTP_OK: return "OK";
30 case HTTP_NO_CONTENT: return "No Content";
31 case HTTP_BAD_REQUEST: return "Bad Request";
32 case HTTP_UNAUTHORIZED: return "Unauthorized";
33 case HTTP_FORBIDDEN: return "Forbidden";
34 case HTTP_NOT_FOUND: return "Not Found";
35 case HTTP_BAD_METHOD: return "Method Not Allowed";
36 case HTTP_CONTENT_TOO_LARGE: return "Content too large";
37 case HTTP_INTERNAL_SERVER_ERROR: return "Internal Server Error";
38 case HTTP_SERVICE_UNAVAILABLE: return "Service Unavailable";
39 }
40
41 // Reason phrases are optional and may be replaced by local variants.
42 // https://httpwg.org/specs/rfc9110.html#rfc.section.15.1
43 return "";
44}
45
48{
50 // RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400).
51 // It should not be used for application-layer errors.
53 // RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404).
54 // It should not be used for application-layer errors.
57 // RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind
58 // (for example datadir corruption).
61
76
80
90
93
108
111
114};
115
116#endif // BITCOIN_RPC_PROTOCOL_H
std::string_view HTTPStatusReasonString(HTTPStatusCode code)
Mapping of HTTP status codes to short string explanation.
Definition: protocol.h:26
HTTPStatusCode
HTTP status codes.
Definition: protocol.h:11
@ HTTP_BAD_REQUEST
Definition: protocol.h:14
@ HTTP_BAD_METHOD
Definition: protocol.h:18
@ HTTP_OK
Definition: protocol.h:12
@ HTTP_CONTENT_TOO_LARGE
Definition: protocol.h:19
@ HTTP_SERVICE_UNAVAILABLE
Definition: protocol.h:21
@ HTTP_UNAUTHORIZED
Definition: protocol.h:15
@ HTTP_NOT_FOUND
Definition: protocol.h:17
@ HTTP_FORBIDDEN
Definition: protocol.h:16
@ HTTP_NO_CONTENT
Definition: protocol.h:13
@ HTTP_INTERNAL_SERVER_ERROR
Definition: protocol.h:20
RPCErrorCode
Bitcoin RPC error codes.
Definition: protocol.h:48
@ RPC_CLIENT_NODE_NOT_CONNECTED
Node to disconnect not found in connected nodes.
Definition: protocol.h:86
@ RPC_WALLET_NOT_SPECIFIED
No wallet specified (error when there are multiple wallets loaded)
Definition: protocol.h:105
@ RPC_WALLET_INVALID_ACCOUNT_NAME
Backwards compatible aliases.
Definition: protocol.h:110
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
Definition: protocol.h:97
@ RPC_WALLET_UNLOCK_NEEDED
Enter the wallet passphrase with walletpassphrase first.
Definition: protocol.h:99
@ RPC_LIMIT_EXCEEDED
A bounded resource is currently at capacity.
Definition: protocol.h:75
@ RPC_WALLET_ALREADY_UNLOCKED
Wallet is already unlocked.
Definition: protocol.h:103
@ RPC_OUT_OF_MEMORY
Ran out of memory during operation.
Definition: protocol.h:66
@ RPC_PARSE_ERROR
Definition: protocol.h:60
@ RPC_FORBIDDEN_BY_SAFE_MODE
Unused reserved codes, kept around for backwards compatibility. Do not reuse.
Definition: protocol.h:113
@ RPC_VERIFY_ALREADY_IN_UTXO_SET
Transaction already in utxo set.
Definition: protocol.h:72
@ RPC_CLIENT_INVALID_IP_OR_SUBNET
Invalid IP/Subnet.
Definition: protocol.h:87
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:63
@ RPC_WALLET_INSUFFICIENT_FUNDS
Not enough funds in wallet or account.
Definition: protocol.h:96
@ RPC_WALLET_ALREADY_EXISTS
There is already a wallet with the same name.
Definition: protocol.h:107
@ RPC_CLIENT_NODE_ALREADY_ADDED
Node is already added.
Definition: protocol.h:84
@ RPC_WALLET_WRONG_ENC_STATE
Command given in wrong wallet encryption state (encrypting an encrypted wallet etc....
Definition: protocol.h:101
@ RPC_METHOD_NOT_FOUND
Definition: protocol.h:55
@ RPC_INVALID_PARAMS
Definition: protocol.h:56
@ RPC_WALLET_ENCRYPTION_FAILED
Failed to encrypt the wallet.
Definition: protocol.h:102
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
Definition: protocol.h:64
@ RPC_CLIENT_MEMPOOL_DISABLED
Chain errors.
Definition: protocol.h:92
@ RPC_TRANSACTION_REJECTED
Definition: protocol.h:79
@ RPC_TRANSACTION_ERROR
Aliases for backward compatibility.
Definition: protocol.h:78
@ RPC_METHOD_DEPRECATED
RPC method is deprecated.
Definition: protocol.h:74
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
Definition: protocol.h:82
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:67
@ RPC_IN_WARMUP
Client still warming up.
Definition: protocol.h:73
@ RPC_WALLET_ERROR
Wallet errors.
Definition: protocol.h:95
@ RPC_WALLET_ALREADY_LOADED
This same wallet is already loaded.
Definition: protocol.h:106
@ RPC_VERIFY_ERROR
General error during transaction or block submission.
Definition: protocol.h:70
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
Definition: protocol.h:104
@ RPC_INTERNAL_ERROR
Definition: protocol.h:59
@ RPC_WALLET_KEYPOOL_RAN_OUT
Keypool ran out, call keypoolrefill first.
Definition: protocol.h:98
@ RPC_DATABASE_ERROR
Database error.
Definition: protocol.h:68
@ RPC_CLIENT_IN_INITIAL_DOWNLOAD
Still downloading initial blocks.
Definition: protocol.h:83
@ RPC_CLIENT_NODE_NOT_ADDED
Node has not been added before.
Definition: protocol.h:85
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
Definition: protocol.h:69
@ RPC_WALLET_PASSPHRASE_INCORRECT
The wallet passphrase entered was incorrect.
Definition: protocol.h:100
@ RPC_INVALID_REQUEST
Standard JSON-RPC 2.0 errors.
Definition: protocol.h:52
@ RPC_VERIFY_REJECTED
Transaction or block was rejected by network rules.
Definition: protocol.h:71
@ RPC_CLIENT_NODE_CAPACITY_REACHED
Max number of outbound or block-relay connections already open.
Definition: protocol.h:89
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
Definition: protocol.h:65
@ RPC_CLIENT_P2P_DISABLED
No valid connection manager instance found.
Definition: protocol.h:88