notification: disconnect with json key disconnect

Changelog-Added: JSON-RPC: `connect` and `disconnect` notifications now wrap `id` field in a `connect`/`disconnect` object (consistency with other notifications)
This commit is contained in:
Shahana Farooqui
2023-06-27 19:26:27 -07:00
committed by Rusty Russell
parent e247d16536
commit 79092c16b1
3 changed files with 18 additions and 3 deletions

View File

@@ -528,8 +528,10 @@ to a peer was lost.
```json ```json
{ {
"disconnect": {
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432"
} }
}
``` ```
### `invoice_payment` ### `invoice_payment`

View File

@@ -103,8 +103,10 @@ A notification for topic `disconnect` is sent every time a connection to a peer
```json ```json
{ {
"disconnect": {
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432" "id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432"
} }
}
``` ```

View File

@@ -84,10 +84,21 @@ void notify_connect(struct lightningd *ld,
plugins_notify(ld->plugins, take(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);
}
static void disconnect_notification_serialize(struct json_stream *stream, static void disconnect_notification_serialize(struct json_stream *stream,
struct node_id *nodeid) 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, REGISTER_NOTIFICATION(disconnect,