diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index eff2de231..452f54bef 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -528,7 +528,9 @@ to a peer was lost. ```json { - "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" + "disconnect": { + "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" + } } ``` diff --git a/doc/guides/Developer-s Guide/plugin-development/event-notifications.md b/doc/guides/Developer-s Guide/plugin-development/event-notifications.md index 5d6917401..31dd79928 100644 --- a/doc/guides/Developer-s Guide/plugin-development/event-notifications.md +++ b/doc/guides/Developer-s Guide/plugin-development/event-notifications.md @@ -103,7 +103,9 @@ A notification for topic `disconnect` is sent every time a connection to a peer ```json { - "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" + "disconnect": { + "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" + } } ``` diff --git a/lightningd/notification.c b/lightningd/notification.c index 24dfff144..3a72eb163 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -84,10 +84,21 @@ void notify_connect(struct lightningd *ld, 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); +} + static void disconnect_notification_serialize(struct json_stream *stream, struct node_id *nodeid) { - json_add_node_id(stream, "id", nodeid); + /* Old style: Add raw fields without disconnect key */ + /* FIXME: deprecate! */ + json_add_disconnect_fields(stream, nodeid); + json_object_start(stream, "disconnect"); + json_add_disconnect_fields(stream, nodeid); + json_object_end(stream); } REGISTER_NOTIFICATION(disconnect,