Skip to content

Commit d9a8c8a

Browse files
authored
Merge pull request #165 from jbesraa/add-props-to-ChannelConfig
Add more properties to `ChannelConfig` from LDK original struct
2 parents c89ede5 + 16e990e commit d9a8c8a

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

bindings/ldk_node.udl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ dictionary ChannelDetails {
197197
boolean is_usable;
198198
boolean is_public;
199199
u16? cltv_expiry_delta;
200+
u64 counterparty_unspendable_punishment_reserve;
201+
u64 counterparty_outbound_htlc_minimum_msat;
202+
u64? counterparty_outbound_htlc_maximum_msat;
203+
u32? counterparty_forwarding_info_fee_base_msat;
204+
u32? counterparty_forwarding_info_fee_proportional_millionths;
205+
u16? counterparty_forwarding_info_cltv_expiry_delta;
206+
u64 next_outbound_htlc_limit_msat;
207+
u64 next_outbound_htlc_minimum_msat;
208+
u16? force_close_spend_delay;
209+
u64 inbound_htlc_minimum_msat;
210+
u64? inbound_htlc_maximum_msat;
211+
ChannelConfig config;
200212
};
201213

202214
dictionary PeerDetails {

src/types.rs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl Readable for UserChannelId {
152152
/// Details of a channel as returned by [`Node::list_channels`].
153153
///
154154
/// [`Node::list_channels`]: crate::Node::list_channels
155-
#[derive(Debug, Clone, PartialEq, Eq)]
155+
#[derive(Debug, Clone)]
156156
pub struct ChannelDetails {
157157
/// The channel ID (prior to funding transaction generation, this is a random 32-byte
158158
/// identifier, afterwards this is the transaction ID of the funding transaction XOR the
@@ -226,6 +226,52 @@ pub struct ChannelDetails {
226226
/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
227227
/// the channel.
228228
pub cltv_expiry_delta: Option<u16>,
229+
/// The value, in satoshis, that must always be held in the channel for our counterparty. This
230+
/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
231+
/// claiming at least this value on chain.
232+
///
233+
/// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
234+
///
235+
/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
236+
pub counterparty_unspendable_punishment_reserve: u64,
237+
/// The smallest value HTLC (in msat) the remote peer will accept, for this channel.
238+
pub counterparty_outbound_htlc_minimum_msat: u64,
239+
/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
240+
pub counterparty_outbound_htlc_maximum_msat: Option<u64>,
241+
/// Base routing fee in millisatoshis.
242+
pub counterparty_forwarding_info_fee_base_msat: Option<u32>,
243+
/// Proportional fee, in millionths of a satoshi the channel will charge per transferred satoshi.
244+
pub counterparty_forwarding_info_fee_proportional_millionths: Option<u32>,
245+
/// The minimum difference in CLTV expiry between an ingoing HTLC and its outgoing counterpart,
246+
/// such that the outgoing HTLC is forwardable to this counterparty.
247+
pub counterparty_forwarding_info_cltv_expiry_delta: Option<u16>,
248+
/// The available outbound capacity for sending a single HTLC to the remote peer. This is
249+
/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
250+
/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
251+
/// to use a limit as close as possible to the HTLC limit we can currently send.
252+
///
253+
/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
254+
/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
255+
pub next_outbound_htlc_limit_msat: u64,
256+
/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
257+
/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
258+
/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
259+
/// route which is valid.
260+
pub next_outbound_htlc_minimum_msat: u64,
261+
/// The number of blocks (after our commitment transaction confirms) that we will need to wait
262+
/// until we can claim our funds after we force-close the channel. During this time our
263+
/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
264+
/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
265+
/// time to claim our non-HTLC-encumbered funds.
266+
///
267+
/// This value will be `None` for outbound channels until the counterparty accepts the channel.
268+
pub force_close_spend_delay: Option<u16>,
269+
/// The smallest value HTLC (in msat) we will accept, for this channel.
270+
pub inbound_htlc_minimum_msat: u64,
271+
/// The largest value HTLC (in msat) we currently will accept, for this channel.
272+
pub inbound_htlc_maximum_msat: Option<u64>,
273+
/// Set of configurable parameters that affect channel operation.
274+
pub config: Arc<ChannelConfig>,
229275
}
230276

231277
impl From<LdkChannelDetails> for ChannelDetails {
@@ -247,7 +293,36 @@ impl From<LdkChannelDetails> for ChannelDetails {
247293
is_channel_ready: value.is_channel_ready,
248294
is_usable: value.is_usable,
249295
is_public: value.is_public,
250-
cltv_expiry_delta: value.config.and_then(|c| Some(c.cltv_expiry_delta)),
296+
cltv_expiry_delta: value.config.map(|c| c.cltv_expiry_delta),
297+
counterparty_unspendable_punishment_reserve: value
298+
.counterparty
299+
.unspendable_punishment_reserve,
300+
counterparty_outbound_htlc_minimum_msat: value
301+
.counterparty
302+
.outbound_htlc_minimum_msat
303+
.unwrap(),
304+
counterparty_outbound_htlc_maximum_msat: value.counterparty.outbound_htlc_maximum_msat,
305+
counterparty_forwarding_info_fee_base_msat: value
306+
.counterparty
307+
.forwarding_info
308+
.as_ref()
309+
.map(|f| f.fee_base_msat),
310+
counterparty_forwarding_info_fee_proportional_millionths: value
311+
.counterparty
312+
.forwarding_info
313+
.as_ref()
314+
.map(|f| f.fee_proportional_millionths),
315+
counterparty_forwarding_info_cltv_expiry_delta: value
316+
.counterparty
317+
.forwarding_info
318+
.as_ref()
319+
.map(|f| f.cltv_expiry_delta),
320+
next_outbound_htlc_limit_msat: value.next_outbound_htlc_limit_msat,
321+
next_outbound_htlc_minimum_msat: value.next_outbound_htlc_minimum_msat,
322+
force_close_spend_delay: value.force_close_spend_delay,
323+
inbound_htlc_minimum_msat: value.inbound_htlc_minimum_msat.unwrap(),
324+
inbound_htlc_maximum_msat: value.inbound_htlc_maximum_msat,
325+
config: value.config.map(|c| Arc::new(c.into())).unwrap(),
251326
}
252327
}
253328
}

0 commit comments

Comments
 (0)