@@ -36,6 +36,7 @@ use lightning::impl_writeable_tlv_based_enum;
3636use lightning:: ln:: channelmanager:: PaymentId ;
3737use lightning:: ln:: types:: ChannelId ;
3838use lightning:: routing:: gossip:: NodeId ;
39+ use lightning:: util:: config:: { ChannelConfigOverrides , ChannelConfigUpdate , ChannelHandshakeConfigUpdate } ;
3940use lightning:: util:: errors:: APIError ;
4041use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
4142
@@ -1168,19 +1169,44 @@ where
11681169
11691170 let user_channel_id: u128 = rand:: thread_rng ( ) . gen :: < u128 > ( ) ;
11701171 let allow_0conf = self . config . trusted_peers_0conf . contains ( & counterparty_node_id) ;
1172+ let mut channel_override_config = None ;
1173+ if let Some ( ( lsp_node_id, _) ) = self
1174+ . liquidity_source
1175+ . as_ref ( )
1176+ . and_then ( |ls| ls. as_ref ( ) . get_lsps2_lsp_details ( ) )
1177+ {
1178+ if lsp_node_id == counterparty_node_id {
1179+ // When we're an LSPS2 client, allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
1180+ // check that they don't take too much before claiming.
1181+ //
1182+ // We also set maximum allowed inbound HTLC value in flight
1183+ // to 100%. We should eventually be able to set this on a per-channel basis, but for
1184+ // now we just bump the default for all channels.
1185+ channel_override_config = Some ( ChannelConfigOverrides {
1186+ handshake_overrides : Some ( ChannelHandshakeConfigUpdate {
1187+ max_inbound_htlc_value_in_flight_percent_of_channel : Some ( 100 ) ,
1188+ ..Default :: default ( )
1189+ } ) ,
1190+ update_overrides : Some ( ChannelConfigUpdate {
1191+ accept_underpaying_htlcs : Some ( true ) ,
1192+ ..Default :: default ( )
1193+ } ) ,
1194+ } ) ;
1195+ }
1196+ }
11711197 let res = if allow_0conf {
11721198 self . channel_manager . accept_inbound_channel_from_trusted_peer_0conf (
11731199 & temporary_channel_id,
11741200 & counterparty_node_id,
11751201 user_channel_id,
1176- None ,
1202+ channel_override_config ,
11771203 )
11781204 } else {
11791205 self . channel_manager . accept_inbound_channel (
11801206 & temporary_channel_id,
11811207 & counterparty_node_id,
11821208 user_channel_id,
1183- None ,
1209+ channel_override_config ,
11841210 )
11851211 } ;
11861212
0 commit comments