@@ -219,6 +219,23 @@ impl Readable for UserChannelId {
219219 }
220220}
221221
222+ /// The type of a channel, as negotiated during channel opening.
223+ ///
224+ /// See [`BOLT 2`] for more information.
225+ ///
226+ /// [`BOLT 2`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#defined-channel-types
227+ #[ derive( Debug , Clone ) ]
228+ pub enum ChannelType {
229+ /// A channel of type `option_static_remotekey`.
230+ StaticRemoteKey ,
231+ /// A channel of type `option_static_remotekey` that requires 0conf support.
232+ StaticRemoteKey0conf ,
233+ /// A channel of type `option_anchors_zero_fee_htlc_tx`.
234+ Anchors ,
235+ /// A channel of type `option_anchors_zero_fee_htlc_tx` that requires 0conf support.
236+ Anchors0conf ,
237+ }
238+
222239/// Details of a channel as returned by [`Node::list_channels`].
223240///
224241/// [`Node::list_channels`]: crate::Node::list_channels
@@ -236,6 +253,10 @@ pub struct ChannelDetails {
236253 /// The channel's funding transaction output, if we've negotiated the funding transaction with
237254 /// our counterparty already.
238255 pub funding_txo : Option < OutPoint > ,
256+ /// The channel type as negotiated during channel opening.
257+ ///
258+ /// Will be `None` until the channel negotiation has been completed.
259+ pub channel_type : Option < ChannelType > ,
239260 /// The value, in satoshis, of this channel as it appears in the funding output.
240261 pub channel_value_sats : u64 ,
241262 /// The value, in satoshis, that must always be held as a reserve in the channel for us. This
@@ -349,10 +370,27 @@ pub struct ChannelDetails {
349370
350371impl From < LdkChannelDetails > for ChannelDetails {
351372 fn from ( value : LdkChannelDetails ) -> Self {
373+ let channel_type = value. channel_type . map ( |t| {
374+ if t. supports_anchors_zero_fee_htlc_tx ( ) {
375+ if t. requires_zero_conf ( ) {
376+ ChannelType :: Anchors0conf
377+ } else {
378+ ChannelType :: Anchors
379+ }
380+ } else {
381+ if t. requires_zero_conf ( ) {
382+ ChannelType :: StaticRemoteKey0conf
383+ } else {
384+ ChannelType :: StaticRemoteKey
385+ }
386+ }
387+ } ) ;
388+
352389 ChannelDetails {
353390 channel_id : value. channel_id ,
354391 counterparty_node_id : value. counterparty . node_id ,
355392 funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
393+ channel_type,
356394 channel_value_sats : value. channel_value_satoshis ,
357395 unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
358396 user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments