@@ -15,7 +15,9 @@ use bitcoin::{OutPoint, ScriptBuf};
1515use bitcoin_payment_instructions:: onion_message_resolver:: LDKOnionMessageDNSSECHrnResolver ;
1616use lightning:: chain:: chainmonitor;
1717use lightning:: impl_writeable_tlv_based;
18- use lightning:: ln:: channel_state:: ChannelDetails as LdkChannelDetails ;
18+ use lightning:: ln:: channel_state:: {
19+ ChannelDetails as LdkChannelDetails , ChannelShutdownState as LdkChannelShutdownState ,
20+ } ;
1921use lightning:: ln:: msgs:: { RoutingMessageHandler , SocketAddress } ;
2022use lightning:: ln:: peer_handler:: IgnoringMessageHandler ;
2123use lightning:: ln:: types:: ChannelId ;
@@ -347,6 +349,40 @@ impl fmt::Display for UserChannelId {
347349 }
348350}
349351
352+ /// The shutdown state of a channel as returned in [`ChannelDetails::channel_shutdown_state`].
353+ ///
354+ /// [`ChannelDetails::channel_shutdown_state`]: crate::ChannelDetails::channel_shutdown_state
355+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
356+ #[ cfg_attr( feature = "uniffi" , derive( uniffi:: Enum ) ) ]
357+ pub enum ChannelShutdownState {
358+ /// Channel has not sent or received a shutdown message.
359+ NotShuttingDown ,
360+ /// Local node has sent a shutdown message for this channel.
361+ ShutdownInitiated ,
362+ /// Shutdown message exchanges have concluded and the channels are in the midst of
363+ /// resolving all existing open HTLCs before closing can continue.
364+ ResolvingHTLCs ,
365+ /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates.
366+ NegotiatingClosingFee ,
367+ /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about
368+ /// to drop the channel.
369+ ShutdownComplete ,
370+ }
371+
372+ impl From < LdkChannelShutdownState > for ChannelShutdownState {
373+ fn from ( value : LdkChannelShutdownState ) -> Self {
374+ match value {
375+ LdkChannelShutdownState :: NotShuttingDown => ChannelShutdownState :: NotShuttingDown ,
376+ LdkChannelShutdownState :: ShutdownInitiated => ChannelShutdownState :: ShutdownInitiated ,
377+ LdkChannelShutdownState :: ResolvingHTLCs => ChannelShutdownState :: ResolvingHTLCs ,
378+ LdkChannelShutdownState :: NegotiatingClosingFee => {
379+ ChannelShutdownState :: NegotiatingClosingFee
380+ } ,
381+ LdkChannelShutdownState :: ShutdownComplete => ChannelShutdownState :: ShutdownComplete ,
382+ }
383+ }
384+ }
385+
350386/// Details of a channel as returned by [`Node::list_channels`].
351387///
352388/// When a channel is spliced, most fields continue to refer to the original pre-splice channel
@@ -529,6 +565,10 @@ pub struct ChannelDetails {
529565 pub inbound_htlc_maximum_msat : Option < u64 > ,
530566 /// Set of configurable parameters that affect channel operation.
531567 pub config : ChannelConfig ,
568+ /// The current shutdown state of the channel, if any.
569+ ///
570+ /// Returns `None` for channels that have not yet started the shutdown process.
571+ pub channel_shutdown_state : Option < ChannelShutdownState > ,
532572}
533573
534574impl From < LdkChannelDetails > for ChannelDetails {
@@ -584,6 +624,7 @@ impl From<LdkChannelDetails> for ChannelDetails {
584624 inbound_htlc_maximum_msat : value. inbound_htlc_maximum_msat ,
585625 // unwrap safety: `config` is only `None` for LDK objects serialized prior to 0.0.109.
586626 config : value. config . map ( |c| c. into ( ) ) . unwrap ( ) ,
627+ channel_shutdown_state : value. channel_shutdown_state . map ( |s| s. into ( ) ) ,
587628 }
588629 }
589630}
0 commit comments