diff --git a/common/json_helpers.c b/common/json_helpers.c index f82e4b8a0..8303b7798 100644 --- a/common/json_helpers.c +++ b/common/json_helpers.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -164,6 +163,18 @@ void json_add_short_channel_id(struct json_stream *response, short_channel_id_outnum(scid)); } +void json_add_short_channel_id_dir(struct json_stream *response, + const char *fieldname, + const struct short_channel_id_dir *scidd) +{ + json_add_member(response, fieldname, true, "%dx%dx%d/%d", + short_channel_id_blocknum(&scidd->scid), + short_channel_id_txnum(&scidd->scid), + short_channel_id_outnum(&scidd->scid), + scidd->dir + ); +} + void json_add_address(struct json_stream *response, const char *fieldname, const struct wireaddr *addr) { diff --git a/common/json_helpers.h b/common/json_helpers.h index 248344f20..ac28575aa 100644 --- a/common/json_helpers.h +++ b/common/json_helpers.h @@ -2,6 +2,7 @@ #ifndef LIGHTNING_COMMON_JSON_HELPERS_H #define LIGHTNING_COMMON_JSON_HELPERS_H #include "config.h" +#include #include #include #include @@ -92,6 +93,11 @@ void json_add_short_channel_id(struct json_stream *response, const char *fieldname, const struct short_channel_id *id); +/* '"fieldname" : "1234:5:6/7"' */ +void json_add_short_channel_id_dir(struct json_stream *response, + const char *fieldname, + const struct short_channel_id_dir *id); + /* JSON serialize a network address for a node */ void json_add_address(struct json_stream *response, const char *fieldname, const struct wireaddr *addr);