Struct clightningrpc::lightningrpc::LightningRPC
source · pub struct LightningRPC { /* private fields */ }
Expand description
Structure providing a high-level interface to the c-lightning daemon RPC
Implementations§
source§impl LightningRPC
impl LightningRPC
sourcepub fn new<P: AsRef<Path>>(sockpath: P) -> LightningRPC
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.
sourcepub fn call<T: Serialize, U: DeserializeOwned>(
&self,
method: &str,
input: T
) -> Result<U, Error>
pub fn call<T: Serialize, U: DeserializeOwned>( &self, method: &str, input: T ) -> Result<U, Error>
Generic call function for RPC calls.
sourcepub fn feerates(&self, style: &str) -> Result<FeeRates, Error>
pub fn feerates(&self, style: &str) -> Result<FeeRates, Error>
Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb).
sourcepub fn listnodes(&self, id: Option<&str>) -> Result<ListNodes, Error>
pub fn listnodes(&self, id: Option<&str>) -> Result<ListNodes, Error>
Show node {id} (or all, if no {id}), in our local network view.
sourcepub fn listchannels(
&self,
short_channel_id: Option<&str>,
source: Option<&str>,
destination: Option<&str>
) -> Result<ListChannels, Error>
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}).
sourcepub fn help(&self, command: Option<&str>) -> Result<Help, Error>
pub fn help(&self, command: Option<&str>) -> Result<Help, Error>
List available commands, or give verbose help on one command.
sourcepub fn getlog(&self, level: Option<&str>) -> Result<GetLog, Error>
pub fn getlog(&self, level: Option<&str>) -> Result<GetLog, Error>
Show logs, with optional log {level} (info|unusual|debug|io).
sourcepub fn listconfigs(&self, config: Option<&str>) -> Result<ListConfigs, Error>
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.
sourcepub fn listpeers(
&self,
id: Option<&str>,
level: Option<&str>
) -> Result<ListPeers, Error>
pub fn listpeers( &self, id: Option<&str>, level: Option<&str> ) -> Result<ListPeers, Error>
Show current peers, if {level} is set, include {log}s.
sourcepub fn listinvoices(
&self,
label: Option<&str>,
invstring: Option<&str>,
payment_hash: Option<&str>,
offer_id: Option<&str>
) -> Result<ListInvoices, Error>
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)).
sourcepub fn invoice(
&self,
amount_msat: Option<u64>,
label: &str,
description: &str,
preimage: Option<&str>,
expiry: Option<u64>,
deschashonly: Option<bool>
) -> Result<Invoice, Error>
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).
sourcepub fn createinvoice(
&self,
invstring: &str,
label: &str,
preimage: &str
) -> Result<Invoice, Error>
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}
sourcepub fn delinvoice(&self, label: &str, status: &str) -> Result<DelInvoice, Error>
pub fn delinvoice(&self, label: &str, status: &str) -> Result<DelInvoice, Error>
Delete unpaid invoice {label} with {status}
sourcepub fn delexpiredinvoice(
&self,
maxexpirytime: Option<u64>
) -> Result<DelExpiredInvoice, Error>
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.
sourcepub fn autocleaninvoice(
&self,
cycle_seconds: Option<u64>,
expired_by: Option<u64>
) -> Result<AutoCleanInvoice, Error>
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).
sourcepub fn waitanyinvoice(
&self,
lastpay_index: Option<u64>
) -> Result<WaitAnyInvoice, Error>
pub fn waitanyinvoice( &self, lastpay_index: Option<u64> ) -> Result<WaitAnyInvoice, Error>
Wait for the next invoice to be paid, after {lastpay_index}. (if supplied)
sourcepub fn waitinvoice(&self, label: &str) -> Result<WaitInvoice, Error>
pub fn waitinvoice(&self, label: &str) -> Result<WaitInvoice, Error>
Wait for an incoming payment matching the invoice with {label}.
sourcepub fn pay(&self, bolt11: &str, options: PayOptions<'_>) -> Result<Pay, Error>
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. UseDefault::default()
to not pass any options.
sourcepub fn sendpay(
&self,
route: Vec<RouteItem>,
payment_hash: &str,
description: Option<&str>,
msatoshi: Option<u64>
) -> Result<SendPay, Error>
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}.
sourcepub fn waitsendpay(
&self,
payment_hash: &str,
timeout: u64
) -> Result<WaitSendPay, Error>
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.
sourcepub fn listsendpays(
&self,
bolt11: Option<&str>,
payment_hash: Option<&str>
) -> Result<ListSendPays, Error>
pub fn listsendpays( &self, bolt11: Option<&str>, payment_hash: Option<&str> ) -> Result<ListSendPays, Error>
Show outgoing payments.
sourcepub fn decodepay(
&self,
bolt11: &str,
description: Option<&str>
) -> Result<DecodePay, Error>
pub fn decodepay( &self, bolt11: &str, description: Option<&str> ) -> Result<DecodePay, Error>
Decode {bolt11}, using {description} if necessary.
sourcepub fn getroute(
&self,
id: &str,
msatoshi: u64,
riskfactor: f64,
cltv: Option<u64>,
fromid: Option<&str>,
fuzzpercent: Option<f64>,
seed: Option<&str>
) -> Result<GetRoute, Error>
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.
sourcepub fn connect(&self, id: &str, host: Option<&str>) -> Result<Connect, Error>
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.
sourcepub fn disconnect(&self, id: &str) -> Result<Disconnect, Error>
pub fn disconnect(&self, id: &str) -> Result<Disconnect, Error>
Disconnect from peer with {peer_id}.
sourcepub fn fundchannel(
&self,
id: &str,
amount: AmountOrAll,
feerate: Option<u64>
) -> Result<FundChannel, Error>
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 toamount
- eitherAmountOrAll::Amount(n)
for a given amount in satoshi units, orAmountOrAll::All
to spend all available fundsfeerate
- optional feerate to use for Bitcoin transaction
sourcepub fn close(
&self,
id: &str,
force: Option<bool>,
timeout: Option<u64>
) -> Result<Close, Error>
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.
sourcepub fn ping(
&self,
id: &str,
len: Option<u64>,
pongbytes: Option<u64>
) -> Result<Ping, Error>
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).
sourcepub fn listfunds(&self) -> Result<ListFunds, Error>
pub fn listfunds(&self) -> Result<ListFunds, Error>
Show available funds from the internal wallet.
sourcepub fn withdraw(
&self,
destination: &str,
satoshi: AmountOrAll,
feerate: Option<u64>,
minconf: Option<u32>
) -> Result<Withdraw, Error>
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 toamount
- eitherAmountOrAll::Amount(n)
for a given amount in satoshi units, orAmountOrAll::All
to spend all available fundsfeerate
- optional feerate to use for Bitcoin transaction