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