Skip to content

Commit 9dcc264

Browse files
committed
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 <[email protected]>
1 parent d869fa4 commit 9dcc264

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugins/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,19 @@ where
876876
method: String,
877877
v: serde_json::Value,
878878
) -> Result<(), Error> {
879+
// Modern has them inside object of same name.
880+
// This is deprecated, scheduled for removal 26.09.
881+
let mut params = match &v {
882+
serde_json::Value::Object(map) => map.clone(),
883+
_ => return Err(anyhow::anyhow!("params must be a JSON object")),
884+
};
885+
params.insert(method.clone(), json!(v));
886+
879887
self.sender
880888
.send(json!({
881889
"jsonrpc": "2.0",
882890
"method": method,
883-
"params": v,
891+
"params": params,
884892
}))
885893
.await
886894
.context("sending custom notification")?;

0 commit comments

Comments
 (0)