diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index b4f571055..eff2de231 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -513,9 +513,11 @@ to a peer is established. `direction` is either `"in"` or `"out"`. ```json { - "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432", - "direction": "in", - "address": "1.2.3.4:1234" + "connect": { + "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432", + "direction": "in", + "address": "1.2.3.4:1234" + } } ``` 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 e7ca76f65..5d6917401 100644 --- a/doc/guides/Developer-s Guide/plugin-development/event-notifications.md +++ b/doc/guides/Developer-s Guide/plugin-development/event-notifications.md @@ -87,9 +87,11 @@ A notification for topic `connect` is sent every time a new connection to a peer ```json { - "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432", - "direction": "in", - "address": "1.2.3.4:1234" + "connect": { + "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432", + "direction": "in", + "address": "1.2.3.4:1234" + } } ``` diff --git a/lightningd/notification.c b/lightningd/notification.c index 1208ad7aa..24dfff144 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -41,7 +41,7 @@ bool notifications_have_topic(const struct plugins *plugins, const char *topic) return false; } -static void connect_notification_serialize(struct json_stream *stream, +static void json_add_connect_fields(struct json_stream *stream, const struct node_id *nodeid, bool incoming, const struct wireaddr_internal *addr) @@ -51,6 +51,19 @@ static void connect_notification_serialize(struct json_stream *stream, json_add_address_internal(stream, "address", addr); } +static void connect_notification_serialize(struct json_stream *stream, + const struct node_id *nodeid, + bool incoming, + const struct wireaddr_internal *addr) +{ + /* Old style: Add raw fields without connect key */ + /* FIXME: Deprecate! */ + 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, connect_notification_serialize);