diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 4f4e85866..41da67a30 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -453,19 +453,10 @@ static const char *plugin_notification_handle(struct plugin *plugin, methname = json_strdup(tmpctx, plugin->buffer, methtok); if (notifications_have_topic(plugin->plugins, methname)) { - n = tal(NULL, struct jsonrpc_notification); - n->method = tal_steal(n, methname); - n->stream = new_json_stream(n, NULL, NULL); - json_object_start(n->stream, NULL); - json_add_string(n->stream, "jsonrpc", "2.0"); - json_add_string(n->stream, "method", methname); - - json_add_tok(n->stream, "params", paramstok, plugin->buffer); - - json_object_end(n->stream); /* closes '.' */ - - /* We guarantee to have \n\n at end of each response. */ - json_stream_append(n->stream, "\n\n", strlen("\n\n")); + n = jsonrpc_notification_start(NULL, methname); + json_add_string(n->stream, "origin", plugin->shortname); + json_add_tok(n->stream, "payload", paramstok, plugin->buffer); + jsonrpc_notification_end(n); plugins_notify(plugin->plugins, take(n)); return NULL; diff --git a/tests/plugins/custom_notifications.py b/tests/plugins/custom_notifications.py index 9b32aa45e..570543950 100755 --- a/tests/plugins/custom_notifications.py +++ b/tests/plugins/custom_notifications.py @@ -6,8 +6,8 @@ plugin = Plugin() @plugin.subscribe("custom") -def on_custom_notification(val, plugin, **kwargs): - plugin.log("Got a custom notification {}".format(val)) +def on_custom_notification(origin, payload, **kwargs): + plugin.log("Got a custom notification {} from plugin {}".format(payload, origin)) @plugin.method("emit") diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 308710c79..d16cc75fd 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -2404,7 +2404,6 @@ def test_self_disable(node_factory): l1.rpc.plugin_start(p2, selfdisable=True) -@pytest.mark.xfail(strict=True) def test_custom_notification_topics(node_factory): plugin = os.path.join( os.path.dirname(__file__), "plugins", "custom_notifications.py"