cln4rust
cln4rust copied to clipboard
improve the way to access to the option and configuration value inside the plugin
Take the value from the configuration plugin usually inside the init method is painful
+ .on_init(&|plugin| -> Value {
+ plugin.log(LogLevel::Debug, "Custom init method called");
+ // FIXME: improve the get option plugin API
+ let conf = if let Some(conf_plugin) = &plugin.conf {
+ conf_plugin
+ } else {
+ panic!("this should never happen")
+ };
+ let server_port = conf.options[0].to_owned();
+ let server_port: i32 = from_value(server_port).unwrap();
+ if server_port >= 0 {
+ plugin.log(LogLevel::Info, "running rest server on port {port}");
+ let path = conf.configuration.lightning_dir.as_str();
+ run_rocket(path);
+ }
+ json_utils::init_payload()
+ })