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

Function on_lsps_lsps2_getinfo

plugins/lsps-plugin/src/client.rs:139–176  ·  view source on GitHub ↗

Rpc Method handler for `lsps-lsps2-getinfo`.

(
    p: cln_plugin::Plugin<State>,
    v: serde_json::Value,
)

Source from the content-addressed store, hash-verified

137
138/// Rpc Method handler for `lsps-lsps2-getinfo`.
139async fn on_lsps_lsps2_getinfo(
140 p: cln_plugin::Plugin<State>,
141 v: serde_json::Value,
142) -> Result<serde_json::Value, anyhow::Error> {
143 let req: ClnRpcLsps2GetinfoRequest =
144 serde_json::from_value(v).context("Failed to parse request JSON")?;
145 debug!(
146 "Requesting opening fee menu from lsp {} with token {:?}",
147 req.lsp_id, req.token
148 );
149
150 let lsp_id = PublicKey::from_str(&req.lsp_id).context("lsp_id is not a valid public key")?;
151
152 let dir = p.configuration().lightning_dir;
153 let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file);
154 let mut cln_client = cln_rpc::ClnRpc::new(rpc_path.clone()).await?;
155
156 let lsp_status = check_peer_lsp_status(&mut cln_client, &req.lsp_id).await?;
157
158 // Fail early: Check that we are connected to the peer.
159 if !lsp_status.connected {
160 bail!("Not connected to peer {}", &req.lsp_id);
161 };
162
163 // From Blip52: LSPs MAY set the features bit numbered 729
164 // (option_supports_lsps)...
165 // We only log that it is not set but don't fail.
166 if !lsp_status.has_lsp_feature {
167 debug!("Peer {} doesn't have the LSP feature bit set.", &req.lsp_id);
168 }
169
170 // 1. Call lsps2.get_info.
171 let client = p.state().client();
172 match client.get_info(&lsp_id, req.token).await?.as_result() {
173 Ok(i) => Ok(serde_json::to_value(i)?),
174 Err(e) => Ok(serde_json::to_value(e)?),
175 }
176}
177
178/// Rpc Method handler for `lsps-lsps2-buy`.
179async fn on_lsps_lsps2_buy(

Callers

nothing calls this directly

Calls 7

check_peer_lsp_statusFunction · 0.85
configurationMethod · 0.80
joinMethod · 0.80
clientMethod · 0.80
stateMethod · 0.80
as_resultMethod · 0.80
get_infoMethod · 0.80

Tested by

no test coverage detected