Skip to main content

NodeState

Struct NodeState 

Source
pub struct NodeState {
Show 24 fields pub id: String, pub block_height: u32, pub network: String, pub version: String, pub alias: Option<String>, pub color: String, pub num_active_channels: u32, pub num_pending_channels: u32, pub num_inactive_channels: u32, pub channels_balance_msat: u64, pub max_payable_msat: u64, pub total_channel_capacity_msat: u64, pub max_chan_reserve_msat: u64, pub onchain_balance_msat: u64, pub unconfirmed_onchain_balance_msat: u64, pub immature_onchain_balance_msat: u64, pub pending_onchain_balance_msat: u64, pub max_receivable_single_payment_msat: u64, pub total_inbound_liquidity_msat: u64, pub connected_channel_peers: Vec<String>, pub utxos: Vec<FundOutput>, pub total_onchain_msat: u64, pub total_balance_msat: u64, pub spendable_balance_msat: u64,
}
Expand description

A point-in-time snapshot of the node’s balances, capacity, and connectivity. Returned by node_state().

All amounts are in millisatoshis (1 sat = 1000 msat).

Fields§

§id: String

The node’s public key as a lowercase hex string (66 chars).

§block_height: u32

Latest block height the node has synced to.

§network: String

The Bitcoin network this node is running on (e.g. “bitcoin”, “regtest”).

§version: String

CLN version string (e.g. “v24.11”).

§alias: Option<String>

Human-readable node alias, if set.

§color: String

3-byte RGB color of the node, as a lowercase hex string (6 chars).

§num_active_channels: u32

Number of channels that are open and operational. These are the channels that contribute to channels_balance_msat, max_payable_msat, total_channel_capacity_msat, and total_inbound_liquidity_msat.

§num_pending_channels: u32

Number of channels that are being opened but not yet confirmed. Pending channels do not contribute to any balance or capacity field on this snapshot; their funds show up only after they transition to active.

§num_inactive_channels: u32

Number of channels that are open but the peer is offline. Inactive channels hold balance but cannot be used for payments until the peer reconnects; they do not contribute to max_payable_msat or total_inbound_liquidity_msat (those are computed from the live spendable_msat / receivable_msat reported by CLN, which goes to zero when the peer is offline).

§channels_balance_msat: u64

Total our-side balance across all open channels, including amounts that protocol reserves make unspendable.

This is the field a wallet’s home screen should show as the user’s “Lightning balance” — it reflects what they own off-chain, matching what they’d expect to see at a glance.

Do not use this to gate a send button: some of it is locked in channel reserves. Use max_payable_msat for that.

§max_payable_msat: u64

Aggregate spendable amount across all open channels. Equal to channels_balance_msat - max_chan_reserve_msat.

This is the field a send screen should gate against — it is what the user can actually move right now over Lightning in total.

Caveat: a single Lightning payment is additionally bounded by the largest channel’s own spendable_msat. Reaching this full aggregate amount in one payment requires multi-path-payment support from the recipient and a working route.

§total_channel_capacity_msat: u64

Sum of all open channel capacities (your side + remote side).

§max_chan_reserve_msat: u64

Amount locked in protocol channel reserves, computed as channels_balance_msat - max_payable_msat. These sats are yours on paper but cannot be spent until the channel closes.

§onchain_balance_msat: u64

Confirmed on-chain balance available for spending or opening channels.

§unconfirmed_onchain_balance_msat: u64

On-chain balance from transactions that have not yet been confirmed.

§immature_onchain_balance_msat: u64

On-chain balance confirmed but not yet spendable (e.g. coinbase outputs inside the 100-block maturation window).

§pending_onchain_balance_msat: u64

On-chain balance locked in channels that are being closed. These funds will become available once the close is confirmed.

§max_receivable_single_payment_msat: u64

Largest single Lightning payment the node can receive without splitting across channels. Bounded by the inbound capacity of the largest open channel.

§total_inbound_liquidity_msat: u64

Total amount you can receive across all open channels combined.

§connected_channel_peers: Vec<String>

Lowercase hex public keys of peers we have at least one channel with and are currently connected to. Peers we’re connected to but have no channel with are not represented here; for routing-node use cases, query list_peers() directly.

§utxos: Vec<FundOutput>

Unspent on-chain outputs owned by the node’s wallet. Excludes spent outputs; includes confirmed, unconfirmed, immature, and reserved UTXOs (callers can filter by status and reserved).

§total_onchain_msat: u64

All non-pending on-chain balance buckets summed: onchain_balance_msat + unconfirmed_onchain_balance_msat + immature_onchain_balance_msat. Excludes funds locked in closing channels (pending_onchain_balance_msat) since those are not yet on-chain UTXOs.

§total_balance_msat: u64

Everything the user owns, summed: channel balance (including protocol reserves) + all on-chain buckets + funds locked in closing channels. The “total holdings” number a wallet home screen typically shows.

§spendable_balance_msat: u64

What the user can spend right now: max_payable_msat + onchain_balance_msat. Excludes reserves, unconfirmed, immature, and pending amounts. The number a send-money screen should gate against.

Trait Implementations§

Source§

impl Clone for NodeState

Source§

fn clone(&self) -> NodeState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<UT> ConvertError<UT> for NodeState

Source§

impl<UT> FfiConverter<UT> for NodeState

Source§

const TYPE_ID_META: MetadataBuffer

Type ID metadata, serialized into a MetadataBuffer.
Source§

type FfiType = RustBuffer

The low-level type used for passing values of this type over the FFI. Read more
Source§

fn lower(v: Self) -> RustBuffer

Lower a rust value of the target type, into an FFI value of type Self::FfiType. Read more
Source§

fn try_lift(buf: RustBuffer) -> Result<Self>

Lift a rust value of the target type, from an FFI value of type Self::FfiType. Read more
Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Write a rust value into a buffer, to send over the FFI in serialized form. Read more
Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Read a rust value from a buffer, received over the FFI in serialized form. Read more
Source§

impl<UT> Lift<UT> for NodeState

Source§

type FfiType = <NodeState as FfiConverter<UT>>::FfiType

Source§

fn try_lift(v: Self::FfiType) -> Result<Self>

Source§

fn try_read(buf: &mut &[u8]) -> Result<Self>

Source§

fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>

Convenience method
Source§

impl<UT> LiftRef<UT> for NodeState

Source§

impl<UT> LiftReturn<UT> for NodeState

Source§

type ReturnType = <NodeState as Lift<UT>>::FfiType

FFI return type for trait interfaces
Source§

fn try_lift_successful_return(v: Self::ReturnType) -> Result<Self>

Lift a successfully returned value from a trait interface
Source§

fn lift_foreign_return( ffi_return: Self::ReturnType, call_status: RustCallStatus, ) -> Self

Lift a foreign returned value from a trait interface Read more
Source§

fn lift_error(_buf: RustBuffer) -> Self

Lift a Rust value for a callback interface method error result Read more
Source§

fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self

Lift a Rust value for an unexpected callback interface error Read more
Source§

impl<UT> Lower<UT> for NodeState

Source§

type FfiType = <NodeState as FfiConverter<UT>>::FfiType

Source§

fn lower(obj: Self) -> Self::FfiType

Source§

fn write(obj: Self, buf: &mut Vec<u8>)

Source§

fn lower_into_rust_buffer(obj: Self) -> RustBuffer

Convenience method
Source§

impl<UT> LowerError<UT> for NodeState

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for NodeState

Source§

type ReturnType = <NodeState as Lower<UT>>::FfiType

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

fn lower_return(v: 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 Serialize for NodeState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<UT> TypeId<UT> for NodeState

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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