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

Method rpcmethod

plugins/src/lib.rs:277–293  ·  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

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