pub struct Node { /* private fields */ }Expand description
The Node is an RPC stub representing the node running in the
cloud. It is the main entrypoint to interact with the node.
Implementations§
Source§impl Node
impl Node
pub fn new(credentials: &Credentials) -> Result<Self, Error>
Sourcepub fn credentials(&self) -> Result<Vec<u8>, Error>
pub fn credentials(&self) -> Result<Vec<u8>, Error>
Returns the serialized credentials for this node. The app should persist these bytes and pass them to connect() on next launch.
Sourcepub fn disconnect(&self) -> Result<(), Error>
pub fn disconnect(&self) -> Result<(), Error>
Disconnects from the node and stops the signer if running. After disconnect, all RPC methods will return an error. Safe to call multiple times.
Sourcepub fn receive(
&self,
label: String,
description: String,
amount_msat: Option<u64>,
) -> Result<ReceiveResponse, Error>
pub fn receive( &self, label: String, description: String, amount_msat: Option<u64>, ) -> Result<ReceiveResponse, Error>
Receive an off-chain payment.
This method generates a request for a payment, also called an invoice, that encodes all the information, including amount and destination, for a prospective sender to send a lightning payment. The invoice includes negotiation of an LSPS2 / JIT channel, meaning that if there is no channel sufficient to receive the requested funds, the node will negotiate an opening, and when/if executed the payment will cause a channel to be created, and the incoming payment to be forwarded.
pub fn send( &self, invoice: String, amount_msat: Option<u64>, ) -> Result<SendResponse, Error>
Sourcepub fn onchain_send(
&self,
destination: String,
amount_or_all: String,
) -> Result<OnchainSendResponse, Error>
pub fn onchain_send( &self, destination: String, amount_or_all: String, ) -> Result<OnchainSendResponse, Error>
Send bitcoin on-chain to a destination address.
§Arguments
destination— A Bitcoin address (bech32, p2sh, or p2tr).amount_or_all— Amount to send. Accepts:"50000"or"50000sat"— 50,000 satoshis"50000msat"— 50,000 millisatoshis"all"— sweep the entire on-chain balance
Returns the raw transaction, txid, and PSBT once broadcast. The transaction is broadcast immediately — this is not a dry run.
Sourcepub fn onchain_receive(&self) -> Result<OnchainReceiveResponse, Error>
pub fn onchain_receive(&self) -> Result<OnchainReceiveResponse, Error>
Generate a fresh on-chain Bitcoin address for receiving funds.
Returns both a bech32 (SegWit v0) and a p2tr (Taproot) address.
Either can be shared with a sender. Deposited funds will appear
in node_state().onchain_balance_msat once confirmed.
Sourcepub fn get_info(&self) -> Result<GetInfoResponse, Error>
pub fn get_info(&self) -> Result<GetInfoResponse, Error>
Get information about the node.
Returns basic information about the node including its ID, alias, network, and channel counts.
Sourcepub fn list_peers(&self) -> Result<ListPeersResponse, Error>
pub fn list_peers(&self) -> Result<ListPeersResponse, Error>
List all peers connected to this node.
Returns information about all peers including their connection status.
Sourcepub fn list_peer_channels(&self) -> Result<ListPeerChannelsResponse, Error>
pub fn list_peer_channels(&self) -> Result<ListPeerChannelsResponse, Error>
List all channels with peers.
Returns detailed information about all channels including their state, capacity, and balances.
Sourcepub fn list_funds(&self) -> Result<ListFundsResponse, Error>
pub fn list_funds(&self) -> Result<ListFundsResponse, Error>
List all funds available to the node.
Returns information about on-chain outputs and channel funds that are available or pending.
Sourcepub fn list_invoices(
&self,
label: Option<String>,
invstring: Option<String>,
payment_hash: Option<Vec<u8>>,
offer_id: Option<String>,
index: Option<ListIndex>,
start: Option<u64>,
limit: Option<u32>,
) -> Result<ListInvoicesResponse, Error>
pub fn list_invoices( &self, label: Option<String>, invstring: Option<String>, payment_hash: Option<Vec<u8>>, offer_id: Option<String>, index: Option<ListIndex>, start: Option<u64>, limit: Option<u32>, ) -> Result<ListInvoicesResponse, Error>
List all invoices (received payment requests). List invoices (received payment requests). All parameters are optional filters; pass None to fetch all.
Sourcepub fn list_pays(
&self,
bolt11: Option<String>,
payment_hash: Option<Vec<u8>>,
status: Option<PayStatus>,
index: Option<ListIndex>,
start: Option<u64>,
limit: Option<u32>,
) -> Result<ListPaysResponse, Error>
pub fn list_pays( &self, bolt11: Option<String>, payment_hash: Option<Vec<u8>>, status: Option<PayStatus>, index: Option<ListIndex>, start: Option<u64>, limit: Option<u32>, ) -> Result<ListPaysResponse, Error>
List outgoing payments. All parameters are optional filters; pass None to fetch all.
Sourcepub fn list_payments(
&self,
req: ListPaymentsRequest,
) -> Result<Vec<Payment>, Error>
pub fn list_payments( &self, req: ListPaymentsRequest, ) -> Result<Vec<Payment>, Error>
List payments (sent and received), merged into a single timeline.
Fetches invoices and outgoing payments from the node, merges
them into a unified list, and applies optional filters.
Use list_invoices/list_pays for direct CLN access.
Results are sorted newest-first.
Sourcepub fn stream_node_events(&self) -> Result<Arc<NodeEventStream>, Error>
pub fn stream_node_events(&self) -> Result<Arc<NodeEventStream>, Error>
Stream real-time events from the node.
Returns a NodeEventStream iterator. Call next() repeatedly
to receive events as they occur (e.g., invoice payments).
The next() method blocks the calling thread until an event
is available, but does not block the underlying async runtime,
so other node methods can be called concurrently from other
threads.
Trait Implementations§
Source§impl<UT> LowerError<UT> for Node
impl<UT> LowerError<UT> for Node
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for Node
impl<UT> LowerReturn<UT> for Node
Source§type ReturnType = <Arc<Node> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<Node> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Auto Trait Implementations§
impl !Freeze for Node
impl !RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl !UnwindSafe for Node
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request