pub struct LightningRPC { /* private fields */ }
Expand description

Structure providing a high-level interface to the c-lightning daemon RPC

Implementations§

source§

impl LightningRPC

source

pub fn new<P: AsRef<Path>>(sockpath: P) -> LightningRPC

Create a new connection from a UNIX socket path.

Arguments
  • sockpath - Path of UNIX socket to connect to, by default lightningd will create a socket named .lightning/lightning-rpc in the home directory of the user running lightningd.
source

pub fn client(&mut self) -> &mut Client

Get reference to the low-level client connection

source

pub fn call<T: Serialize, U: DeserializeOwned>( &self, method: &str, input: T ) -> Result<U, Error>

Generic call function for RPC calls.

source

pub fn getinfo(&self) -> Result<GetInfo, Error>

Show information about this node.

source

pub fn feerates(&self, style: &str) -> Result<FeeRates, Error>

Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb).

source

pub fn listnodes(&self, id: Option<&str>) -> Result<ListNodes, Error>

Show node {id} (or all, if no {id}), in our local network view.

source

pub fn listchannels( &self, short_channel_id: Option<&str>, source: Option<&str>, destination: Option<&str> ) -> Result<ListChannels, Error>

Show channel {short_channel_id} (or all known channels, if no {short_channel_id}).

source

pub fn help(&self, command: Option<&str>) -> Result<Help, Error>

List available commands, or give verbose help on one command.

source

pub fn getlog(&self, level: Option<&str>) -> Result<GetLog, Error>

Show logs, with optional log {level} (info|unusual|debug|io).

source

pub fn listconfigs(&self, config: Option<&str>) -> Result<ListConfigs, Error>

List all configuration options, or with [config], just that one. Because of the dynamic nature of the returned object, unlike the other methods, this returns a HashMap (from &str to Json) instead of a structure.

source

pub fn listpeers( &self, id: Option<&str>, level: Option<&str> ) -> Result<ListPeers, Error>

Show current peers, if {level} is set, include {log}s.

source

pub fn listinvoices( &self, label: Option<&str>, invstring: Option<&str>, payment_hash: Option<&str>, offer_id: Option<&str> ) -> Result<ListInvoices, Error>

Show invoice {label} (or all, if no {label)).

source

pub fn invoice( &self, amount_msat: Option<u64>, label: &str, description: &str, preimage: Option<&str>, expiry: Option<u64>, deschashonly: Option<bool> ) -> Result<Invoice, Error>

Create an invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 hour).

source

pub fn createinvoice( &self, invstring: &str, label: &str, preimage: &str ) -> Result<Invoice, Error>

Lowlevel command to sign and create invoice {invstring}, resolved with {preimage}, using unique {label}

source

pub fn delinvoice(&self, label: &str, status: &str) -> Result<DelInvoice, Error>

Delete unpaid invoice {label} with {status}

source

pub fn delexpiredinvoice( &self, maxexpirytime: Option<u64> ) -> Result<DelExpiredInvoice, Error>

Delete all expired invoices that expired as of given {maxexpirytime} (a UNIX epoch time), or all expired invoices if not specified.

source

pub fn autocleaninvoice( &self, cycle_seconds: Option<u64>, expired_by: Option<u64> ) -> Result<AutoCleanInvoice, Error>

Set up autoclean of expired invoices. Perform cleanup every {cycle_seconds} (default 3600), or disable autoclean if 0. Clean up expired invoices that have expired for {expired_by} seconds (default 86400).

source

pub fn waitanyinvoice( &self, lastpay_index: Option<u64> ) -> Result<WaitAnyInvoice, Error>

Wait for the next invoice to be paid, after {lastpay_index}. (if supplied)

source

pub fn waitinvoice(&self, label: &str) -> Result<WaitInvoice, Error>

Wait for an incoming payment matching the invoice with {label}.

source

pub fn pay(&self, bolt11: &str, options: PayOptions<'_>) -> Result<Pay, Error>

Send a lightning payment.

Arguments
  • bolt11 - A string that holds the payment information in bolt11 format.
  • options - Options for this payment. Use Default::default() to not pass any options.
source

pub fn sendpay( &self, route: Vec<RouteItem>, payment_hash: &str, description: Option<&str>, msatoshi: Option<u64> ) -> Result<SendPay, Error>

Send along {route} in return for preimage of {payment_hash}, with optional {description}.

source

pub fn waitsendpay( &self, payment_hash: &str, timeout: u64 ) -> Result<WaitSendPay, Error>

Wait for payment attempt on {payment_hash} to succeed or fail, but only up to {timeout} seconds.

source

pub fn listsendpays( &self, bolt11: Option<&str>, payment_hash: Option<&str> ) -> Result<ListSendPays, Error>

Show outgoing payments.

source

pub fn decodepay( &self, bolt11: &str, description: Option<&str> ) -> Result<DecodePay, Error>

Decode {bolt11}, using {description} if necessary.

source

pub fn getroute( &self, id: &str, msatoshi: u64, riskfactor: f64, cltv: Option<u64>, fromid: Option<&str>, fuzzpercent: Option<f64>, seed: Option<&str> ) -> Result<GetRoute, Error>

Show route to {id} for {msatoshi}, using {riskfactor} and optional {cltv} (default 9). If specified search from {fromid} otherwise use this node as source. Randomize the route with up to {fuzzpercent} (0.0 -> 100.0, default 5.0) using {seed} as an arbitrary-size string seed.

source

pub fn connect(&self, id: &str, host: Option<&str>) -> Result<Connect, Error>

Connect to {id} at {host} (which can end in ‘:port’ if not default). {id} can also be of the form id@host.

source

pub fn disconnect(&self, id: &str) -> Result<Disconnect, Error>

Disconnect from peer with {peer_id}.

source

pub fn fundchannel( &self, id: &str, amount: AmountOrAll, feerate: Option<u64> ) -> Result<FundChannel, Error>

Fund a new channel with another lightning node.

Arguments
  • id - Id of node to fund a channel to
  • amount - either AmountOrAll::Amount(n) for a given amount in satoshi units, or AmountOrAll::All to spend all available funds
  • feerate - optional feerate to use for Bitcoin transaction
source

pub fn close( &self, id: &str, force: Option<bool>, timeout: Option<u64> ) -> Result<Close, Error>

Close the channel with {id} (either peer ID, channel ID, or short channel ID). If {force} (default false) is true, force a unilateral close after {timeout} seconds (default 30), otherwise just schedule a mutual close later and fail after timing out.

source

pub fn ping( &self, id: &str, len: Option<u64>, pongbytes: Option<u64> ) -> Result<Ping, Error>

Send {peerid} a ping of length {len} (default 128) asking for {pongbytes} (default 128).

source

pub fn listfunds(&self) -> Result<ListFunds, Error>

Show available funds from the internal wallet.

source

pub fn withdraw( &self, destination: &str, satoshi: AmountOrAll, feerate: Option<u64>, minconf: Option<u32> ) -> Result<Withdraw, Error>

Send to destination address via Bitcoin transaction.

Arguments
  • destination - Bitcoin address to send to
  • amount - either AmountOrAll::Amount(n) for a given amount in satoshi units, or AmountOrAll::All to spend all available funds
  • feerate - optional feerate to use for Bitcoin transaction
source

pub fn newaddr(&self, addresstype: Option<&str>) -> Result<NewAddr, Error>

Get a new {bech32, p2sh-segwit} address to fund a channel (default is bech32).

source

pub fn stop(&self) -> Result<Stop, Error>

Shut down the lightningd process.

Trait Implementations§

source§

impl Debug for LightningRPC

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.