From 546163ca20ba7da4c404fff0c9d7c58e8c89bf74 Mon Sep 17 00:00:00 2001 From: jbesraa Date: Wed, 27 Sep 2023 10:22:55 +0300 Subject: [PATCH] Add more properties to `ChannelConfig` from LDK original struct 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` --- src/types.rs | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/types.rs b/src/types.rs index b031dec69..f90717d8c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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, + /// 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, + /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + pub counterparty_outbound_htlc_maximum_msat: Option, + /// Base routing fee in millisatoshis. + pub counterparty_forwarding_info_fee_base_msat: Option, + /// Amount in millionths of a satoshi the channel will charge per transferred satoshi. + pub counterparty_forwarding_info_fee_proportional_millionths: Option, + /// 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, + /// 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, + /// 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, + /// The largest value HTLC (in msat) we currently will accept, for this channel. + pub inbound_htlc_maximum_msat: Option, + /// 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, } impl From for ChannelDetails { @@ -248,6 +302,32 @@ impl From 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, } } }