(
p: cln_plugin::Plugin<State>,
v: serde_json::Value,
)
| 722 | } |
| 723 | |
| 724 | async fn on_lsps_listprotocols( |
| 725 | p: cln_plugin::Plugin<State>, |
| 726 | v: serde_json::Value, |
| 727 | ) -> Result<serde_json::Value, anyhow::Error> { |
| 728 | #[derive(Deserialize)] |
| 729 | struct Request { |
| 730 | lsp_id: String, |
| 731 | } |
| 732 | let dir = p.configuration().lightning_dir; |
| 733 | let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file); |
| 734 | let mut cln_client = cln_rpc::ClnRpc::new(rpc_path.clone()).await?; |
| 735 | |
| 736 | let req: Request = serde_json::from_value(v).context("Failed to parse request JSON")?; |
| 737 | let lsp_id = PublicKey::from_str(&req.lsp_id).context("lsp_id is not a valid public key")?; |
| 738 | let lsp_status = check_peer_lsp_status(&mut cln_client, &req.lsp_id).await?; |
| 739 | |
| 740 | // Fail early: Check that we are connected to the peer. |
| 741 | if !lsp_status.connected { |
| 742 | bail!("Not connected to peer {}", &req.lsp_id); |
| 743 | }; |
| 744 | |
| 745 | // From Blip52: LSPs MAY set the features bit numbered 729 |
| 746 | // (option_supports_lsps)... |
| 747 | // We only log that it is not set but don't fail. |
| 748 | if !lsp_status.has_lsp_feature { |
| 749 | debug!("Peer {} doesn't have the LSP feature bit set.", &req.lsp_id); |
| 750 | } |
| 751 | |
| 752 | let client = p.state().client(); |
| 753 | match client.list_protocols(&lsp_id).await?.as_result() { |
| 754 | Ok(i) => { |
| 755 | debug!("Received lsps0.list_protocols response: {:?}", i); |
| 756 | Ok(serde_json::to_value(i)?) |
| 757 | } |
| 758 | Err(e) => Ok(serde_json::to_value(e)?), |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | struct PeerLspStatus { |
| 763 | connected: bool, |
nothing calls this directly
no test coverage detected