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

Function main

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

Source from the content-addressed store, hash-verified

48
49#[tokio::main]
50async fn main() -> Result<(), anyhow::Error> {
51 let state = ();
52
53 let test_dynamic_option: BooleanConfigOption = BooleanConfigOption::new_bool_no_default(
54 "test-dynamic-option",
55 "A option that can be changed dynamically",
56 )
57 .dynamic();
58
59 if let Some(plugin) = Builder::new(tokio::io::stdin(), tokio::io::stdout())
60 .option(TEST_OPTION)
61 .option(TEST_OPTION_NO_DEFAULT)
62 .option(test_dynamic_option)
63 .option(TEST_MULTI_STR_OPTION)
64 .option(TEST_MULTI_STR_OPTION_DEFAULT)
65 .option(TEST_MULTI_I64_OPTION)
66 .option(TEST_MULTI_I64_OPTION_DEFAULT)
67 .setconfig_callback(setconfig_callback)
68 .rpcmethod("testmethod", "This is a test", testmethod)
69 .rpcmethod(
70 "testoptions",
71 "Retrieve options from this plugin",
72 testoptions,
73 )
74 .rpcmethod(
75 "test-custom-notification",
76 "send a test_custom_notification event",
77 test_send_custom_notification,
78 )
79 .rpcmethod("test-log-levels", "send on all log levels", test_log_levels)
80 .subscribe("connect", connect_handler)
81 .subscribe("test_custom_notification", test_receive_custom_notification)
82 .hook_from_builder(
83 HookBuilder::new("peer_connected", peer_connected_handler)
84 .after(Vec::new())
85 .before(Vec::new())
86 .filters(Vec::new()),
87 )
88 .notification(messages::NotificationTopic::new(TEST_NOTIF_TAG))
89 .start(state)
90 .await?
91 {
92 plugin.join().await
93 } else {
94 Ok(())
95 }
96}
97
98async fn setconfig_callback(
99 plugin: Plugin<()>,

Callers

nothing calls this directly

Calls 12

notificationMethod · 0.80
hook_from_builderMethod · 0.80
rpcmethodMethod · 0.80
setconfig_callbackMethod · 0.80
optionMethod · 0.80
filtersMethod · 0.80
beforeMethod · 0.80
afterMethod · 0.80
joinMethod · 0.80
dynamicMethod · 0.45
startMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected