From ad592d8b0d1b537769b0632f48836d9722369a0e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 11 Jul 2023 07:55:22 +0930 Subject: [PATCH] plugins: fix shutdown notification to contain object. We fixed the others. There are no fields, but this keeps it consistent. Signed-off-by: Rusty Russell Changelog-Added: JSON-RPC: `shutdown` notification contains `shutdown` object (notification consistency) --- doc/PLUGINS.md | 6 ++++++ lightningd/notification.c | 3 +++ tests/test_plugin.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index a2f7fb476..b7c7e8071 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -929,6 +929,12 @@ logging or notifications. New rpc calls will fail with error code -5 and (plugin responses will be ignored. Because lightningd can crash or be killed, a plugin cannot rely on the shutdown notification always been send. +```json +{ + "shutdown": { + } +} +``` ## Hooks diff --git a/lightningd/notification.c b/lightningd/notification.c index 5f584c31b..edb00ed87 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -700,6 +700,9 @@ bool notify_plugin_shutdown(struct lightningd *ld, struct plugin *p) struct jsonrpc_notification *n = jsonrpc_notification_start(NULL, "shutdown"); + /* Even shutdown should follow the same "object inside notification" pattern */ + json_object_start(n->stream, "shutdown"); + json_object_end(n->stream); jsonrpc_notification_end(n); return plugin_single_notify(p, take(n)); } diff --git a/tests/test_plugin.py b/tests/test_plugin.py index cabc0b057..8ec9f8fa8 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -4266,7 +4266,7 @@ def test_all_subscription(node_factory, directory): "balance_snapshot: {'balance_snapshot': {'node_id': ", "connect: {'connect': {'id': ", "channel_state_changed: {'channel_state_changed': {'peer_id': ", - "shutdown: {}"): + "shutdown: {'shutdown': {}"): assert l1.daemon.is_in_log(f".*plugin-all_notifications.py: notification {notstr}.*") for notstr in ('block_added: ',