diff --git a/common/json_helpers.c b/common/json_helpers.c index 25737b01f..a304c534a 100644 --- a/common/json_helpers.c +++ b/common/json_helpers.c @@ -142,6 +142,13 @@ void json_add_node_id(struct json_stream *response, json_add_hex(response, fieldname, id->k, sizeof(id->k)); } +void json_add_channel_id(struct json_stream *response, + const char *fieldname, + const struct channel_id *cid) +{ + json_add_hex(response, fieldname, cid->id, sizeof(cid->id)); +} + void json_add_pubkey(struct json_stream *response, const char *fieldname, const struct pubkey *key) diff --git a/common/json_helpers.h b/common/json_helpers.h index 801e08ec3..22b5f66f3 100644 --- a/common/json_helpers.h +++ b/common/json_helpers.h @@ -89,6 +89,11 @@ void json_add_node_id(struct json_stream *response, const char *fieldname, const struct node_id *id); +/* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */ +void json_add_channel_id(struct json_stream *response, + const char *fieldname, + const struct channel_id *cid); + /* '"fieldname" : ' or "" if fieldname is NULL */ void json_add_txid(struct json_stream *result, const char *fieldname, const struct bitcoin_txid *txid); diff --git a/lightningd/notification.c b/lightningd/notification.c index e25ed2144..9d7f395c3 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -219,8 +219,7 @@ static void channel_state_changed_notification_serialize(struct json_stream *str { json_object_start(stream, "channel_state_changed"); json_add_node_id(stream, "peer_id", peer_id); - json_add_string(stream, "channel_id", - type_to_string(tmpctx, struct channel_id, cid)); + json_add_channel_id(stream, "channel_id", cid); if (scid) json_add_short_channel_id(stream, "short_channel_id", scid); else