From 21f95824cea5ca56412eaf262b9cdbd7784fcdd2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Nov 2022 11:09:56 +1030 Subject: [PATCH 1/4] doc: document how to construct JSON ids in modern plugins and utilities. Signed-off-by: Rusty Russell --- doc/lightningd-rpc.7.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/lightningd-rpc.7.md b/doc/lightningd-rpc.7.md index 8f55f206d3ac..594cfcaf47bd 100644 --- a/doc/lightningd-rpc.7.md +++ b/doc/lightningd-rpc.7.md @@ -42,6 +42,38 @@ The lightning-cli(1) tool uses ordered parameters by default, but named parameters if explicitly specified or the first parameter contains an '='. +JSON IDS +-------- + +JSON `id` fields in requests are used to match requests and responses. +These used to be simple numbers, but with modern plugins that is deprecated: +we use a specific format, which makes them very useful for debugging +and tracking the cause of commands: + +```EBNF +JSONID := IDPART ['/' IDPART]* +IDPART := PREFIX ':' METHOD '#' NUMBER +``` + +`PREFIX` is cln for the main daemon, cli for lightning-cli, and should +be the plugin name for plugins. `METHOD` is an internal identifier, +indicating what caused the request: for `cli` it's simply the method +it's invoking, but for plugins it may be the routine which created the +request. And `NUMBER` ensures uniqueness (it's usually a simple +increment). + +Importantly for plugins, incoming requests often trigger outgoing +requests, and for these, the outgoing request id is created by +appending a `/` and another id part into the incoming. This makes the +chain of responsibility much clearer. e.g, this shows the JSON `id` +of a `sendrawtransaction` RPC call, and we can tell that lightning-cli +has invoked the `withdraw` command, which lightningd passes through +to the `txprepare` plugin, which called `sendrawtransaction`. + +``` +cli:withdraw#123/cln:withdraw#7/txprepare:sendpsbt#1/cln:sendrawtransaction#9 +``` + JSON REPLIES ------------ From a4c39270cfb05583a9fbd805e31f9a370960568c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Nov 2022 11:12:28 +1030 Subject: [PATCH 2/4] plugins: set non_numeric_ids flag based on getmanifest `nonnumericids` field. And document support for it. Signed-off-by: Rusty Russell Changelog-Added: Plugins: `getmanfest` response can contain `nonnumericids` to indicate support for modern string-based JSON request ids. Changelog-Deprecated: Plugins: numeric JSON request ids: modern ones will be strings (see doc/lightningd-rpc.7.md!) --- doc/PLUGINS.md | 9 +++++++++ lightningd/plugin.c | 15 +++++++++++++++ lightningd/plugin.h | 3 +++ 3 files changed, 27 insertions(+) diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index a40e13f54a67..1a8946356c4f 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -136,6 +136,7 @@ example: "method": "mycustomnotification" } ], + "nonnumericids": true, "dynamic": true } ``` @@ -158,6 +159,13 @@ you plan on removing them: this will disable them if the user sets `allow-deprecated-apis` to false (which every developer should do, right?). +The `nonnumericids` indicates that the plugin can handle +string JSON request `id` fields: prior to v22.11 lightningd used numbers +for these, and the change to strings broke some plugins. If not set, +then strings will be used once this feature is removed after v23.05. +See [the lightning-rpc documentation][lightning-rpc.7.md] for how to handle +JSON `id` fields! + The `dynamic` indicates if the plugin can be managed after `lightningd` has been started using the [plugin][lightning-plugin] JSON-RPC command. Critical plugins that should not be stopped should set it to false. Plugin `options` can be passed to dynamic plugins as argument to the `plugin` command . @@ -1781,3 +1789,4 @@ The plugin must broadcast it and respond with the following fields: [bolt9]: https://github.com/lightning/bolts/blob/master/09-features.md [lightning-plugin]: lightning-plugin.7.md [pyln-client]: ../contrib/pyln-client +[lightning-rpc.7.md]: lightning-rpc.7.md diff --git a/lightningd/plugin.c b/lightningd/plugin.c index b569d28f360e..b01e3de4f672 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -291,6 +291,7 @@ struct plugin *plugin_register(struct plugins *plugins, const char* path TAKES, p->notification_topics = tal_arr(p, const char *, 0); p->subscriptions = NULL; p->dynamic = false; + p->non_numeric_ids = false; p->index = plugins->plugin_idx++; p->log = new_log(p, plugins->log_book, NULL, "plugin-%s", p->shortname); @@ -1528,6 +1529,20 @@ static const char *plugin_parse_getmanifest_response(const char *buffer, } } + tok = json_get_member(buffer, resulttok, "nonnumericids"); + if (tok) { + if (!json_to_bool(&plugin->non_numeric_ids, buffer, tok)) + return tal_fmt(plugin, + "Invalid nonnumericids: %.*s", + json_tok_full_len(tok), + json_tok_full(buffer, tok)); + if (!deprecated_apis && !plugin->non_numeric_ids) + return tal_fmt(plugin, + "Plugin does not allow nonnumericids"); + } else + /* Default is false in deprecated mode */ + plugin->non_numeric_ids = !deprecated_apis; + err = plugin_notifications_add(buffer, resulttok, plugin); if (!err) err = plugin_opts_add(plugin, buffer, resulttok); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index fbcfbf486645..6f41e701b12e 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -81,6 +81,9 @@ struct plugin { * C-lightning should terminate as well. */ bool important; + /* Can this handle non-numeric JSON ids? */ + bool non_numeric_ids; + /* Parameters for dynamically-started plugins. */ const char *parambuf; const jsmntok_t *params; From b7500c7462a2bc757c53409e0619bb471d94fc56 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Nov 2022 12:18:32 +1030 Subject: [PATCH 3/4] lightningd: only use non-numeric JSON ids if plugin says we can. We also remember whether the id is a string or not, for replacement in JSON passthrough. Signed-off-by: Rusty Russell --- lightningd/bitcoind.c | 15 ++++++++------ lightningd/invoice.c | 21 +++++++++---------- lightningd/jsonrpc.c | 23 ++++++++++++++------- lightningd/jsonrpc.h | 13 +++++++----- lightningd/plugin.c | 15 +++++++------- lightningd/plugin_hook.c | 5 ++++- lightningd/signmessage.c | 15 +++++++------- lightningd/test/run-invoice-select-inchan.c | 4 +++- tests/test_plugin.py | 20 ++++++++++++++++-- 9 files changed, 84 insertions(+), 47 deletions(-) diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c index 367abf05f692..1baec3c587a5 100644 --- a/lightningd/bitcoind.c +++ b/lightningd/bitcoind.c @@ -49,7 +49,8 @@ static void config_plugin(struct plugin *plugin) struct jsonrpc_request *req; void *ret; - req = jsonrpc_request_start(plugin, "init", NULL, plugin->log, + req = jsonrpc_request_start(plugin, "init", NULL, + plugin->non_numeric_ids, plugin->log, NULL, plugin_config_cb, plugin); plugin_populate_init_request(plugin, req); jsonrpc_request_end(req); @@ -237,7 +238,7 @@ void bitcoind_estimate_fees_(struct bitcoind *bitcoind, call->cb = cb; call->arg = arg; - req = jsonrpc_request_start(bitcoind, "estimatefees", NULL, + req = jsonrpc_request_start(bitcoind, "estimatefees", NULL, true, bitcoind->log, NULL, estimatefees_callback, call); jsonrpc_request_end(req); @@ -314,7 +315,8 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind, call->cb_arg = cb_arg; log_debug(bitcoind->log, "sendrawtransaction: %s", hextx); - req = jsonrpc_request_start(bitcoind, "sendrawtransaction", id_prefix, + req = jsonrpc_request_start(bitcoind, "sendrawtransaction", + id_prefix, true, bitcoind->log, NULL, sendrawtx_callback, call); @@ -401,7 +403,7 @@ void bitcoind_getrawblockbyheight_(struct bitcoind *bitcoind, call->cb = cb; call->cb_arg = cb_arg; - req = jsonrpc_request_start(bitcoind, "getrawblockbyheight", NULL, + req = jsonrpc_request_start(bitcoind, "getrawblockbyheight", NULL, true, bitcoind->log, NULL, getrawblockbyheight_callback, call); @@ -482,7 +484,7 @@ void bitcoind_getchaininfo_(struct bitcoind *bitcoind, call->cb_arg = cb_arg; call->first_call = first_call; - req = jsonrpc_request_start(bitcoind, "getchaininfo", NULL, + req = jsonrpc_request_start(bitcoind, "getchaininfo", NULL, true, bitcoind->log, NULL, getchaininfo_callback, call); jsonrpc_request_end(req); @@ -555,7 +557,8 @@ void bitcoind_getutxout_(struct bitcoind *bitcoind, call->cb = cb; call->cb_arg = cb_arg; - req = jsonrpc_request_start(bitcoind, "getutxout", NULL, bitcoind->log, + req = jsonrpc_request_start(bitcoind, "getutxout", NULL, true, + bitcoind->log, NULL, getutxout_callback, call); json_add_txid(req->stream, "txid", &outpoint->txid); json_add_num(req->stream, "vout", outpoint->n); diff --git a/lightningd/invoice.c b/lightningd/invoice.c index 6ae17b9e5ab8..2ddbcc647990 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -1241,22 +1241,21 @@ static struct command_result *json_invoice(struct command *cmd, if (fallback_scripts) info->b11->fallbacks = tal_steal(info->b11, fallback_scripts); + /* We can't generate routehints without listincoming. */ + plugin = find_plugin_for_command(cmd->ld, "listincoming"); + if (!plugin) { + return invoice_complete(info, true, + false, false, false, false, false); + } + req = jsonrpc_request_start(info, "listincoming", - cmd->id, + cmd->id, plugin->non_numeric_ids, command_log(cmd), NULL, listincoming_done, info); jsonrpc_request_end(req); - - plugin = find_plugin_for_command(cmd->ld, "listincoming"); - if (plugin) { - plugin_request_send(plugin, req); - return command_still_pending(cmd); - } - - /* We can't generate routehints without listincoming. */ - return invoice_complete(info, true, - false, false, false, false, false); + plugin_request_send(plugin, req); + return command_still_pending(cmd); } static const struct json_command invoice_command = { diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index dfc7db71bc36..b311f50daba9 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -1376,7 +1376,7 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n) struct jsonrpc_request *jsonrpc_request_start_( const tal_t *ctx, const char *method, - const char *id_prefix, struct log *log, + const char *id_prefix, bool id_as_string, struct log *log, bool add_header, void (*notify_cb)(const char *buffer, const jsmntok_t *methodtok, @@ -1389,11 +1389,17 @@ struct jsonrpc_request *jsonrpc_request_start_( { struct jsonrpc_request *r = tal(ctx, struct jsonrpc_request); static u64 next_request_id = 0; - if (id_prefix) - r->id = tal_fmt(r, "%s/cln:%s#%"PRIu64, - id_prefix, method, next_request_id); - else - r->id = tal_fmt(r, "cln:%s#%"PRIu64, method, next_request_id); + + r->id_is_string = id_as_string; + if (r->id_is_string) { + if (id_prefix) + r->id = tal_fmt(r, "%s/cln:%s#%"PRIu64, + id_prefix, method, next_request_id); + else + r->id = tal_fmt(r, "cln:%s#%"PRIu64, method, next_request_id); + } else { + r->id = tal_fmt(r, "%"PRIu64, next_request_id); + } if (taken(id_prefix)) tal_free(id_prefix); next_request_id++; @@ -1409,7 +1415,10 @@ struct jsonrpc_request *jsonrpc_request_start_( if (add_header) { json_object_start(r->stream, NULL); json_add_string(r->stream, "jsonrpc", "2.0"); - json_add_string(r->stream, "id", r->id); + if (r->id_is_string) + json_add_string(r->stream, "id", r->id); + else + json_add_primitive(r->stream, "id", r->id); json_add_string(r->stream, "method", method); json_object_start(r->stream, "params"); } diff --git a/lightningd/jsonrpc.h b/lightningd/jsonrpc.h index 2310b079b7d0..a3f6cd5d6777 100644 --- a/lightningd/jsonrpc.h +++ b/lightningd/jsonrpc.h @@ -73,6 +73,7 @@ struct jsonrpc_notification { struct jsonrpc_request { const char *id; + bool id_is_string; const char *method; struct json_stream *stream; void (*notify_cb)(const char *buffer, @@ -226,9 +227,9 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n); * start a JSONRPC request; id_prefix is non-NULL if this was triggered by * another JSONRPC request. */ -#define jsonrpc_request_start(ctx, method, id_prefix, log, notify_cb, response_cb, response_cb_arg) \ +#define jsonrpc_request_start(ctx, method, id_prefix, id_as_string, log, notify_cb, response_cb, response_cb_arg) \ jsonrpc_request_start_( \ - (ctx), (method), (id_prefix), (log), true, \ + (ctx), (method), (id_prefix), (id_as_string), (log), true, \ typesafe_cb_preargs(void, void *, (notify_cb), (response_cb_arg), \ const char *buffer, \ const jsmntok_t *idtok, \ @@ -240,9 +241,9 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n); const jsmntok_t *idtok), \ (response_cb_arg)) -#define jsonrpc_request_start_raw(ctx, method, id_prefix, log, notify_cb, response_cb, response_cb_arg) \ +#define jsonrpc_request_start_raw(ctx, method, id_prefix, id_as_string,log, notify_cb, response_cb, response_cb_arg) \ jsonrpc_request_start_( \ - (ctx), (method), (id_prefix), (log), false, \ + (ctx), (method), (id_prefix), (id_as_string), (log), false, \ typesafe_cb_preargs(void, void *, (notify_cb), (response_cb_arg), \ const char *buffer, \ const jsmntok_t *idtok, \ @@ -256,7 +257,9 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n); struct jsonrpc_request *jsonrpc_request_start_( const tal_t *ctx, const char *method, - const char *id_prefix TAKES, struct log *log, bool add_header, + const char *id_prefix TAKES, + bool id_as_string, + struct log *log, bool add_header, void (*notify_cb)(const char *buffer, const jsmntok_t *idtok, const jsmntok_t *methodtok, diff --git a/lightningd/plugin.c b/lightningd/plugin.c index b01e3de4f672..3ca0f3d2a983 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1143,7 +1143,8 @@ static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd, call = tal(plugin, struct plugin_rpccall); call->cmd = cmd; - req = jsonrpc_request_start_raw(plugin, cmd->json_cmd->name, cmd->id, + req = jsonrpc_request_start_raw(plugin, cmd->json_cmd->name, + cmd->id, plugin->non_numeric_ids, plugin->log, plugin_notify_cb, plugin_rpcmethod_cb, call); @@ -1152,7 +1153,7 @@ static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd, list_add_tail(&plugin->pending_rpccalls, &call->list); json_stream_forward_change_id(req->stream, buffer, toks, idtok, req->id, - true); + req->id_is_string); json_stream_double_cr(req->stream); plugin_request_send(plugin, req); req->stream = NULL; @@ -1531,7 +1532,7 @@ static const char *plugin_parse_getmanifest_response(const char *buffer, tok = json_get_member(buffer, resulttok, "nonnumericids"); if (tok) { - if (!json_to_bool(&plugin->non_numeric_ids, buffer, tok)) + if (!json_to_bool(buffer, tok, &plugin->non_numeric_ids)) return tal_fmt(plugin, "Invalid nonnumericids: %.*s", json_tok_full_len(tok), @@ -1745,8 +1746,8 @@ const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id) * write-only on p->stdin */ p->stdout_conn = io_new_conn(p, stdoutfd, plugin_stdout_conn_init, p); p->stdin_conn = io_new_conn(p, stdinfd, plugin_stdin_conn_init, p); - req = jsonrpc_request_start(p, "getmanifest", cmd_id, p->log, - NULL, plugin_manifest_cb, p); + req = jsonrpc_request_start(p, "getmanifest", cmd_id, p->non_numeric_ids, + p->log, NULL, plugin_manifest_cb, p); json_add_bool(req->stream, "allow-deprecated-apis", deprecated_apis); jsonrpc_request_end(req); plugin_request_send(p, req); @@ -1926,8 +1927,8 @@ plugin_config(struct plugin *plugin) struct jsonrpc_request *req; plugin_set_timeout(plugin); - req = jsonrpc_request_start(plugin, "init", NULL, plugin->log, - NULL, plugin_config_cb, plugin); + req = jsonrpc_request_start(plugin, "init", NULL, plugin->non_numeric_ids, + plugin->log, NULL, plugin_config_cb, plugin); plugin_populate_init_request(plugin, req); jsonrpc_request_end(req); plugin_request_send(plugin, req); diff --git a/lightningd/plugin_hook.c b/lightningd/plugin_hook.c index d167d3a1825f..4b90a57d7af7 100644 --- a/lightningd/plugin_hook.c +++ b/lightningd/plugin_hook.c @@ -235,6 +235,7 @@ static void plugin_hook_call_next(struct plugin_hook_request *ph_req) log_debug(ph_req->ld->log, "Calling %s hook of plugin %s", ph_req->hook->name, ph_req->plugin->shortname); req = jsonrpc_request_start(NULL, hook->name, ph_req->cmd_id, + ph_req->plugin->non_numeric_ids, plugin_get_log(ph_req->plugin), NULL, plugin_hook_callback, ph_req); @@ -380,7 +381,9 @@ void plugin_hook_db_sync(struct db *db) /* FIXME: id_prefix from caller? */ /* FIXME: do IO logging for this! */ - req = jsonrpc_request_start(NULL, hook->name, NULL, NULL, NULL, + req = jsonrpc_request_start(NULL, hook->name, NULL, + dwh_req->plugin->non_numeric_ids, + NULL, NULL, db_hook_response, dwh_req); diff --git a/lightningd/signmessage.c b/lightningd/signmessage.c index 59862caad24d..5a008a425a46 100644 --- a/lightningd/signmessage.c +++ b/lightningd/signmessage.c @@ -211,17 +211,18 @@ static struct command_result *json_checkmessage(struct command *cmd, node_id_from_pubkey(&can->id, &reckey); can->cmd = cmd; - req = jsonrpc_request_start(cmd, "listnodes", - cmd->id, - command_log(cmd), - NULL, listnodes_done, - can); - json_add_node_id(req->stream, "id", &can->id); - jsonrpc_request_end(req); /* Only works if we have listnodes! */ plugin = find_plugin_for_command(cmd->ld, "listnodes"); if (plugin) { + req = jsonrpc_request_start(cmd, "listnodes", + cmd->id, + plugin->non_numeric_ids, + command_log(cmd), + NULL, listnodes_done, + can); + json_add_node_id(req->stream, "id", &can->id); + jsonrpc_request_end(req); plugin_request_send(plugin, req); return command_still_pending(cmd); } diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index a38647e3851b..2497a8647208 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -517,7 +517,9 @@ void jsonrpc_request_end(struct jsonrpc_request *request UNNEEDED) /* Generated stub for jsonrpc_request_start_ */ struct jsonrpc_request *jsonrpc_request_start_( const tal_t *ctx UNNEEDED, const char *method UNNEEDED, - const char *id_prefix TAKES UNNEEDED, struct log *log UNNEEDED, bool add_header UNNEEDED, + const char *id_prefix TAKES UNNEEDED, + bool id_as_string UNNEEDED, + struct log *log UNNEEDED, bool add_header UNNEEDED, void (*notify_cb)(const char *buffer UNNEEDED, const jsmntok_t *idtok UNNEEDED, const jsmntok_t *methodtok UNNEEDED, diff --git a/tests/test_plugin.py b/tests/test_plugin.py index f89aba5938d4..5a6b2c8ab2b9 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -1501,8 +1501,9 @@ def test_libplugin(node_factory): myname = os.path.splitext(os.path.basename(sys.argv[0]))[0] - # Side note: getmanifest will trace back to plugin_start - l1.daemon.wait_for_log(r": {}:plugin#[0-9]*/cln:getmanifest#[0-9]*\[OUT\]".format(myname)) + # Note: getmanifest always uses numeric ids, since it doesn't know + # yet whether strings are allowed: + l1.daemon.wait_for_log(r"test_libplugin: [0-9]*\[OUT\]") # Test commands assert l1.rpc.call("helloworld") == {"hello": "world"} @@ -3237,3 +3238,18 @@ 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\]") From a25c5d14fe986b67178988e6ebb79610672cc829 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 21 Nov 2022 12:23:26 +1030 Subject: [PATCH 4/4] 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\]")