@@ -36,6 +36,9 @@ use lightning::impl_writeable_tlv_based_enum;
36
36
use lightning:: ln:: channelmanager:: PaymentId ;
37
37
use lightning:: ln:: types:: ChannelId ;
38
38
use lightning:: routing:: gossip:: NodeId ;
39
+ use lightning:: util:: config:: {
40
+ ChannelConfigOverrides , ChannelConfigUpdate , ChannelHandshakeConfigUpdate ,
41
+ } ;
39
42
use lightning:: util:: errors:: APIError ;
40
43
use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
41
44
@@ -1155,17 +1158,44 @@ where
1155
1158
1156
1159
let user_channel_id: u128 = rand:: thread_rng ( ) . gen :: < u128 > ( ) ;
1157
1160
let allow_0conf = self . config . trusted_peers_0conf . contains ( & counterparty_node_id) ;
1161
+ let mut channel_override_config = None ;
1162
+ if let Some ( ( lsp_node_id, _) ) = self
1163
+ . liquidity_source
1164
+ . as_ref ( )
1165
+ . and_then ( |ls| ls. as_ref ( ) . get_lsps2_lsp_details ( ) )
1166
+ {
1167
+ if lsp_node_id == counterparty_node_id {
1168
+ // When we're an LSPS2 client, allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
1169
+ // check that they don't take too much before claiming.
1170
+ //
1171
+ // We also set maximum allowed inbound HTLC value in flight
1172
+ // to 100%. We should eventually be able to set this on a per-channel basis, but for
1173
+ // now we just bump the default for all channels.
1174
+ channel_override_config = Some ( ChannelConfigOverrides {
1175
+ handshake_overrides : Some ( ChannelHandshakeConfigUpdate {
1176
+ max_inbound_htlc_value_in_flight_percent_of_channel : Some ( 100 ) ,
1177
+ ..Default :: default ( )
1178
+ } ) ,
1179
+ update_overrides : Some ( ChannelConfigUpdate {
1180
+ accept_underpaying_htlcs : Some ( true ) ,
1181
+ ..Default :: default ( )
1182
+ } ) ,
1183
+ } ) ;
1184
+ }
1185
+ }
1158
1186
let res = if allow_0conf {
1159
1187
self . channel_manager . accept_inbound_channel_from_trusted_peer_0conf (
1160
1188
& temporary_channel_id,
1161
1189
& counterparty_node_id,
1162
1190
user_channel_id,
1191
+ channel_override_config,
1163
1192
)
1164
1193
} else {
1165
1194
self . channel_manager . accept_inbound_channel (
1166
1195
& temporary_channel_id,
1167
1196
& counterparty_node_id,
1168
1197
user_channel_id,
1198
+ channel_override_config,
1169
1199
)
1170
1200
} ;
1171
1201
0 commit comments