Skip to main content

Node

Struct Node 

Source
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

Source

pub fn new(credentials: &Credentials) -> Result<Self, Error>

Source

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

Stop the node if it is currently running.

Source

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.

Source

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.

Source

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.

Source

pub fn send( &self, invoice: String, amount_msat: Option<u64>, ) -> Result<SendResponse, Error>

Source

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.

Source

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.

Source

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.

Source

pub fn list_peers(&self) -> Result<ListPeersResponse, Error>

List all peers connected to this node.

Returns information about all peers including their connection status.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> LiftRef<UT> for Node

Source§

impl<UT> LowerError<UT> for Node

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for Node

Source§

type ReturnType = <Arc<Node> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for Node

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<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more