Skip to content

Commit 20bae9a

Browse files
jkczyzclaude
andcommitted
f - Assert unannounced-channel default stays at 100%
Per review feedback on PR #878. The forwarding behavior for LSPS2 channels relies on LDK's default of 100% for the unannounced-channel inbound HTLC value-in-flight cap. Catch upstream changes to that default with debug asserts at the three sites that depend on it. Generated with assistance from Claude Code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4fda093 commit 20bae9a

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/event.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,17 @@ where
12781278
}),
12791279
..Default::default()
12801280
});
1281+
1282+
// LSPS2 channels are unannounced; rely on LDK's default of 100%
1283+
// inbound HTLC value-in-flight so the LSP can forward the initial
1284+
// payment in full.
1285+
debug_assert_eq!(
1286+
self.channel_manager
1287+
.get_current_config()
1288+
.channel_handshake_config
1289+
.unannounced_channel_max_inbound_htlc_value_in_flight_percentage,
1290+
100
1291+
);
12811292
}
12821293
}
12831294
let res = if allow_0conf {

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,17 @@ impl Node {
11961196
user_config.channel_handshake_config.announce_for_forwarding = announce_for_forwarding;
11971197
user_config.channel_config = (channel_config.unwrap_or_default()).clone().into();
11981198

1199+
// Unannounced channels rely on LDK's default of 100% inbound HTLC value-in-flight
1200+
// to support large initial payments via LSPS2.
1201+
if !announce_for_forwarding {
1202+
debug_assert_eq!(
1203+
user_config
1204+
.channel_handshake_config
1205+
.unannounced_channel_max_inbound_htlc_value_in_flight_percentage,
1206+
100
1207+
);
1208+
}
1209+
11991210
let push_msat = push_to_counterparty_msat.unwrap_or(0);
12001211
let user_channel_id: u128 = u128::from_ne_bytes(
12011212
self.keys_manager.get_secure_random_bytes()[..16]

src/liquidity.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,13 +782,15 @@ where
782782
let mut config = self.channel_manager.get_current_config().clone();
783783

784784
// If we act as an LSPS2 service, the HTLC-value-in-flight must be 100% of the
785-
// channel value to ensure we can forward the initial payment.
785+
// channel value to ensure we can forward the initial payment. That cap only
786+
// applies to unannounced channels, so the channel must also be unannounced.
786787
debug_assert_eq!(
787788
config
788789
.channel_handshake_config
789790
.unannounced_channel_max_inbound_htlc_value_in_flight_percentage,
790791
100
791792
);
793+
debug_assert!(!config.channel_handshake_config.announce_for_forwarding);
792794
debug_assert!(config.accept_forwards_to_priv_channels);
793795

794796
// We set the forwarding fee to 0 for now as we're getting paid by the channel fee.

0 commit comments

Comments
 (0)