@@ -219,6 +219,23 @@ impl Readable for UserChannelId {
219
219
}
220
220
}
221
221
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
+
222
239
/// Details of a channel as returned by [`Node::list_channels`].
223
240
///
224
241
/// [`Node::list_channels`]: crate::Node::list_channels
@@ -236,6 +253,10 @@ pub struct ChannelDetails {
236
253
/// The channel's funding transaction output, if we've negotiated the funding transaction with
237
254
/// our counterparty already.
238
255
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 > ,
239
260
/// The value, in satoshis, of this channel as it appears in the funding output.
240
261
pub channel_value_sats : u64 ,
241
262
/// 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 {
349
370
350
371
impl From < LdkChannelDetails > for ChannelDetails {
351
372
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
+
352
389
ChannelDetails {
353
390
channel_id : value. channel_id ,
354
391
counterparty_node_id : value. counterparty . node_id ,
355
392
funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
393
+ channel_type,
356
394
channel_value_sats : value. channel_value_satoshis ,
357
395
unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
358
396
user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments