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

Function on_lsps_lsps2_approve

plugins/lsps-plugin/src/client.rs:266–298  ·  view source on GitHub ↗
(
    p: cln_plugin::Plugin<State>,
    v: serde_json::Value,
)

Source from the content-addressed store, hash-verified

264}
265
266async fn on_lsps_lsps2_approve(
267 p: cln_plugin::Plugin<State>,
268 v: serde_json::Value,
269) -> Result<serde_json::Value, anyhow::Error> {
270 let req: ClnRpcLsps2Approve = serde_json::from_value(v)?;
271 let ds_rec = DatastoreRecord {
272 jit_channel_scid: req.jit_channel_scid.clone(),
273 client_trusts_lsp: req.client_trusts_lsp.unwrap_or_default(),
274 };
275 let ds_rec_json = serde_json::to_string(&ds_rec)?;
276
277 let dir = p.configuration().lightning_dir;
278 let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file);
279 let mut cln_client = cln_rpc::ClnRpc::new(rpc_path.clone()).await?;
280
281 let ds_req = DatastoreRequest {
282 generation: None,
283 hex: None,
284 mode: Some(DatastoreMode::CREATE_OR_REPLACE),
285 string: Some(ds_rec_json),
286 key: vec!["lsps".to_string(), "client".to_string(), req.lsp_id.clone()],
287 };
288 let _ds_res = cln_client.call_typed(&ds_req).await?;
289 let ds_req = DatastoreRequest {
290 generation: None,
291 hex: None,
292 mode: Some(DatastoreMode::CREATE_OR_REPLACE),
293 string: Some(req.lsp_id),
294 key: vec!["lsps".to_string(), "invoice".to_string(), req.payment_hash],
295 };
296 let _ds_res = cln_client.call_typed(&ds_req).await?;
297 Ok(serde_json::Value::default())
298}
299
300/// RPC Method handler for `lsps-jitchannel`.
301/// Calls lsps2.get_info, selects parameters, calculates fee, calls lsps2.buy,

Callers

nothing calls this directly

Calls 4

configurationMethod · 0.80
joinMethod · 0.80
call_typedMethod · 0.80
to_stringFunction · 0.50

Tested by

no test coverage detected