@@ -163,6 +163,19 @@ impl Readable for UserChannelId {
163
163
}
164
164
}
165
165
166
+ /// The type of a channel, as negotiated during channel opening.
167
+ ///
168
+ /// See [`BOLT 2`] for more information.
169
+ ///
170
+ /// [`BOLT 2`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#defined-channel-types
171
+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
172
+ pub enum ChannelType {
173
+ /// A channel of type `option_static_remotekey`.
174
+ StaticRemoteKey ,
175
+ /// A channel of type `option_anchors_zero_fee_htlc_tx`.
176
+ Anchors ,
177
+ }
178
+
166
179
/// Details of a channel as returned by [`Node::list_channels`].
167
180
///
168
181
/// [`Node::list_channels`]: crate::Node::list_channels
@@ -180,6 +193,10 @@ pub struct ChannelDetails {
180
193
/// The channel's funding transaction output, if we've negotiated the funding transaction with
181
194
/// our counterparty already.
182
195
pub funding_txo : Option < OutPoint > ,
196
+ /// The channel type as negotiated during channel opening.
197
+ ///
198
+ /// Will be `None` until the channel negotiation has been completed.
199
+ pub channel_type : Option < ChannelType > ,
183
200
/// The value, in satoshis, of this channel as it appears in the funding output.
184
201
pub channel_value_sats : u64 ,
185
202
/// The value, in satoshis, that must always be held as a reserve in the channel for us. This
@@ -287,10 +304,19 @@ pub struct ChannelDetails {
287
304
288
305
impl From < LdkChannelDetails > for ChannelDetails {
289
306
fn from ( value : LdkChannelDetails ) -> Self {
307
+ let channel_type = value. channel_type . map ( |t| {
308
+ if t. requires_anchors_zero_fee_htlc_tx ( ) {
309
+ ChannelType :: Anchors
310
+ } else {
311
+ ChannelType :: StaticRemoteKey
312
+ }
313
+ } ) ;
314
+
290
315
ChannelDetails {
291
316
channel_id : value. channel_id ,
292
317
counterparty_node_id : value. counterparty . node_id ,
293
318
funding_txo : value. funding_txo . and_then ( |o| Some ( o. into_bitcoin_outpoint ( ) ) ) ,
319
+ channel_type,
294
320
channel_value_sats : value. channel_value_satoshis ,
295
321
unspendable_punishment_reserve : value. unspendable_punishment_reserve ,
296
322
user_channel_id : UserChannelId ( value. user_channel_id ) ,
0 commit comments