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

Method call_raw

cln-rpc/src/lib.rs:171–195  ·  view source on GitHub ↗

Low-level API to call the rpc. An interesting choice of `R` and `P` is [`serde_json::Value`] because it allows ad-hoc calls to custom RPC-methods If you are using a model such as [`crate::model::requests::GetinfoRequest`] you'd probably want to use [`Self::call_typed`] instead. Example: ```no_run use cln_rpc::ClnRpc; use cln_rpc::model::{requests::GetinfoRequest, responses::GetinfoResponse, res

(&mut self, method: &str, params: &P)

Source from the content-addressed store, hash-verified

169 /// })
170 /// ```
171 pub async fn call_raw<R, P>(&mut self, method: &str, params: &P) -> Result<R, RpcError>
172 where
173 P: Serialize + Debug,
174 R: DeserializeOwned + Debug,
175 {
176 trace!("Sending request {} with params {:?}", method, &params);
177 let id = self.next_id.fetch_add(1, Ordering::SeqCst);
178
179 // TODO: Can we make this nicer
180 // I don't want to have this json_rpc : 2.0 floating everywhere
181 let req = serde_json::json!({
182 "jsonrpc" : "2.0",
183 "id" : id,
184 "method" : method,
185 "params" : params,
186 });
187
188 let response: serde_json::Value = self.call_raw_request(req).await?;
189
190 serde_json::from_value(response).map_err(|e| RpcError {
191 code: None,
192 message: format!("Failed to parse response {:?}", e),
193 data: None,
194 })
195 }
196
197 /// A low level method to call raw requests
198 ///

Callers 9

call_enumMethod · 0.80
call_rawFunction · 0.80
check_proxy_configFunction · 0.80
call_rpcFunction · 0.80
on_lsps_lsps2_invoiceFunction · 0.80
get_offerMethod · 0.80
get_channel_capacityMethod · 0.80
get_offerMethod · 0.80
get_channel_capacityMethod · 0.80

Calls 1

call_raw_requestMethod · 0.80

Tested by 1

call_rawFunction · 0.64