From 34ecbab6679a3522bf15113d1cb9fa640e44e448 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Mon, 26 Feb 2024 09:07:34 +0100 Subject: [PATCH] Bump max inflight HTLC value to 100% if we're an LSPS2 client When we're an LSPS2 client, the LSP might open the channel to us with a capacity only barely more than the initial payment size. We therefore need to be able to receive close to 100% of the channel size in a single HTLC. Here we therefore bump the default max HTLC value inflight config to 100%. We should eventually be able to set this on a per-channel basis, but for now we just bump or default for all channels. --- src/builder.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 75c5bc9db..0bcefed56 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -685,7 +685,11 @@ fn build_with_store_internal( }, }; - // Initialize the ChannelManager + // Initialize the default config values. + // + // Note that methods such as Node::connect_open_channel might override some of the values set + // here, e.g. the ChannelHandshakeConfig, meaning these default values will mostly be relevant + // for inbound channels. let mut user_config = UserConfig::default(); user_config.channel_handshake_limits.force_announced_channel_preference = false; @@ -695,11 +699,22 @@ fn build_with_store_internal( user_config.manually_accept_inbound_channels = true; } - if liquidity_source_config.is_some() { + if let Some(liquidity_source_config) = liquidity_source_config { // Generally allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll // check that they don't take too much before claiming. user_config.channel_config.accept_underpaying_htlcs = true; + + // FIXME: When we're an LSPS2 client, set maximum allowed inbound HTLC value in flight + // to 100%. We should eventually be able to set this on a per-channel basis, but for + // now we just bump or default for all channels. + if liquidity_source_config.lsps2_service.is_some() { + user_config + .channel_handshake_config + .max_inbound_htlc_value_in_flight_percent_of_channel = 100; + } } + + // Initialize the ChannelManager let channel_manager = { if let Ok(res) = kv_store.read( CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,