@@ -7,6 +7,8 @@ use crate::UniffiCustomTypeConverter;
77
88use lightning:: chain:: chainmonitor;
99use lightning:: chain:: keysinterface:: InMemorySigner ;
10+ use lightning:: chain:: transaction:: OutPoint as LdkOutpoint ;
11+ use lightning:: ln:: channelmanager:: ChannelDetails as LdkChannelDetails ;
1012use lightning:: ln:: peer_handler:: IgnoringMessageHandler ;
1113use lightning:: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
1214use lightning:: routing:: gossip;
@@ -339,3 +341,93 @@ impl UniffiCustomTypeConverter for Network {
339341 obj. 0 . to_string ( )
340342 }
341343}
344+
345+ /// Details about the user's channel as returned by [`Node::list_channels`].
346+ ///
347+ /// [`Node::list_channels`]: [`crate::Node::list_channels`]
348+ pub struct ChannelDetails {
349+ /// The channel's ID.
350+ pub channel_id : ChannelId ,
351+ /// The `node_id` of our channel's counterparty.
352+ pub counterparty : PublicKey ,
353+ /// Information about the channel's funding transaction output. `None `unless a funding
354+ /// transaction has been successfully negotiated with the channel's counterparty.
355+ pub funding_txo : Option < OutPoint > ,
356+ /// Position of the funding transaction on-chain. `None` unless the funding transaction has been
357+ /// confirmed and fully opened.
358+ pub short_channel_id : Option < u64 > ,
359+ /// The value, in satoshis, of this channel as appears in the funding output.
360+ pub channel_value_satoshis : u64 ,
361+ /// Total balance of the channel. It is the amount that will be returned to the user if the
362+ /// channel is closed. The value is not exact, due to potential in-flight and fee-rate changes.
363+ /// Therefore, exactly this amount is likely irrecoverable on close.
364+ pub balance_msat : u64 ,
365+ /// Available outbound capacity for sending HTLCs to the remote peer. The amount does not
366+ /// include any pending HTLCs which are not yet resolved (and, thus, whose balance is not
367+ /// available for inclusion in new outbound HTLCs). This further does not include any
368+ /// pending outgoing HTLCs which are awaiting some other resolution to be sent.
369+ pub outbound_capacity_msat : u64 ,
370+ /// Available outbound capacity for sending HTLCs to the remote peer. The amount does not
371+ /// include any pending HTLCs which are not yet resolved (and, thus, whose balance is not
372+ /// available for inclusion in new inbound HTLCs). This further does not include any
373+ /// pending outgoing HTLCs which are awaiting some other resolution to be sent.
374+ pub inbound_capacity_msat : u64 ,
375+ /// The number of required confirmations on the funding transactions before the funding is
376+ /// considered "locked". The amount is selected by the channel fundee.
377+ ///
378+ /// The value will be `None` for outbound channels until the counterparty accepts the channel.
379+ pub confirmations_required : Option < u32 > ,
380+ /// The current number of confirmations on the funding transaction.
381+ pub confirmations : Option < u32 > ,
382+ /// Returns `True` if the channel was initiated (and therefore funded) by us.
383+ pub is_outbound : bool ,
384+ /// Returns `True` if the channel is confirmed, both parties have exchanged `channel_ready`
385+ /// messages, and the channel is not currently being shut down. Both parties exchange
386+ /// `channel_ready` messages upon independently verifying that the required confirmations count
387+ /// provided by `confirmations_required` has been reached.
388+ pub is_channel_ready : bool ,
389+ /// Returns `True` if the channel is (a) confirmed and `channel_ready` has been exchanged,
390+ /// (b) the peer is connected, and (c) the channel is not currently negotiating shutdown.
391+ pub is_usable : bool ,
392+ /// Returns `True` if this channel is (or will be) publicly-announced
393+ pub is_public : bool ,
394+ /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
395+ /// the channel.
396+ pub cltv_expiry_delta : Option < u16 > ,
397+ }
398+
399+ impl From < LdkChannelDetails > for ChannelDetails {
400+ fn from ( value : LdkChannelDetails ) -> Self {
401+ ChannelDetails {
402+ channel_id : ChannelId ( value. channel_id ) ,
403+ counterparty : value. counterparty . node_id ,
404+ funding_txo : value. funding_txo . and_then ( |o| Some ( o. into ( ) ) ) ,
405+ short_channel_id : value. short_channel_id ,
406+ channel_value_satoshis : value. channel_value_satoshis ,
407+ balance_msat : value. balance_msat ,
408+ outbound_capacity_msat : value. outbound_capacity_msat ,
409+ inbound_capacity_msat : value. inbound_capacity_msat ,
410+ confirmations_required : value. confirmations_required ,
411+ confirmations : value. confirmations ,
412+ is_outbound : value. is_outbound ,
413+ is_channel_ready : value. is_channel_ready ,
414+ is_usable : value. is_usable ,
415+ is_public : value. is_public ,
416+ cltv_expiry_delta : value. config . and_then ( |c| Some ( c. cltv_expiry_delta ) ) ,
417+ }
418+ }
419+ }
420+
421+ /// Data structure that references and transaction output.
422+ pub struct OutPoint {
423+ /// The referenced transaction's txid.
424+ pub txid : String ,
425+ /// The index of the referenced output in its transaction's vout.
426+ pub index : u16 ,
427+ }
428+
429+ impl From < LdkOutpoint > for OutPoint {
430+ fn from ( value : LdkOutpoint ) -> Self {
431+ OutPoint { txid : value. txid . to_string ( ) , index : value. index }
432+ }
433+ }
0 commit comments