From 4f17672001a474df448bade408beec64b2b76063 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 28 Feb 2025 11:59:32 +1030 Subject: [PATCH] lightningd: disable old notification fields. Signed-off-by: Rusty Russell Changelog-Removed: connection/disconnection/block_added notification raw fields (deprecated v23.08, disabled by default in v24.11). --- doc/developers-guide/deprecations.md | 3 - lightningd/notification.c | 89 +++++----------------------- 2 files changed, 16 insertions(+), 76 deletions(-) diff --git a/doc/developers-guide/deprecations.md b/doc/developers-guide/deprecations.md index 666a3f317..71c4ed257 100644 --- a/doc/developers-guide/deprecations.md +++ b/doc/developers-guide/deprecations.md @@ -7,9 +7,6 @@ hidden: false | Name | Type | First Deprecated | Last Supported | Description | |--------------------------------------|--------------------|------------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| connection_notification.rawfields | Notification Field | v23.08 | v24.08 | All notifications now wrap members in an object of the same name | -| disconnection_notification.rawfields | Notification Field | v23.08 | v24.08 | All notifications now wrap members in an object of the same name | -| block_added_notification.block | Notification Field | v23.08 | v24.08 | All notifications now wrap members in an object of the same name | | accept-htlc-tlv-types | Config | v23.08 | v24.08 | New `accept-htlc-tlv-type` can be specified multiple times, which is cleaner | | bind-addr.torv3 | Config | v23.08 | v24.08 | `announce-addr` makes more sense for Tor addresses | | addr.torv3 | Config | v23.08 | v24.08 | `announce-addr` makes more sense for Tor addresses | diff --git a/lightningd/notification.c b/lightningd/notification.c index 83ce9c3eb..ee4802d8c 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -55,33 +55,15 @@ static void notify_send(struct lightningd *ld, plugins_notify(ld->plugins, take(n)); } -static void json_add_connect_fields(struct json_stream *stream, - const struct node_id *nodeid, - bool incoming, - const struct wireaddr_internal *addr) +static void connect_notification_serialize(struct json_stream *stream, + const struct node_id *nodeid, + bool incoming, + const struct wireaddr_internal *addr) { json_add_node_id(stream, "id", nodeid); json_add_string(stream, "direction", incoming ? "in" : "out"); json_add_address_internal(stream, "address", addr); } - -static void connect_notification_serialize(struct json_stream *stream, - struct lightningd *ld, - const struct node_id *nodeid, - bool incoming, - const struct wireaddr_internal *addr) -{ - /* Old style: Add raw fields without connect key */ - if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok, - "connect_notification", "rawfields", - "v23.08", "v24.08")) { - json_add_connect_fields(stream, nodeid, incoming, addr); - } - json_object_start(stream, "connect"); - json_add_connect_fields(stream, nodeid, incoming, addr); - json_object_end(stream); -} - REGISTER_NOTIFICATION(connect); void notify_connect(struct lightningd *ld, @@ -89,43 +71,23 @@ void notify_connect(struct lightningd *ld, bool incoming, const struct wireaddr_internal *addr) { - struct jsonrpc_notification *n - = jsonrpc_notification_start(NULL, "connect"); - connect_notification_serialize(n->stream, ld, nodeid, incoming, addr); - jsonrpc_notification_end(n); - plugins_notify(ld->plugins, take(n)); -} - -static void json_add_disconnect_fields(struct json_stream *stream, - const struct node_id *nodeid) -{ - json_add_node_id(stream, "id", nodeid); + struct jsonrpc_notification *n = notify_start("connect"); + connect_notification_serialize(n->stream, nodeid, incoming, addr); + notify_send(ld, n); } static void disconnect_notification_serialize(struct json_stream *stream, - struct lightningd *ld, const struct node_id *nodeid) { - /* Old style: Add raw fields without disconnect key */ - if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok, - "disconnect_notification", "rawfields", - "v23.08", "v24.08")) { - json_add_disconnect_fields(stream, nodeid); - } - json_object_start(stream, "disconnect"); - json_add_disconnect_fields(stream, nodeid); - json_object_end(stream); + json_add_node_id(stream, "id", nodeid); } - REGISTER_NOTIFICATION(disconnect); void notify_disconnect(struct lightningd *ld, struct node_id *nodeid) { - struct jsonrpc_notification *n - = jsonrpc_notification_start(NULL, "disconnect"); - disconnect_notification_serialize(n->stream, ld, nodeid); - jsonrpc_notification_end(n); - plugins_notify(ld->plugins, take(n)); + struct jsonrpc_notification *n = notify_start("disconnect"); + disconnect_notification_serialize(n->stream, nodeid); + notify_send(ld, n); } /*'warning' is based on LOG_UNUSUAL/LOG_BROKEN level log @@ -565,40 +527,21 @@ void notify_balance_snapshot(struct lightningd *ld, notify_send(ld, n); } -static void json_add_block_added_fields(struct json_stream *stream, - const struct block *block) +static void block_added_notification_serialize(struct json_stream *stream, + const struct block *block) { json_add_string(stream, "hash", fmt_bitcoin_blkid(tmpctx, &block->blkid)); json_add_u32(stream, "height", block->height); } - -static void block_added_notification_serialize(struct json_stream *stream, - struct lightningd *ld, - const struct block *block) -{ - if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok, - "block_added_notification", "block", - "v23.08", "v24.08")) { - json_object_start(stream, "block"); - json_add_block_added_fields(stream, block); - json_object_end(stream); - } - json_object_start(stream, "block_added"); - json_add_block_added_fields(stream, block); - json_object_end(stream); -} - REGISTER_NOTIFICATION(block_added); void notify_block_added(struct lightningd *ld, const struct block *block) { - struct jsonrpc_notification *n = - jsonrpc_notification_start(NULL, "block_added"); - block_added_notification_serialize(n->stream, ld, block); - jsonrpc_notification_end(n); - plugins_notify(ld->plugins, take(n)); + struct jsonrpc_notification *n = notify_start("block_added"); + block_added_notification_serialize(n->stream, block); + notify_send(ld, n); } static void openchannel_peer_sigs_serialize(struct json_stream *stream,