@@ -154,6 +154,23 @@ impl Readable for UserChannelId {
154154 }
155155}
156156
157+ /// The type of a channel, as negotiated during channel opening.
158+ ///
159+ /// See [`BOLT 2`] for more information.
160+ ///
161+ /// [`BOLT 2`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#defined-channel-types
162+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
163+ pub enum ChannelType {
164+ /// A channel of type `option_static_remotekey`.
165+ StaticRemoteKey ,
166+ /// A channel of type `option_static_remotekey` that requires 0conf support.
167+ StaticRemoteKey0conf ,
168+ /// A channel of type `option_anchors_zero_fee_htlc_tx`.
169+ Anchors ,
170+ /// A channel of type `option_anchors_zero_fee_htlc_tx` that requires 0conf support.
171+ Anchors0conf ,
172+ }
173+
157174/// Details of a channel as returned by [`Node::list_channels`].
158175///
159176/// [`Node::list_channels`]: crate::Node::list_channels
@@ -171,6 +188,10 @@ pub struct ChannelDetails {
171188 /// The channel's funding transaction output, if we've negotiated the funding transaction with
172189 /// our counterparty already.
173190 pub funding_txo : Option < OutPoint > ,
191+ /// The channel type as negotiated during channel opening.
192+ ///
193+ /// Will be `None` until the channel negotiation has been completed.
194+ pub channel_type : Option < ChannelType > ,
174195 /// The value, in satoshis, of this channel as it appears in the funding output.
175196 pub channel_value_sats : u64 ,
176197 /// The value, in satoshis, that must always be held as a reserve in the channel for us. This
@@ -284,10 +305,27 @@ pub struct ChannelDetails {
284305
285306impl From < LdkChannelDetails > for ChannelDetails {
286307 fn from ( value : LdkChannelDetails ) -> Self {
308+ let channel_type = value. channel_type . map ( |t| {
309+ if t. supports_anchors_zero_fee_htlc_tx ( ) {
310+ if t. requires_zero_conf ( ) {
311+ ChannelType :: Anchors0conf
312+ } else {
313+ ChannelType :: Anchors
314+ }
315+ } else {
316+ if t. requires_zero_conf ( ) {
317+ ChannelType :: StaticRemoteKey0conf
318+ } else {
319+ ChannelType :: StaticRemoteKey
320+ }
321+ }
322+ } ) ;
323+
287324 ChannelDetails {
288325 channel_id : value. channel_id ,
289326 counterparty_node_id : value. counterparty . node_id ,
290327 funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
328+ channel_type,
291329 channel_value_sats : value. channel_value_satoshis ,
292330 unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
293331 user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments