pub struct CommandoClient { /* private fields */ }Expand description
Public client for Core Lightning Commando over an LNSocket.
Spawns a background task to:
- write requests with generated IDs,
- read fragments (
COMMANDO_REPLY_CONT) and accumulate bytes, - parse JSON on terminal chunk (
COMMANDO_REPLY_TERM), - optionally reconnect and resend per
RetryPolicy.
§Usage
let key = SecretKey::new(&mut rand::thread_rng());
let sock = LNSocket::connect_and_init(key, pk, "ln.example.com:9735").await?;
let client = CommandoClient::spawn(sock, rune);
// Default policy (see `CommandoConfig::default()`):
let v = client.call("listpeers", json!({})).await?;
// Per-call overrides:
use lnsocket::commando::CallOpts;
let opts = CallOpts::new().retry(5).timeout(std::time::Duration::from_secs(10));
let v2 = client.call_with_opts("getchaninfo", json!({"channel": "..." }), opts).await?;Implementations§
Source§impl CommandoClient
impl CommandoClient
Sourcepub fn spawn_with_config(
sock: LNSocket,
rune: impl Into<String>,
config: CommandoConfig,
) -> Self
pub fn spawn_with_config( sock: LNSocket, rune: impl Into<String>, config: CommandoConfig, ) -> Self
Spawn the background pump that owns the LNSocket.
pub fn spawn(sock: LNSocket, rune: impl Into<String>) -> Self
pub async fn call( &self, method: impl Into<String>, params: Value, ) -> Result<Value, Error>
pub async fn call_with_opts( &self, method: impl Into<String>, params: Value, opts: CallOpts, ) -> Result<Value, Error>
Auto Trait Implementations§
impl !Freeze for CommandoClient
impl RefUnwindSafe for CommandoClient
impl Send for CommandoClient
impl Sync for CommandoClient
impl Unpin for CommandoClient
impl UnsafeUnpin for CommandoClient
impl UnwindSafe for CommandoClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more