()
| 15 | |
| 16 | #[tokio::main(flavor = "current_thread")] |
| 17 | async fn main() -> Result<(), anyhow::Error> { |
| 18 | unsafe { |
| 19 | // SAFETY: |
| 20 | // `std::env::set_var` is unsafe in Rust 2024 because environment variables |
| 21 | // are process-global and unsynchronized. Concurrent reads/writes from |
| 22 | // multiple threads can cause undefined behavior. |
| 23 | // |
| 24 | // This call happens at process startup, before any threads are spawned and |
| 25 | // before any code that may read environment variables is executed. |
| 26 | // Therefore, no concurrent access is possible. |
| 27 | std::env::set_var( |
| 28 | "CLN_PLUGIN_LOG", |
| 29 | "cln_plugin=info,cln_rpc=info,cln_bip353=trace,warn", |
| 30 | ) |
| 31 | }; |
| 32 | |
| 33 | log_panics::init(); |
| 34 | |
| 35 | let plugin = match Builder::new(tokio::io::stdin(), tokio::io::stdout()) |
| 36 | .rpcmethod_from_builder( |
| 37 | RpcMethodBuilder::new("fetchbip353", fetch_bip353) |
| 38 | .description("Fetch bip353 data and proofs") |
| 39 | .usage("[address]"), |
| 40 | ) |
| 41 | .dynamic() |
| 42 | .configure() |
| 43 | .await? |
| 44 | { |
| 45 | Some(p) => p, |
| 46 | None => return Ok(()), |
| 47 | }; |
| 48 | |
| 49 | let plugin = plugin.start(()).await?; |
| 50 | |
| 51 | plugin.join().await |
| 52 | } |
| 53 | |
| 54 | #[derive(Debug, Serialize)] |
| 55 | struct ProcessedBIP353 { |
nothing calls this directly
no test coverage detected