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

Method rpcmethod

plugins/src/lib.rs:278–294  ·  view source on GitHub ↗

Register a custom RPC method for the RPC passthrough from the main daemon

(mut self, name: &str, description: &str, callback: C)

Source from the content-addressed store, hash-verified

276 /// Register a custom RPC method for the RPC passthrough from the
277 /// main daemon
278 pub fn rpcmethod<C, F>(mut self, name: &str, description: &str, callback: C) -> Builder<S, I, O>
279 where
280 C: Send + Sync + 'static,
281 C: Fn(Plugin<S>, Request) -> F + 'static,
282 F: Future<Output = Response> + Send + 'static,
283 {
284 self.rpcmethods.insert(
285 name.to_string(),
286 RpcMethod {
287 name: name.to_string(),
288 description: description.to_string(),
289 usage: String::default(),
290 callback: Box::new(move |p, r| Box::pin(callback(p, r))),
291 },
292 );
293 self
294 }
295
296 pub fn rpcmethod_from_builder(mut self, rpc_method: RpcMethodBuilder<S>) -> Builder<S, I, O> {
297 self.rpcmethods

Callers 3

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 2

insertMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected