@@ -157,6 +157,23 @@ impl Readable for UserChannelId {
157157 }
158158}
159159
160+ /// The type of a channel, as negotiated during channel opening.
161+ ///
162+ /// See [`BOLT 2`] for more information.
163+ ///
164+ /// [`BOLT 2`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#defined-channel-types
165+ #[ derive( Debug , Clone ) ]
166+ pub enum ChannelType {
167+ /// A channel of type `option_static_remotekey`.
168+ StaticRemoteKey ,
169+ /// A channel of type `option_static_remotekey` that requires 0conf support.
170+ StaticRemoteKey0conf ,
171+ /// A channel of type `option_anchors_zero_fee_htlc_tx`.
172+ Anchors ,
173+ /// A channel of type `option_anchors_zero_fee_htlc_tx` that requires 0conf support.
174+ Anchors0conf ,
175+ }
176+
160177/// Details of a channel as returned by [`Node::list_channels`].
161178///
162179/// [`Node::list_channels`]: crate::Node::list_channels
@@ -174,6 +191,10 @@ pub struct ChannelDetails {
174191 /// The channel's funding transaction output, if we've negotiated the funding transaction with
175192 /// our counterparty already.
176193 pub funding_txo : Option < OutPoint > ,
194+ /// The channel type as negotiated during channel opening.
195+ ///
196+ /// Will be `None` until the channel negotiation has been completed.
197+ pub channel_type : Option < ChannelType > ,
177198 /// The value, in satoshis, of this channel as it appears in the funding output.
178199 pub channel_value_sats : u64 ,
179200 /// The value, in satoshis, that must always be held as a reserve in the channel for us. This
@@ -287,10 +308,27 @@ pub struct ChannelDetails {
287308
288309impl From < LdkChannelDetails > for ChannelDetails {
289310 fn from ( value : LdkChannelDetails ) -> Self {
311+ let channel_type = value. channel_type . map ( |t| {
312+ if t. supports_anchors_zero_fee_htlc_tx ( ) {
313+ if t. requires_zero_conf ( ) {
314+ ChannelType :: Anchors0conf
315+ } else {
316+ ChannelType :: Anchors
317+ }
318+ } else {
319+ if t. requires_zero_conf ( ) {
320+ ChannelType :: StaticRemoteKey0conf
321+ } else {
322+ ChannelType :: StaticRemoteKey
323+ }
324+ }
325+ } ) ;
326+
290327 ChannelDetails {
291328 channel_id : value. channel_id ,
292329 counterparty_node_id : value. counterparty . node_id ,
293330 funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
331+ channel_type,
294332 channel_value_sats : value. channel_value_satoshis ,
295333 unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
296334 user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments