cln-plugin: adapt send_custom_notification to send modern-style notifications.

Modern style for notifications is to put everything inside an object
of same name as the method.

For now this means duplication for backward compatibility.  ChatGPT
helped me do that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-08-17 09:39:35 +09:30
parent e43a4a96e7
commit 6bac381a3f

View File

@@ -876,11 +876,19 @@ where
method: String,
v: serde_json::Value,
) -> Result<(), Error> {
// Modern has them inside object of same name.
// This is deprecated, scheduled for removal 26.09.
let mut params = match &v {
serde_json::Value::Object(map) => map.clone(),
_ => return Err(anyhow::anyhow!("params must be a JSON object")),
};
params.insert(method.clone(), json!(v));
self.sender
.send(json!({
"jsonrpc": "2.0",
"method": method,
"params": v,
"params": params,
}))
.await
.context("sending custom notification")?;