jsonrpc: make error codes an enum.

This allows GDB to print values, but also allows us to use them in
'case' statements.  This wasn't allowed before because they're not
constant terms.

This also made it clear there's a clash between two error codes,
so move one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: Error code from bcli plugin changed from 400 to 500.
This commit is contained in:
Rusty Russell 2022-09-18 09:50:50 +09:30
parent 7fa1364645
commit 2da5244e83
31 changed files with 152 additions and 152 deletions

View file

@ -5,10 +5,6 @@
#include <ccan/short_types/short_types.h>
typedef s32 errcode_t;
#define PRIerrcode PRId32
// Setup errors
#define EXITCODE_SUBDAEMON_FAIL 10
#define EXITCODE_PIDFILE_LOCK 11

View file

@ -11,7 +11,7 @@ struct command;
struct command_result;
/* Caller supplied this: param assumes it can call it. */
struct command_result *command_fail(struct command *cmd, errcode_t code,
struct command_result *command_fail(struct command *cmd, enum jsonrpc_errcode code,
const char *fmt, ...)
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT RETURNS_NONNULL;

View file

@ -134,7 +134,8 @@ bool json_to_int(const char *buffer, const jsmntok_t *tok, int *num)
return true;
}
bool json_to_errcode(const char *buffer, const jsmntok_t *tok, errcode_t *errcode)
bool json_to_jsonrpc_errcode(const char *buffer, const jsmntok_t *tok,
enum jsonrpc_errcode *errcode)
{
s64 tmp;

View file

@ -6,6 +6,7 @@
#include <common/errcode.h>
/* Simple helpers are here: this file contains heavier ones */
#include <common/json_parse_simple.h>
#include <common/jsonrpc_errors.h>
struct json_escape;
struct json_stream;
@ -49,7 +50,8 @@ bool json_to_millionths(const char *buffer, const jsmntok_t *tok,
bool json_to_int(const char *buffer, const jsmntok_t *tok, int *num);
/* Extract an error code from this (may be a string, or a number literal) */
bool json_to_errcode(const char *buffer, const jsmntok_t *tok, errcode_t *errcode);
bool json_to_jsonrpc_errcode(const char *buffer, const jsmntok_t *tok,
enum jsonrpc_errcode *errcode);
/* Split a json token into 2 tokens given a splitting character */
bool split_tok(const char *buffer, const jsmntok_t *tok,

View file

@ -377,10 +377,10 @@ void json_add_tok(struct json_stream *result, const char *fieldname,
memcpy(space, json_tok_full(buffer, tok), json_tok_full_len(tok));
}
void json_add_errcode(struct json_stream *result, const char *fieldname,
errcode_t code)
void json_add_jsonrpc_errcode(struct json_stream *result, const char *fieldname,
enum jsonrpc_errcode code)
{
json_add_primitive_fmt(result, fieldname, "%" PRIerrcode, code);
json_add_primitive_fmt(result, fieldname, "%i", code);
}
void json_add_invstring(struct json_stream *result, const char *invstring)

View file

@ -12,7 +12,7 @@
#include <ccan/tal/tal.h>
#include <ccan/time/time.h>
#include <common/amount.h>
#include <common/errcode.h>
#include <common/jsonrpc_errors.h>
struct command;
struct io_conn;
@ -260,8 +260,8 @@ void json_add_tok(struct json_stream *result, const char *fieldname,
const jsmntok_t *tok, const char *buffer);
/* Add an error code */
void json_add_errcode(struct json_stream *result, const char *fieldname,
errcode_t code);
void json_add_jsonrpc_errcode(struct json_stream *result, const char *fieldname,
enum jsonrpc_errcode code);
/* Add "bolt11" or "bolt12" field, depending on invstring. */
void json_add_invstring(struct json_stream *result, const char *invstring);

View file

@ -8,102 +8,104 @@
#include <common/errcode.h>
/* Standard errors defined by JSON-RPC 2.0 standard */
static const errcode_t JSONRPC2_INVALID_REQUEST = -32600;
static const errcode_t JSONRPC2_METHOD_NOT_FOUND = -32601;
static const errcode_t JSONRPC2_INVALID_PARAMS = -32602;
enum jsonrpc_errcode {
/* Standard errors defined by JSON-RPC 2.0 standard */
JSONRPC2_INVALID_REQUEST = -32600,
JSONRPC2_METHOD_NOT_FOUND = -32601,
JSONRPC2_INVALID_PARAMS = -32602,
/* Uncategorized error.
* FIXME: This should be replaced in all places
* with a specific error code, and then removed.
*/
static const errcode_t LIGHTNINGD = -1;
/* Uncategorized error.
* FIXME: This should be replaced in all places
* with a specific error code, and then removed.
*/
LIGHTNINGD = -1,
/* Developer error in the parameters to param() call */
static const errcode_t PARAM_DEV_ERROR = -2;
/* Developer error in the parameters to param() call */
PARAM_DEV_ERROR = -2,
/* Plugin returned an error */
static const errcode_t PLUGIN_ERROR = -3;
/* Plugin returned an error */
PLUGIN_ERROR = -3,
/* Plugin terminated while handling a request. */
static const errcode_t PLUGIN_TERMINATED = -4;
/* Plugin terminated while handling a request. */
PLUGIN_TERMINATED = -4,
/* Lightningd is shutting down while handling a request. */
static const errcode_t LIGHTNINGD_SHUTDOWN = -5;
/* Lightningd is shutting down while handling a request. */
LIGHTNINGD_SHUTDOWN = -5,
/* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
static const errcode_t PAY_IN_PROGRESS = 200;
static const errcode_t PAY_RHASH_ALREADY_USED = 201;
static const errcode_t PAY_UNPARSEABLE_ONION = 202;
static const errcode_t PAY_DESTINATION_PERM_FAIL = 203;
static const errcode_t PAY_TRY_OTHER_ROUTE = 204;
static const errcode_t PAY_ROUTE_NOT_FOUND = 205;
static const errcode_t PAY_ROUTE_TOO_EXPENSIVE = 206;
static const errcode_t PAY_INVOICE_EXPIRED = 207;
static const errcode_t PAY_NO_SUCH_PAYMENT = 208;
static const errcode_t PAY_UNSPECIFIED_ERROR = 209;
static const errcode_t PAY_STOPPED_RETRYING = 210;
static const errcode_t PAY_STATUS_UNEXPECTED = 211;
static const errcode_t PAY_OFFER_INVALID = 212;
/* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
PAY_IN_PROGRESS = 200,
PAY_RHASH_ALREADY_USED = 201,
PAY_UNPARSEABLE_ONION = 202,
PAY_DESTINATION_PERM_FAIL = 203,
PAY_TRY_OTHER_ROUTE = 204,
PAY_ROUTE_NOT_FOUND = 205,
PAY_ROUTE_TOO_EXPENSIVE = 206,
PAY_INVOICE_EXPIRED = 207,
PAY_NO_SUCH_PAYMENT = 208,
PAY_UNSPECIFIED_ERROR = 209,
PAY_STOPPED_RETRYING = 210,
PAY_STATUS_UNEXPECTED = 211,
PAY_OFFER_INVALID = 212,
/* `fundchannel` or `withdraw` errors */
static const errcode_t FUND_MAX_EXCEEDED = 300;
static const errcode_t FUND_CANNOT_AFFORD = 301;
static const errcode_t FUND_OUTPUT_IS_DUST = 302;
static const errcode_t FUNDING_BROADCAST_FAIL = 303;
static const errcode_t FUNDING_STILL_SYNCING_BITCOIN = 304;
static const errcode_t FUNDING_PEER_NOT_CONNECTED = 305;
static const errcode_t FUNDING_UNKNOWN_PEER = 306;
static const errcode_t FUNDING_NOTHING_TO_CANCEL = 307;
static const errcode_t FUNDING_CANCEL_NOT_SAFE = 308;
static const errcode_t FUNDING_PSBT_INVALID = 309;
static const errcode_t FUNDING_V2_NOT_SUPPORTED = 310;
static const errcode_t FUNDING_UNKNOWN_CHANNEL = 311;
static const errcode_t FUNDING_STATE_INVALID = 312;
/* `fundchannel` or `withdraw` errors */
FUND_MAX_EXCEEDED = 300,
FUND_CANNOT_AFFORD = 301,
FUND_OUTPUT_IS_DUST = 302,
FUNDING_BROADCAST_FAIL = 303,
FUNDING_STILL_SYNCING_BITCOIN = 304,
FUNDING_PEER_NOT_CONNECTED = 305,
FUNDING_UNKNOWN_PEER = 306,
FUNDING_NOTHING_TO_CANCEL = 307,
FUNDING_CANCEL_NOT_SAFE = 308,
FUNDING_PSBT_INVALID = 309,
FUNDING_V2_NOT_SUPPORTED = 310,
FUNDING_UNKNOWN_CHANNEL = 311,
FUNDING_STATE_INVALID = 312,
/* `connect` errors */
static const errcode_t CONNECT_NO_KNOWN_ADDRESS = 400;
static const errcode_t CONNECT_ALL_ADDRESSES_FAILED = 401;
static const errcode_t CONNECT_DISCONNECTED_DURING = 402;
/* `connect` errors */
CONNECT_NO_KNOWN_ADDRESS = 400,
CONNECT_ALL_ADDRESSES_FAILED = 401,
CONNECT_DISCONNECTED_DURING = 402,
/* bitcoin-cli plugin errors */
#define BCLI_ERROR 400
/* bitcoin-cli plugin errors */
BCLI_ERROR = 500,
/* Errors from `invoice` or `delinvoice` commands */
static const errcode_t INVOICE_LABEL_ALREADY_EXISTS = 900;
static const errcode_t INVOICE_PREIMAGE_ALREADY_EXISTS = 901;
static const errcode_t INVOICE_HINTS_GAVE_NO_ROUTES = 902;
static const errcode_t INVOICE_EXPIRED_DURING_WAIT = 903;
static const errcode_t INVOICE_WAIT_TIMED_OUT = 904;
static const errcode_t INVOICE_NOT_FOUND = 905;
static const errcode_t INVOICE_STATUS_UNEXPECTED = 906;
static const errcode_t INVOICE_OFFER_INACTIVE = 907;
static const errcode_t INVOICE_NO_DESCRIPTION = 908;
/* Errors from `invoice` or `delinvoice` commands */
INVOICE_LABEL_ALREADY_EXISTS = 900,
INVOICE_PREIMAGE_ALREADY_EXISTS = 901,
INVOICE_HINTS_GAVE_NO_ROUTES = 902,
INVOICE_EXPIRED_DURING_WAIT = 903,
INVOICE_WAIT_TIMED_OUT = 904,
INVOICE_NOT_FOUND = 905,
INVOICE_STATUS_UNEXPECTED = 906,
INVOICE_OFFER_INACTIVE = 907,
INVOICE_NO_DESCRIPTION = 908,
/* Errors from HSM crypto operations. */
static const errcode_t HSM_ECDH_FAILED = 800;
/* Errors from HSM crypto operations. */
HSM_ECDH_FAILED = 800,
/* Errors from `offer` commands */
static const errcode_t OFFER_ALREADY_EXISTS = 1000;
static const errcode_t OFFER_ALREADY_DISABLED = 1001;
static const errcode_t OFFER_EXPIRED = 1002;
static const errcode_t OFFER_ROUTE_NOT_FOUND = 1003;
static const errcode_t OFFER_BAD_INVREQ_REPLY = 1004;
static const errcode_t OFFER_TIMEOUT = 1005;
/* Errors from `offer` commands */
OFFER_ALREADY_EXISTS = 1000,
OFFER_ALREADY_DISABLED = 1001,
OFFER_EXPIRED = 1002,
OFFER_ROUTE_NOT_FOUND = 1003,
OFFER_BAD_INVREQ_REPLY = 1004,
OFFER_TIMEOUT = 1005,
/* Errors from datastore command */
static const errcode_t DATASTORE_DEL_DOES_NOT_EXIST = 1200;
static const errcode_t DATASTORE_DEL_WRONG_GENERATION = 1201;
static const errcode_t DATASTORE_UPDATE_ALREADY_EXISTS = 1202;
static const errcode_t DATASTORE_UPDATE_DOES_NOT_EXIST = 1203;
static const errcode_t DATASTORE_UPDATE_WRONG_GENERATION = 1204;
static const errcode_t DATASTORE_UPDATE_HAS_CHILDREN = 1205;
static const errcode_t DATASTORE_UPDATE_NO_CHILDREN = 1206;
/* Errors from datastore command */
DATASTORE_DEL_DOES_NOT_EXIST = 1200,
DATASTORE_DEL_WRONG_GENERATION = 1201,
DATASTORE_UPDATE_ALREADY_EXISTS = 1202,
DATASTORE_UPDATE_DOES_NOT_EXIST = 1203,
DATASTORE_UPDATE_WRONG_GENERATION = 1204,
DATASTORE_UPDATE_HAS_CHILDREN = 1205,
DATASTORE_UPDATE_NO_CHILDREN = 1206,
/* Errors from signmessage command */
static const errcode_t SIGNMESSAGE_PUBKEY_NOT_FOUND = 1301;
/* Errors from signmessage command */
SIGNMESSAGE_PUBKEY_NOT_FOUND = 1301,
/* Errors from wait* commands */
static const errcode_t WAIT_TIMEOUT = 2000;
/* Errors from wait* commands */
WAIT_TIMEOUT = 2000,
};
#endif /* LIGHTNING_COMMON_JSONRPC_ERRORS_H */

View file

@ -42,7 +42,7 @@ struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
bool command_check_only(const struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_check_only called!\n"); abort(); }
/* Generated stub for command_fail */
struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED,
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_fail called!\n"); abort(); }

View file

@ -24,7 +24,7 @@ struct command_result {
static struct command_result cmd_failed;
struct command_result *command_fail(struct command *cmd,
errcode_t code, const char *fmt, ...)
enum jsonrpc_errcode code, const char *fmt, ...)
{
failed = true;
va_list ap;

View file

@ -614,14 +614,14 @@ struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect)
static void connect_failed(struct daemon *daemon,
const struct node_id *id,
const struct wireaddr_internal *addrhint,
errcode_t errcode,
enum jsonrpc_errcode errcode,
const char *errfmt, ...)
PRINTF_FMT(5,6);
static void connect_failed(struct daemon *daemon,
const struct node_id *id,
const struct wireaddr_internal *addrhint,
errcode_t errcode,
enum jsonrpc_errcode errcode,
const char *errfmt, ...)
{
u8 *msg;

View file

@ -54,7 +54,7 @@ msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal,
# Connectd->master: connect failed.
msgtype,connectd_connect_failed,2020
msgdata,connectd_connect_failed,id,node_id,
msgdata,connectd_connect_failed,failcode,errcode_t,
msgdata,connectd_connect_failed,failcode,enum jsonrpc_errcode,
msgdata,connectd_connect_failed,failreason,wirestring,
msgdata,connectd_connect_failed,addrhint,?wireaddr_internal,

1 #include <bitcoin/block.h>
54 # Connectd -> master: we got a peer.
55 msgtype,connectd_peer_connected,2002
56 msgdata,connectd_peer_connected,id,node_id,
57 msgdata,connectd_peer_connected,counter,u64,
58 msgdata,connectd_peer_connected,addr,wireaddr_internal,
59 msgdata,connectd_peer_connected,remote_addr,?wireaddr,
60 msgdata,connectd_peer_connected,incoming,bool,

View file

@ -357,7 +357,7 @@ void try_reconnect(const tal_t *ctx,
/* We were trying to connect, but they disconnected. */
static void connect_failed(struct lightningd *ld,
const struct node_id *id,
errcode_t errcode,
enum jsonrpc_errcode errcode,
const char *errmsg,
const struct wireaddr_internal *addrhint)
{
@ -390,7 +390,7 @@ void connect_failed_disconnect(struct lightningd *ld,
static void handle_connect_failed(struct lightningd *ld, const u8 *msg)
{
struct node_id id;
errcode_t errcode;
enum jsonrpc_errcode errcode;
char *errmsg;
struct wireaddr_internal *addrhint;

View file

@ -475,7 +475,7 @@ struct command_result *command_failed(struct command *cmd,
return command_raw_complete(cmd, result);
}
struct command_result *command_fail(struct command *cmd, errcode_t code,
struct command_result *command_fail(struct command *cmd, enum jsonrpc_errcode code,
const char *fmt, ...)
{
const char *errmsg;
@ -513,7 +513,7 @@ static void json_command_malformed(struct json_connection *jcon,
json_add_string(js, "jsonrpc", "2.0");
json_add_primitive(js, "id", id);
json_object_start(js, "error");
json_add_errcode(js, "code", JSONRPC2_INVALID_REQUEST);
json_add_jsonrpc_errcode(js, "code", JSONRPC2_INVALID_REQUEST);
json_add_string(js, "message", error);
json_object_end(js);
json_object_end(js);
@ -601,7 +601,7 @@ struct json_stream *json_stream_success(struct command *cmd)
}
struct json_stream *json_stream_fail_nodata(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg)
{
struct json_stream *js = json_start(cmd);
@ -609,14 +609,14 @@ struct json_stream *json_stream_fail_nodata(struct command *cmd,
assert(code);
json_object_start(js, "error");
json_add_errcode(js, "code", code);
json_add_jsonrpc_errcode(js, "code", code);
json_add_string(js, "message", errmsg);
return js;
}
struct json_stream *json_stream_fail(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg)
{
struct json_stream *r = json_stream_fail_nodata(cmd, code, errmsg);
@ -824,11 +824,11 @@ rpc_command_hook_callback(struct rpc_command_hook_payload *p,
custom_return = json_get_member(buffer, tok, "error");
if (custom_return) {
errcode_t code;
enum jsonrpc_errcode code;
const char *errmsg;
if (!json_to_errcode(buffer,
json_get_member(buffer, custom_return, "code"),
&code)) {
if (!json_to_jsonrpc_errcode(buffer,
json_get_member(buffer, custom_return, "code"),
&code)) {
error = "'error' object does not contain a code.";
goto log_error_and_skip;
}

View file

@ -103,7 +103,7 @@ struct json_stream *json_stream_success(struct command *cmd);
* You need to json_object_end() once you're done!
*/
struct json_stream *json_stream_fail(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg);
/**
@ -115,7 +115,7 @@ struct json_stream *json_stream_fail(struct command *cmd,
* This is used by command_fail(), which doesn't add any JSON data.
*/
struct json_stream *json_stream_fail_nodata(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg);
/* These returned values are never NULL. */

View file

@ -392,7 +392,7 @@ void notify_sendpay_success(struct lightningd *ld,
static void sendpay_failure_notification_serialize(struct json_stream *stream,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail,
char *errmsg)
@ -401,7 +401,7 @@ static void sendpay_failure_notification_serialize(struct json_stream *stream,
/* In line with the format of json error returned
* by sendpay_fail(). */
json_add_errcode(stream, "code", pay_errcode);
json_add_jsonrpc_errcode(stream, "code", pay_errcode);
json_add_string(stream, "message", errmsg);
json_object_start(stream, "data");
@ -420,14 +420,14 @@ REGISTER_NOTIFICATION(sendpay_failure,
void notify_sendpay_failure(struct lightningd *ld,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail,
const char *errmsg)
{
void (*serialize)(struct json_stream *,
const struct wallet_payment *,
errcode_t,
enum jsonrpc_errcode,
const struct onionreply *,
const struct routing_failure *,
const char *) = sendpay_failure_notification_gen.serialize;

View file

@ -76,7 +76,7 @@ void notify_sendpay_success(struct lightningd *ld,
void notify_sendpay_failure(struct lightningd *ld,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail,
const char *errmsg);

View file

@ -205,7 +205,7 @@ json_add_routefail_info(struct json_stream *js,
void json_sendpay_fail_fields(struct json_stream *js,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail)
{
@ -224,7 +224,7 @@ void json_sendpay_fail_fields(struct json_stream *js,
fail->msg);
}
static const char *sendpay_errmsg_fmt(const tal_t *ctx, errcode_t pay_errcode,
static const char *sendpay_errmsg_fmt(const tal_t *ctx, enum jsonrpc_errcode pay_errcode,
const struct routing_failure *fail,
const char *details)
{
@ -243,7 +243,7 @@ static const char *sendpay_errmsg_fmt(const tal_t *ctx, errcode_t pay_errcode,
static struct command_result *
sendpay_fail(struct command *cmd,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail,
const char *errmsg)
@ -276,7 +276,7 @@ json_sendpay_in_progress(struct command *cmd,
static void tell_waiters_failed(struct lightningd *ld,
const struct sha256 *payment_hash,
const struct wallet_payment *payment,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail,
const char *details)
@ -417,7 +417,7 @@ remote_routing_failure(const tal_t *ctx,
const u8 *failuremsg,
int origin_index,
struct log *log,
errcode_t *pay_errcode)
enum jsonrpc_errcode *pay_errcode)
{
enum onion_wire failcode = fromwire_peektype(failuremsg);
struct routing_failure *routing_failure;
@ -541,7 +541,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
struct wallet_payment *payment;
struct routing_failure* fail = NULL;
const char *failstr;
errcode_t pay_errcode;
enum jsonrpc_errcode pay_errcode;
const u8 *failmsg;
int origin_index;
@ -670,7 +670,7 @@ static struct command_result *wait_payment(struct lightningd *ld,
char *faildetail;
struct routing_failure *fail;
int faildirection;
errcode_t rpcerrorcode;
enum jsonrpc_errcode rpcerrorcode;
payment = wallet_payment_by_hash(tmpctx, ld->wallet,
payment_hash, partid, groupid);

View file

@ -29,7 +29,7 @@ void json_add_payment_fields(struct json_stream *response,
/* This json will be also used in 'sendpay_failure' notifictaion. */
void json_sendpay_fail_fields(struct json_stream *js,
const struct wallet_payment *t,
errcode_t pay_errcode,
enum jsonrpc_errcode pay_errcode,
const struct onionreply *onionreply,
const struct routing_failure *fail);

View file

@ -124,7 +124,7 @@ void channel_update_reserve(struct channel *channel UNNEEDED,
struct amount_sat funding_total UNNEEDED)
{ fprintf(stderr, "channel_update_reserve called!\n"); abort(); }
/* Generated stub for command_fail */
struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED,
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_fail called!\n"); abort(); }
@ -455,7 +455,7 @@ const char *json_scan(const tal_t *ctx UNNEEDED,
{ fprintf(stderr, "json_scan called!\n"); abort(); }
/* Generated stub for json_stream_fail */
struct json_stream *json_stream_fail(struct command *cmd UNNEEDED,
errcode_t code UNNEEDED,
enum jsonrpc_errcode code UNNEEDED,
const char *errmsg UNNEEDED)
{ fprintf(stderr, "json_stream_fail called!\n"); abort(); }
/* Generated stub for json_stream_success */

View file

@ -27,9 +27,10 @@ bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
/* Generated stub for fromwire_node_id */
void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED)
{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); }
/* Generated stub for json_to_errcode */
bool json_to_errcode(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, errcode_t *errcode UNNEEDED)
{ fprintf(stderr, "json_to_errcode called!\n"); abort(); }
/* Generated stub for json_to_jsonrpc_errcode */
bool json_to_jsonrpc_errcode(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
enum jsonrpc_errcode *errcode UNNEEDED)
{ fprintf(stderr, "json_to_jsonrpc_errcode called!\n"); abort(); }
/* Generated stub for json_to_number */
bool json_to_number(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
unsigned int *num UNNEEDED)

View file

@ -4,7 +4,7 @@
/* AUTOGENERATED MOCKS START */
/* Generated stub for command_fail */
struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED,
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_fail called!\n"); abort(); }

View file

@ -389,14 +389,14 @@ command_success(struct command *cmd, const struct json_out *result)
}
struct command_result *command_done_err(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg,
const struct json_out *data)
{
struct json_stream *js = jsonrpc_stream_start(cmd);
json_object_start(js, "error");
json_add_errcode(js, "code", code);
json_add_jsonrpc_errcode(js, "code", code);
json_add_string(js, "message", errmsg);
if (data)
@ -442,7 +442,7 @@ struct command_result *forward_result(struct command *cmd,
/* Called by param() directly if it's malformed. */
struct command_result *command_fail(struct command *cmd,
errcode_t code, const char *fmt, ...)
enum jsonrpc_errcode code, const char *fmt, ...)
{
va_list ap;
struct command_result *res;

View file

@ -239,7 +239,7 @@ void NORETURN plugin_exit(struct plugin *p, int exitcode);
* NULL, data can be NULL; otherwise it must be a JSON object. */
struct command_result *WARN_UNUSED_RESULT
command_done_err(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg,
const struct json_out *data);

View file

@ -69,7 +69,7 @@ void fail_destination_tok(struct multifundchannel_destination *dest,
}
void fail_destination_msg(struct multifundchannel_destination *dest,
errcode_t error_code,
enum jsonrpc_errcode error_code,
const char *err_str TAKES)
{
dest->error_code = error_code;
@ -333,7 +333,7 @@ mfc_cleanup_(struct multifundchannel_command *mfc,
struct mfc_fail_object {
struct multifundchannel_command *mfc;
struct command *cmd;
errcode_t code;
enum jsonrpc_errcode code;
const char *msg;
};
@ -347,7 +347,7 @@ mfc_fail_complete(struct mfc_fail_object *obj)
/* Use this instead of command_fail. */
static struct command_result *
mfc_fail(struct multifundchannel_command *mfc, errcode_t code,
mfc_fail(struct multifundchannel_command *mfc, enum jsonrpc_errcode code,
const char *fmt, ...)
{
struct mfc_fail_object *obj;

View file

@ -56,7 +56,7 @@ struct multifundchannel_removed {
*/
const char *method;
const char *error_message;
errcode_t error_code;
enum jsonrpc_errcode error_code;
/* Optional JSON object containing extra data */
const char *error_data;
};
@ -128,7 +128,7 @@ struct multifundchannel_destination {
struct channel_id channel_id;
const char *error_message;
errcode_t error_code;
enum jsonrpc_errcode error_code;
/* Optional JSON object containing extra data */
const char *error_data;

View file

@ -288,7 +288,7 @@ mw_forward_error(struct command *cmd UNUSED,
}
/* Use this instead of command_fail. */
static struct command_result *
mw_fail(struct multiwithdraw_command *mw, errcode_t code,
mw_fail(struct multiwithdraw_command *mw, enum jsonrpc_errcode code,
const char *fmt, ...)
{
va_list ap;
@ -303,7 +303,7 @@ mw_fail(struct multiwithdraw_command *mw, errcode_t code,
js = new_json_stream(tmpctx, mw->cmd, NULL);
json_object_start(js, NULL);
json_add_errcode(js, "code", code);
json_add_jsonrpc_errcode(js, "code", code);
json_add_string(js, "message", message);
json_object_end(js);

View file

@ -194,7 +194,6 @@ class Type(FieldSet):
'bool',
'amount_sat',
'amount_msat',
'errcode_t',
'bigsize',
'varint'
]
@ -209,7 +208,6 @@ class Type(FieldSet):
'secp256k1_ecdsa_recoverable_signature',
'utf8',
'wirestring',
'errcode_t',
'bigsize',
'varint',
]

View file

@ -90,7 +90,7 @@ void channel_update_reserve(struct channel *channel UNNEEDED,
struct amount_sat funding_total UNNEEDED)
{ fprintf(stderr, "channel_update_reserve called!\n"); abort(); }
/* Generated stub for command_fail */
struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED,
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_fail called!\n"); abort(); }

View file

@ -151,9 +151,9 @@ bool fromwire_bool(const u8 **cursor, size_t *max)
return ret;
}
errcode_t fromwire_errcode_t(const u8 **cursor, size_t *max)
enum jsonrpc_errcode fromwire_jsonrpc_errcode(const u8 **cursor, size_t *max)
{
errcode_t ret;
enum jsonrpc_errcode ret;
ret = (s32)fromwire_u32(cursor, max);

View file

@ -77,7 +77,7 @@ void towire_bool(u8 **pptr, bool v)
towire(pptr, &val, sizeof(val));
}
void towire_errcode_t(u8 **pptr, errcode_t v)
void towire_jsonrpc_errcode(u8 **pptr, enum jsonrpc_errcode v)
{
towire_u32(pptr, (u32)v);
}

View file

@ -3,7 +3,7 @@
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <common/errcode.h>
#include <common/jsonrpc_errors.h>
#include <common/wireaddr.h>
#include <secp256k1_recovery.h>
#include <stdlib.h>
@ -36,7 +36,7 @@ void towire_tu32(u8 **pptr, u32 v);
void towire_tu64(u8 **pptr, u64 v);
void towire_pad(u8 **pptr, size_t num);
void towire_bool(u8 **pptr, bool v);
void towire_errcode_t(u8 **pptr, errcode_t v);
void towire_jsonrpc_errcode(u8 **pptr, enum jsonrpc_errcode v);
void towire_u8_array(u8 **pptr, const u8 *arr, size_t num);
void towire_utf8_array(u8 **pptr, const char *arr, size_t num);
@ -53,7 +53,7 @@ u16 fromwire_tu16(const u8 **cursor, size_t *max);
u32 fromwire_tu32(const u8 **cursor, size_t *max);
u64 fromwire_tu64(const u8 **cursor, size_t *max);
bool fromwire_bool(const u8 **cursor, size_t *max);
errcode_t fromwire_errcode_t(const u8 **cursor, size_t *max);
enum jsonrpc_errcode fromwire_jsonrpc_errcode(const u8 **cursor, size_t *max);
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max,
secp256k1_ecdsa_signature *signature);
void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,