Skip to content

Commit b36a153

Browse files
committed
Introduce channel_type field to ChannelDetails
1 parent e73305c commit b36a153

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

bindings/ldk_node.udl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,16 @@ dictionary OutPoint {
264264
u32 vout;
265265
};
266266

267+
enum ChannelType {
268+
"StaticRemoteKey",
269+
"Anchors",
270+
};
271+
267272
dictionary ChannelDetails {
268273
ChannelId channel_id;
269274
PublicKey counterparty_node_id;
270275
OutPoint? funding_txo;
276+
ChannelType? channel_type;
271277
u64 channel_value_sats;
272278
u64? unspendable_punishment_reserve;
273279
UserChannelId user_channel_id;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ use types::{
136136
Broadcaster, ChainMonitor, ChannelManager, DynStore, FeeEstimator, KeysManager, NetworkGraph,
137137
PeerManager, Router, Scorer, Sweeper, Wallet,
138138
};
139-
pub use types::{ChannelDetails, PeerDetails, UserChannelId};
139+
pub use types::{ChannelDetails, ChannelType, PeerDetails, UserChannelId};
140140

141141
use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};
142142

src/types.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ impl Readable for UserChannelId {
163163
}
164164
}
165165

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+
166179
/// Details of a channel as returned by [`Node::list_channels`].
167180
///
168181
/// [`Node::list_channels`]: crate::Node::list_channels
@@ -180,6 +193,10 @@ pub struct ChannelDetails {
180193
/// The channel's funding transaction output, if we've negotiated the funding transaction with
181194
/// our counterparty already.
182195
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>,
183200
/// The value, in satoshis, of this channel as it appears in the funding output.
184201
pub channel_value_sats: u64,
185202
/// 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 {
287304

288305
impl From<LdkChannelDetails> for ChannelDetails {
289306
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+
290315
ChannelDetails {
291316
channel_id: value.channel_id,
292317
counterparty_node_id: value.counterparty.node_id,
293318
funding_txo: value.funding_txo.and_then(|o| Some(o.into_bitcoin_outpoint())),
319+
channel_type,
294320
channel_value_sats: value.channel_value_satoshis,
295321
unspendable_punishment_reserve: value.unspendable_punishment_reserve,
296322
user_channel_id: UserChannelId(value.user_channel_id),

0 commit comments

Comments
 (0)