@@ -154,6 +154,23 @@ impl Readable for UserChannelId {
154
154
}
155
155
}
156
156
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
+
157
174
/// Details of a channel as returned by [`Node::list_channels`].
158
175
///
159
176
/// [`Node::list_channels`]: crate::Node::list_channels
@@ -171,6 +188,10 @@ pub struct ChannelDetails {
171
188
/// The channel's funding transaction output, if we've negotiated the funding transaction with
172
189
/// our counterparty already.
173
190
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 > ,
174
195
/// The value, in satoshis, of this channel as it appears in the funding output.
175
196
pub channel_value_sats : u64 ,
176
197
/// 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 {
284
305
285
306
impl From < LdkChannelDetails > for ChannelDetails {
286
307
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
+
287
324
ChannelDetails {
288
325
channel_id : value. channel_id ,
289
326
counterparty_node_id : value. counterparty . node_id ,
290
327
funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
328
+ channel_type,
291
329
channel_value_sats : value. channel_value_satoshis ,
292
330
unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
293
331
user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments