()
| 81 | |
| 82 | #[tokio::main] |
| 83 | async fn main() -> Result<(), anyhow::Error> { |
| 84 | if let Some(plugin) = cln_plugin::Builder::new(tokio::io::stdin(), tokio::io::stdout()) |
| 85 | .hook_from_builder( |
| 86 | HookBuilder::new("custommsg", hooks::client_custommsg_hook) |
| 87 | .filters(vec![HookFilter::Int(i64::from(LSPS0_MESSAGE_TYPE))]), |
| 88 | ) |
| 89 | .option(OPTION_ENABLED) |
| 90 | .rpcmethod( |
| 91 | "lsps-listprotocols", |
| 92 | "list protocols supported by lsp", |
| 93 | on_lsps_listprotocols, |
| 94 | ) |
| 95 | .rpcmethod( |
| 96 | "lsps-lsps2-getinfo", |
| 97 | "Low-level command to request the opening fee menu of an LSP", |
| 98 | on_lsps_lsps2_getinfo, |
| 99 | ) |
| 100 | .rpcmethod( |
| 101 | "lsps-lsps2-buy", |
| 102 | "Low-level command to return the lsps2.buy result from an ", |
| 103 | on_lsps_lsps2_buy, |
| 104 | ) |
| 105 | .rpcmethod( |
| 106 | "lsps-lsps2-approve", |
| 107 | "Low-level command to approve a jit channel opening for the given scid", |
| 108 | on_lsps_lsps2_approve, |
| 109 | ) |
| 110 | .rpcmethod( |
| 111 | "lsps-lsps2-invoice", |
| 112 | "Requests a new jit channel from LSP and returns the matching invoice", |
| 113 | on_lsps_lsps2_invoice, |
| 114 | ) |
| 115 | .hook("invoice_payment", on_invoice_payment) |
| 116 | .hook("htlc_accepted", on_htlc_accepted) |
| 117 | .hook("openchannel", on_openchannel) |
| 118 | .configure() |
| 119 | .await? |
| 120 | { |
| 121 | if !plugin.option(&OPTION_ENABLED)? { |
| 122 | return plugin |
| 123 | .disable(&format!("`{}` not enabled", OPTION_ENABLED.name)) |
| 124 | .await; |
| 125 | } |
| 126 | |
| 127 | let dir = plugin.configuration().lightning_dir; |
| 128 | let rpc_path = Path::new(&dir).join(&plugin.configuration().rpc_file); |
| 129 | let state = State::new(rpc_path, DEFAULT_REQUEST_TIMEOUT); |
| 130 | |
| 131 | let plugin = plugin.start(state).await?; |
| 132 | plugin.join().await |
| 133 | } else { |
| 134 | Ok(()) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /// Rpc Method handler for `lsps-lsps2-getinfo`. |
| 139 | async fn on_lsps_lsps2_getinfo( |
nothing calls this directly
no test coverage detected