Skip to content

Commit

Permalink
Add more properties to ChannelConfig from LDK original struct
Browse files Browse the repository at this point in the history
 Adds: `counterparty_unspendable_punishment_reserve`,
	`counterparty_outbound_htlc_minimum_msat`
	`counterparty_outbound_htlc_maximum_msat`
	`counterparty_forwarding_info_fee_base_msat`
	`counterparty_forwarding_info_fee_proportional_millionths`
	`counterparty_forwarding_info_cltv_expiry_delta`
	`next_outbound_htlc_limit_msat`
	`next_outbound_htlc_minimum_msat`
	`force_close_spend_delay`
        `inbound_htlc_minimum_msat`
	`inbound_htlc_maximum_msat`
	`config`
  • Loading branch information
jbesraa committed Sep 27, 2023
1 parent db1b7dc commit 546163c
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,60 @@ pub struct ChannelDetails {
/// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
/// the channel.
pub cltv_expiry_delta: Option<u16>,
/// The value, in satoshis, that must always be held in the channel for our counterparty. This
/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
/// claiming at least this value on chain.
///
/// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
///
/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
pub counterparty_unspendable_punishment_reserve: u64,
/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
pub counterparty_outbound_htlc_minimum_msat: Option<u64>,
/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
pub counterparty_outbound_htlc_maximum_msat: Option<u64>,
/// Base routing fee in millisatoshis.
pub counterparty_forwarding_info_fee_base_msat: Option<u32>,
/// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
pub counterparty_forwarding_info_fee_proportional_millionths: Option<u32>,
/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
/// `cltv_expiry_delta` for more details.
pub counterparty_forwarding_info_cltv_expiry_delta: Option<u16>,
/// The available outbound capacity for sending a single HTLC to the remote peer. This is
/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
/// to use a limit as close as possible to the HTLC limit we can currently send.
///
/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
pub next_outbound_htlc_limit_msat: u64,
/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
/// route which is valid.
pub next_outbound_htlc_minimum_msat: u64,
/// The number of blocks (after our commitment transaction confirms) that we will need to wait
/// until we can claim our funds after we force-close the channel. During this time our
/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
/// time to claim our non-HTLC-encumbered funds.
///
/// This value will be `None` for outbound channels until the counterparty accepts the channel.
pub force_close_spend_delay: Option<u16>,
/// The stage of the channel's shutdown.
/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
/// The smallest value HTLC (in msat) we will accept, for this channel. This field
/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
pub inbound_htlc_minimum_msat: Option<u64>,
/// The largest value HTLC (in msat) we currently will accept, for this channel.
pub inbound_htlc_maximum_msat: Option<u64>,
/// Set of configurable parameters that affect channel operation.
///
/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
pub config: Option<LdkChannelConfig>,
}

impl From<LdkChannelDetails> for ChannelDetails {
Expand All @@ -248,6 +302,32 @@ impl From<LdkChannelDetails> for ChannelDetails {
is_usable: value.is_usable,
is_public: value.is_public,
cltv_expiry_delta: value.config.and_then(|c| Some(c.cltv_expiry_delta)),
counterparty_unspendable_punishment_reserve: value
.counterparty
.unspendable_punishment_reserve,
counterparty_outbound_htlc_minimum_msat: value.counterparty.outbound_htlc_minimum_msat,
counterparty_outbound_htlc_maximum_msat: value.counterparty.outbound_htlc_maximum_msat,
counterparty_forwarding_info_fee_base_msat: value
.counterparty
.forwarding_info
.as_ref()
.and_then(|f| Some(f.fee_base_msat)),
counterparty_forwarding_info_fee_proportional_millionths: value
.counterparty
.forwarding_info
.as_ref()
.and_then(|f| Some(f.fee_proportional_millionths)),
counterparty_forwarding_info_cltv_expiry_delta: value
.counterparty
.forwarding_info
.as_ref()
.and_then(|f| Some(f.cltv_expiry_delta)),
next_outbound_htlc_limit_msat: value.next_outbound_htlc_limit_msat,
next_outbound_htlc_minimum_msat: value.next_outbound_htlc_minimum_msat,
force_close_spend_delay: value.force_close_spend_delay,
inbound_htlc_minimum_msat: value.inbound_htlc_minimum_msat,
inbound_htlc_maximum_msat: value.inbound_htlc_maximum_msat,
config: value.config,
}
}
}
Expand Down

0 comments on commit 546163c

Please sign in to comment.