1 /* common/jsonrpc_errors.h
2  * Lists error codes for JSON-RPC.
3  */
4 #ifndef LIGHTNING_COMMON_JSONRPC_ERRORS_H
5 #define LIGHTNING_COMMON_JSONRPC_ERRORS_H
6 
7 #include "config.h"
8 
9 #include <common/errcode.h>
10 
11 /* Standard errors defined by JSON-RPC 2.0 standard */
12 static const errcode_t JSONRPC2_INVALID_REQUEST = -32600;
13 static const errcode_t JSONRPC2_METHOD_NOT_FOUND = -32601;
14 static const errcode_t JSONRPC2_INVALID_PARAMS = -32602;
15 
16 /* Uncategorized error.
17  * FIXME: This should be replaced in all places
18  * with a specific error code, and then removed.
19  */
20 static const errcode_t LIGHTNINGD = -1;
21 
22 /* Developer error in the parameters to param() call */
23 static const errcode_t PARAM_DEV_ERROR = -2;
24 
25 /* Plugin returned an error */
26 static const errcode_t PLUGIN_ERROR = -3;
27 
28 /* Plugin terminated while handling a request. */
29 static const errcode_t PLUGIN_TERMINATED = -4;
30 
31 /* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
32 static const errcode_t PAY_IN_PROGRESS = 200;
33 static const errcode_t PAY_RHASH_ALREADY_USED = 201;
34 static const errcode_t PAY_UNPARSEABLE_ONION = 202;
35 static const errcode_t PAY_DESTINATION_PERM_FAIL = 203;
36 static const errcode_t PAY_TRY_OTHER_ROUTE = 204;
37 static const errcode_t PAY_ROUTE_NOT_FOUND = 205;
38 static const errcode_t PAY_ROUTE_TOO_EXPENSIVE = 206;
39 static const errcode_t PAY_INVOICE_EXPIRED = 207;
40 static const errcode_t PAY_NO_SUCH_PAYMENT = 208;
41 static const errcode_t PAY_UNSPECIFIED_ERROR = 209;
42 static const errcode_t PAY_STOPPED_RETRYING = 210;
43 static const errcode_t PAY_STATUS_UNEXPECTED = 211;
44 static const errcode_t PAY_OFFER_INVALID = 212;
45 
46 /* `fundchannel` or `withdraw` errors */
47 static const errcode_t FUND_MAX_EXCEEDED = 300;
48 static const errcode_t FUND_CANNOT_AFFORD = 301;
49 static const errcode_t FUND_OUTPUT_IS_DUST = 302;
50 static const errcode_t FUNDING_BROADCAST_FAIL = 303;
51 static const errcode_t FUNDING_STILL_SYNCING_BITCOIN = 304;
52 static const errcode_t FUNDING_PEER_NOT_CONNECTED = 305;
53 static const errcode_t FUNDING_UNKNOWN_PEER = 306;
54 static const errcode_t FUNDING_NOTHING_TO_CANCEL = 307;
55 static const errcode_t FUNDING_CANCEL_NOT_SAFE = 308;
56 static const errcode_t FUNDING_PSBT_INVALID = 309;
57 static const errcode_t FUNDING_V2_NOT_SUPPORTED = 310;
58 static const errcode_t FUNDING_UNKNOWN_CHANNEL = 311;
59 static const errcode_t FUNDING_STATE_INVALID = 312;
60 
61 /* `connect` errors */
62 static const errcode_t CONNECT_NO_KNOWN_ADDRESS = 400;
63 static const errcode_t CONNECT_ALL_ADDRESSES_FAILED = 401;
64 
65 /* bitcoin-cli plugin errors */
66 #define BCLI_ERROR                      400
67 
68 /* Errors from `invoice` or `delinvoice` commands */
69 static const errcode_t INVOICE_LABEL_ALREADY_EXISTS = 900;
70 static const errcode_t INVOICE_PREIMAGE_ALREADY_EXISTS = 901;
71 static const errcode_t INVOICE_HINTS_GAVE_NO_ROUTES = 902;
72 static const errcode_t INVOICE_EXPIRED_DURING_WAIT = 903;
73 static const errcode_t INVOICE_WAIT_TIMED_OUT = 904;
74 static const errcode_t INVOICE_NOT_FOUND = 905;
75 static const errcode_t INVOICE_STATUS_UNEXPECTED = 906;
76 static const errcode_t INVOICE_OFFER_INACTIVE = 907;
77 
78 /* Errors from HSM crypto operations. */
79 static const errcode_t HSM_ECDH_FAILED = 800;
80 
81 /* Errors from `offer` commands */
82 static const errcode_t OFFER_ALREADY_EXISTS = 1000;
83 static const errcode_t OFFER_ALREADY_DISABLED = 1001;
84 static const errcode_t OFFER_EXPIRED = 1002;
85 static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003;
86 static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004;
87 static const errcode_t OFFER_TIMEOUT = 1005;
88 
89 /* Errors from datastore command */
90 static const errcode_t DATASTORE_DEL_DOES_NOT_EXIST = 1200;
91 static const errcode_t DATASTORE_DEL_WRONG_GENERATION = 1201;
92 static const errcode_t DATASTORE_UPDATE_ALREADY_EXISTS = 1202;
93 static const errcode_t DATASTORE_UPDATE_DOES_NOT_EXIST = 1203;
94 static const errcode_t DATASTORE_UPDATE_WRONG_GENERATION = 1204;
95 static const errcode_t DATASTORE_UPDATE_HAS_CHILDREN = 1205;
96 static const errcode_t DATASTORE_UPDATE_NO_CHILDREN = 1206;
97 
98 /* Errors from wait* commands */
99 static const errcode_t WAIT_TIMEOUT = 2000;
100 
101 #endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */
102