@@ -157,6 +157,23 @@ impl Readable for UserChannelId {
157
157
}
158
158
}
159
159
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
+
160
177
/// Details of a channel as returned by [`Node::list_channels`].
161
178
///
162
179
/// [`Node::list_channels`]: crate::Node::list_channels
@@ -174,6 +191,10 @@ pub struct ChannelDetails {
174
191
/// The channel's funding transaction output, if we've negotiated the funding transaction with
175
192
/// our counterparty already.
176
193
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 > ,
177
198
/// The value, in satoshis, of this channel as it appears in the funding output.
178
199
pub channel_value_sats : u64 ,
179
200
/// 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 {
287
308
288
309
impl From < LdkChannelDetails > for ChannelDetails {
289
310
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
+
290
327
ChannelDetails {
291
328
channel_id : value. channel_id ,
292
329
counterparty_node_id : value. counterparty . node_id ,
293
330
funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
331
+ channel_type,
294
332
channel_value_sats : value. channel_value_satoshis ,
295
333
unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
296
334
user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments