MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

plugins/examples/cln-plugin-startup.rs:8–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6use tokio;
7#[tokio::main]
8async fn main() -> Result<(), anyhow::Error> {
9 let state = ();
10
11 if let Some(plugin) = Builder::new(tokio::io::stdin(), tokio::io::stdout())
12 .option(options::ConfigOption::new(
13 "test-option",
14 options::Value::Integer(42),
15 "a test-option with default 42",
16 ))
17 .rpcmethod("testmethod", "This is a test", testmethod)
18 .subscribe("connect", connect_handler)
19 .hook("peer_connected", peer_connected_handler)
20 .start(state)
21 .await?
22 {
23 plugin.join().await
24 } else {
25 Ok(())
26 }
27}
28
29async fn testmethod(_p: Plugin<()>, _v: serde_json::Value) -> Result<serde_json::Value, Error> {
30 Ok(json!("Hello"))

Callers

nothing calls this directly

Calls 6

rpcmethodMethod · 0.80
optionMethod · 0.80
joinMethod · 0.80
startMethod · 0.45
hookMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected