bitcoin_remote/error_code.rs
1crate::ix!();
2
3//-------------------------------------------[.cpp/bitcoin/src/rpc/protocol.h]
4
5/**
6 | HTTP status codes
7 |
8 */
9#[repr(i32)]
10pub enum HTTPStatusCode
11{
12 HTTP_OK = 200,
13 HTTP_BAD_REQUEST = 400,
14 HTTP_UNAUTHORIZED = 401,
15 HTTP_FORBIDDEN = 403,
16 HTTP_NOT_FOUND = 404,
17 HTTP_BAD_METHOD = 405,
18 HTTP_INTERNAL_SERVER_ERROR = 500,
19 HTTP_SERVICE_UNAVAILABLE = 503,
20}
21
22/**
23 | Bitcoin RPC error codes
24 |
25 */
26bitflags! {
27
28 pub struct RPCErrorCode: i32 {
29
30 /* --------- Standard JSON-RPC 2.0 errors --------- */
31
32 /*
33 | RPC_INVALID_REQUEST is internally mapped to
34 | HTTP_BAD_REQUEST (400).
35 |
36 | It should not be used for application-layer
37 | errors.
38 */
39 const RPC_INVALID_REQUEST = -32600;
40
41 /*
42 | RPC_METHOD_NOT_FOUND is internally mapped
43 | to HTTP_NOT_FOUND (404).
44 |
45 | It should not be used for application-layer
46 | errors.
47 */
48 const RPC_METHOD_NOT_FOUND = -32601;
49 const RPC_INVALID_PARAMS = -32602;
50
51 /*
52 | RPC_INTERNAL_ERROR should only be
53 | used for genuine errors in bitcoind
54 | (for example datadir corruption).
55 |
56 */
57 const RPC_INTERNAL_ERROR = -32603;
58 const RPC_PARSE_ERROR = -32700;
59
60 /* ------ General application defined errors ------ */
61
62 /*
63 | std::exception thrown in command handling
64 |
65 */
66 const RPC_MISC_ERROR = -1;
67
68 /*
69 | Unexpected type was passed as parameter
70 |
71 */
72 const RPC_TYPE_ERROR = -3;
73
74 /*
75 | Invalid address or key
76 |
77 */
78 const RPC_INVALID_ADDRESS_OR_KEY = -5;
79
80 /*
81 | Ran out of memory during operation
82 |
83 */
84 const RPC_OUT_OF_MEMORY = -7;
85
86 /*
87 | Invalid, missing or duplicate parameter
88 |
89 */
90 const RPC_INVALID_PARAMETER = -8;
91
92 /*
93 | Database error
94 |
95 */
96 const RPC_DATABASE_ERROR = -20;
97
98 /*
99 | Error parsing or validating structure
100 | in raw format
101 |
102 */
103 const RPC_DESERIALIZATION_ERROR = -22;
104
105 /*
106 | General error during transaction or
107 | block submission
108 |
109 */
110 const RPC_VERIFY_ERROR = -25;
111
112 /*
113 | Transaction or block was rejected by
114 | network rules
115 |
116 */
117 const RPC_VERIFY_REJECTED = -26;
118
119 /*
120 | Transaction already in chain
121 |
122 */
123 const RPC_VERIFY_ALREADY_IN_CHAIN = -27;
124
125 /*
126 | Client still warming up
127 |
128 */
129 const RPC_IN_WARMUP = -28;
130
131 /*
132 | RPC method is deprecated
133 |
134 */
135 const RPC_METHOD_DEPRECATED = -32;
136
137
138 /* ------ Aliases for backward compatibility ------ */
139 const RPC_TRANSACTION_ERROR = Self::RPC_VERIFY_ERROR.bits;
140 const RPC_TRANSACTION_REJECTED = Self::RPC_VERIFY_REJECTED.bits;
141 const RPC_TRANSACTION_ALREADY_IN_CHAIN= Self::RPC_VERIFY_ALREADY_IN_CHAIN.bits;
142
143 /* --------------- P2P client errors --------------- */
144
145 /*
146 | Bitcoin is not connected
147 |
148 */
149 const RPC_CLIENT_NOT_CONNECTED = -9;
150
151 /*
152 | Still downloading initial blocks
153 |
154 */
155 const RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10;
156
157 /*
158 | Node is already added
159 |
160 */
161 const RPC_CLIENT_NODE_ALREADY_ADDED = -23;
162
163 /*
164 | Node has not been added before
165 |
166 */
167 const RPC_CLIENT_NODE_NOT_ADDED = -24;
168
169 /*
170 | Node to disconnect not found in connected
171 | nodes
172 |
173 */
174 const RPC_CLIENT_NODE_NOT_CONNECTED = -29;
175
176 /*
177 | Invalid IP/Subnet
178 |
179 */
180 const RPC_CLIENT_INVALID_IP_OR_SUBNET = -30;
181
182 /*
183 | No valid connection manager instance
184 | found
185 |
186 */
187 const RPC_CLIENT_P2P_DISABLED = -31;
188
189 /*
190 | Max number of outbound or block-relay
191 | connections already open
192 |
193 */
194 const RPC_CLIENT_NODE_CAPACITY_REACHED= -34;
195
196 /* ----------------- Chain errors ----------------- */
197
198 /*
199 | No mempool instance found
200 |
201 */
202 const RPC_CLIENT_MEMPOOL_DISABLED = -33;
203
204 /* ----------------- Wallet errors ----------------- */
205
206 /*
207 | Unspecified problem with wallet (key
208 | not found etc.)
209 |
210 */
211 const RPC_WALLET_ERROR = -4;
212
213 /*
214 | Not enough funds in wallet or account
215 |
216 */
217 const RPC_WALLET_INSUFFICIENT_FUNDS = -6;
218
219 /*
220 | Invalid label name
221 |
222 */
223 const RPC_WALLET_INVALID_LABEL_NAME = -11;
224
225 /*
226 | Keypool ran out, call keypoolrefill
227 | first
228 |
229 */
230 const RPC_WALLET_KEYPOOL_RAN_OUT = -12;
231
232 /*
233 | Enter the wallet passphrase with walletpassphrase
234 | first
235 |
236 */
237 const RPC_WALLET_UNLOCK_NEEDED = -13;
238
239 /*
240 | The wallet passphrase entered was incorrect
241 |
242 */
243 const RPC_WALLET_PASSPHRASE_INCORRECT = -14;
244
245 /*
246 | Command given in wrong wallet encryption
247 | state (encrypting an encrypted wallet
248 | etc.)
249 |
250 */
251 const RPC_WALLET_WRONG_ENC_STATE = -15;
252
253 /*
254 | Failed to encrypt the wallet
255 |
256 */
257 const RPC_WALLET_ENCRYPTION_FAILED = -16;
258
259 /*
260 | Wallet is already unlocked
261 |
262 */
263 const RPC_WALLET_ALREADY_UNLOCKED = -17;
264
265 /*
266 | Invalid wallet specified
267 |
268 */
269 const RPC_WALLET_NOT_FOUND = -18;
270
271 /*
272 | No wallet specified (error when there
273 | are multiple wallets loaded)
274 |
275 */
276 const RPC_WALLET_NOT_SPECIFIED = -19;
277
278 /*
279 | This same wallet is already loaded
280 |
281 */
282 const RPC_WALLET_ALREADY_LOADED = -35;
283
284 /* --------- Backwards compatible aliases --------- */
285 const RPC_WALLET_INVALID_ACCOUNT_NAME = Self::RPC_WALLET_INVALID_LABEL_NAME.bits;
286
287 /*
288 | Unused reserved codes, kept around for
289 | backwards compatibility. Do not reuse.
290 */
291
292 /*
293 | Server is in safe mode, and command is
294 | not allowed in safe mode
295 |
296 */
297 const RPC_FORBIDDEN_BY_SAFE_MODE = -2;
298 }
299}