Skip to content

Commit 4cc1fc2

Browse files
f Fix configurable in-flight limit percentage 2
1 parent d362cb5 commit 4cc1fc2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,10 @@ pub const COMMITMENT_TX_WEIGHT_PER_HTLC: u64 = 172;
746746
pub const ANCHOR_OUTPUT_VALUE_SATOSHI: u64 = 330;
747747

748748
/// The percentage of the channel value `holder_max_htlc_value_in_flight_msat` used to be set to,
749-
/// before this was made configurable.
750-
pub const OLD_LDK_MAX_IN_FLIGHT_PERCENT: u8 = 10;
749+
/// before this was made configurable. The percentage was made configurable in LDK 0.0.107,
750+
/// although LDK 0.0.104+ enabled serialization of channels with a different value set for
751+
/// `holder_max_htlc_value_in_flight_msat`.
752+
pub const MAX_IN_FLIGHT_PERCENT_LEGACY: u8 = 10;
751753

752754
/// Maximum `funding_satoshis` value according to the BOLT #2 specification, if
753755
/// `option_support_large_channel` (aka wumbo channels) is not supported.
@@ -808,13 +810,12 @@ macro_rules! secp_check {
808810

809811
impl<Signer: Sign> Channel<Signer> {
810812
/// Returns the value to use for `holder_max_htlc_value_in_flight_msat` as a percentage of the
811-
/// `channel_value_satoshis` in msat, based on how many of the percent its been configured to
812-
/// be set to by the user.
813+
/// `channel_value_satoshis` in msat, set through
814+
/// [`ChannelHandkshakeConfig::max_inbound_htlc_value_in_flight_percent_of_channel`]
813815
///
814-
/// As we only allow the user to set the percentage to a value between `1-100`, if the user
815-
/// sets a value less than `1`, the function will result in `1` percent of the
816-
/// `channel_value_satoshis`, as well as `100` percent if the user has set a value larger
817-
/// than `100`.
816+
/// The effective percentage is lower bounded by 1% and upper bounded by 100%.
817+
///
818+
/// [`ChannelHandkshakeConfig::max_inbound_htlc_value_in_flight_percent_of_channel`]: crate::util::config::ChannelHandshakeConfig::max_inbound_htlc_value_in_flight_percent_of_channel
818819
fn get_holder_max_htlc_value_in_flight_msat(channel_value_satoshis: u64, config: &ChannelHandshakeConfig) -> u64 {
819820
let configured_percent = if config.max_inbound_htlc_value_in_flight_percent_of_channel < 1 {
820821
1
@@ -5904,7 +5905,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
59045905
{ Some(self.holder_selected_channel_reserve_satoshis) } else { None };
59055906

59065907
let mut old_max_in_flight_percent_config = UserConfig::default().own_channel_config;
5907-
old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel = OLD_LDK_MAX_IN_FLIGHT_PERCENT;
5908+
old_max_in_flight_percent_config.max_inbound_htlc_value_in_flight_percent_of_channel = MAX_IN_FLIGHT_PERCENT_LEGACY;
59085909
let serialized_holder_htlc_max_in_flight =
59095910
if self.holder_max_htlc_value_in_flight_msat != Self::get_holder_max_htlc_value_in_flight_msat(self.channel_value_satoshis, &old_max_in_flight_percent_config)
59105911
{ Some(self.holder_max_htlc_value_in_flight_msat) } else { None };

0 commit comments

Comments
 (0)