Skip to content

Commit

Permalink
pyln-client, libplugin, rust cln-plugin: explicitly flag that we allo…
Browse files Browse the repository at this point in the history
…w non-numeric JSON ids.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Nov 21, 2022
1 parent b7500c7 commit a25c5d1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions contrib/pyln-client/pyln/client/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down
1 change: 1 addition & 0 deletions plugins/libplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
3 changes: 3 additions & 0 deletions plugins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ where
rpcmethods: HashMap<String, RpcMethod<S>>,
subscriptions: HashMap<String, Subscription<S>>,
dynamic: bool,
nonnumericids: bool,
}

/// A plugin that has registered with the lightning daemon, and gotten
Expand Down Expand Up @@ -115,6 +116,7 @@ where
options: vec![],
rpcmethods: HashMap::new(),
dynamic: false,
nonnumericids: true,
}
}

Expand Down Expand Up @@ -318,6 +320,7 @@ where
hooks: self.hooks.keys().map(|s| s.clone()).collect(),
rpcmethods,
dynamic: self.dynamic,
nonnumericids: true,
}
}

Expand Down
1 change: 1 addition & 0 deletions plugins/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub(crate) struct GetManifestResponse {
pub(crate) subscriptions: Vec<String>,
pub(crate) hooks: Vec<String>,
pub(crate) dynamic: bool,
pub(crate) nonnumericids: bool,
}

#[derive(Serialize, Default, Debug)]
Expand Down
15 changes: 0 additions & 15 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\]")

0 comments on commit a25c5d1

Please sign in to comment.