From ece77840f906bba94d77889d651dd39208c9127d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Nov 2022 12:23:26 +1030 Subject: [PATCH] pyln-client, libplugin, rust cln-plugin: explicitly flag that we allow non-numeric JSON ids. Signed-off-by: Rusty Russell --- contrib/pyln-client/pyln/client/plugin.py | 1 + plugins/libplugin.c | 1 + plugins/src/lib.rs | 3 +++ plugins/src/messages.rs | 1 + tests/test_plugin.py | 15 --------------- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/contrib/pyln-client/pyln/client/plugin.py b/contrib/pyln-client/pyln/client/plugin.py index 921c9f3041d0..e53bcbeda6df 100644 --- a/contrib/pyln-client/pyln/client/plugin.py +++ b/contrib/pyln-client/pyln/client/plugin.py @@ -917,6 +917,7 @@ def _getmanifest(self, **kwargs) -> JSONType: 'subscriptions': list(self.subscriptions.keys()), 'hooks': hooks, 'dynamic': self.dynamic, + 'nonnumericids': True, 'notifications': [ {"method": name} for name in self.notification_topics ], diff --git a/plugins/libplugin.c b/plugins/libplugin.c index a5527448c5ef..332f65890f6c 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -888,6 +888,7 @@ handle_getmanifest(struct command *getmanifest_cmd, } json_add_bool(params, "dynamic", p->restartability == PLUGIN_RESTARTABLE); + json_add_bool(params, "nonnumericids", true); json_array_start(params, "notifications"); for (size_t i = 0; p->notif_topics && i < p->num_notif_topics; i++) { diff --git a/plugins/src/lib.rs b/plugins/src/lib.rs index a437defab90e..cb681b1330ed 100644 --- a/plugins/src/lib.rs +++ b/plugins/src/lib.rs @@ -46,6 +46,7 @@ where rpcmethods: HashMap>, subscriptions: HashMap>, dynamic: bool, + nonnumericids: bool, } /// A plugin that has registered with the lightning daemon, and gotten @@ -115,6 +116,7 @@ where options: vec![], rpcmethods: HashMap::new(), dynamic: false, + nonnumericids: true, } } @@ -318,6 +320,7 @@ where hooks: self.hooks.keys().map(|s| s.clone()).collect(), rpcmethods, dynamic: self.dynamic, + nonnumericids: true, } } diff --git a/plugins/src/messages.rs b/plugins/src/messages.rs index 89722b997b1d..7097380a05d9 100644 --- a/plugins/src/messages.rs +++ b/plugins/src/messages.rs @@ -157,6 +157,7 @@ pub(crate) struct GetManifestResponse { pub(crate) subscriptions: Vec, pub(crate) hooks: Vec, pub(crate) dynamic: bool, + pub(crate) nonnumericids: bool, } #[derive(Serialize, Default, Debug)] diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 5a6b2c8ab2b9..91474de2c1a4 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -3238,18 +3238,3 @@ def test_block_added_notifications(node_factory, bitcoind): sync_blockheight(bitcoind, [l2]) ret = l2.rpc.call("blockscatched") assert len(ret) == 3 and ret[1] == next_l2_base + 1 and ret[2] == next_l2_base + 2 - - -def test_numeric_json_ids(node_factory): - """Test that we use numeric json IDs when in deprecated mode (unless -plugin says otherwise!)""" - l1 = node_factory.get_node(options={'allow-deprecated-apis': True, - 'log-level': 'io'}) - - # getmanifest and init - l1.daemon.logsearch_start = 0 - l1.daemon.wait_for_logs([r"plugin-commando: [0-9]*\[OUT\]"] * 2) - - # This is in a plugin. - l1.rpc.commando_rune() - l1.daemon.wait_for_log(r"plugin-commando: [0-9]*\[OUT\]")