From e78c102dff7d1848788e1971df4a269606b16b9f Mon Sep 17 00:00:00 2001 From: Lagrang3 Date: Mon, 23 Sep 2024 10:18:27 +0100 Subject: [PATCH] Add json API for struct route_exclusion To be able to write a route_exclusion to a json stream. Changelog-None. Signed-off-by: Lagrang3 --- common/json_stream.c | 12 ++++++++++++ common/json_stream.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/common/json_stream.c b/common/json_stream.c index 31a5367b15e4..81ff9ff6c33c 100644 --- a/common/json_stream.c +++ b/common/json_stream.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -494,6 +495,17 @@ void json_add_short_channel_id_dir(struct json_stream *response, short_channel_id_outnum(scidd.scid), scidd.dir); } +void json_add_route_exclusion(struct json_stream *response, + const char *fieldname, + const struct route_exclusion *ex) +{ + if (ex->type == EXCLUDE_NODE) + json_add_node_id(response, fieldname, &ex->u.node_id); + else + json_add_short_channel_id_dir(response, fieldname, + ex->u.chan_id); +} + static void json_add_address_fields(struct json_stream *response, const struct wireaddr *addr, const char *typefield) diff --git a/common/json_stream.h b/common/json_stream.h index eeca272c3e09..1962de0c4634 100644 --- a/common/json_stream.h +++ b/common/json_stream.h @@ -36,6 +36,7 @@ struct wally_psbt; struct lease_rates; struct wireaddr; struct wireaddr_internal; +struct route_exclusion; struct json_stream { struct json_out *jout; @@ -301,6 +302,12 @@ void json_add_channel_id(struct json_stream *response, const char *fieldname, const struct channel_id *cid); +/* '"fieldname" : ' or "" if fieldname is NULL, where is + * either a node_id or a short_channel_id_dir. */ +void json_add_route_exclusion(struct json_stream *response, + const char *fieldname, + const struct route_exclusion *ex); + /* '"fieldname" : ' or "" if fieldname is NULL */ void json_add_txid(struct json_stream *result, const char *fieldname, const struct bitcoin_txid *txid);