diff --git a/common/json.c b/common/json.c index 2f372044c..b3cb20490 100644 --- a/common/json.c +++ b/common/json.c @@ -762,3 +762,9 @@ void json_add_tok(struct json_stream *result, const char *fieldname, } abort(); } + +void json_add_errcode(struct json_stream *result, const char *fieldname, + errcode_t code) +{ + json_add_member(result, fieldname, false, "%"PRIerrcode, code); +} diff --git a/common/json.h b/common/json.h index 4ac74bdd9..056e79d41 100644 --- a/common/json.h +++ b/common/json.h @@ -264,5 +264,9 @@ void json_add_preimage(struct json_stream *result, const char *fieldname, 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); + #endif /* LIGHTNING_COMMON_JSON_H */