Skip to content

Commit 79d0a49

Browse files
committed
f Account for accept_inbound_channel allowing override params
.. we now apply the LSPS2 client-side overrides on a per-counterparty basis, not as soon as we act as an LSP client
1 parent 4acbd0b commit 79d0a49

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

src/builder.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,17 +1181,6 @@ fn build_with_store_internal(
11811181
};
11821182

11831183
let mut user_config = default_user_config(&config);
1184-
if liquidity_source_config.and_then(|lsc| lsc.lsps2_client.as_ref()).is_some() {
1185-
// Generally allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
1186-
// check that they don't take too much before claiming.
1187-
user_config.channel_config.accept_underpaying_htlcs = true;
1188-
1189-
// FIXME: When we're an LSPS2 client, set maximum allowed inbound HTLC value in flight
1190-
// to 100%. We should eventually be able to set this on a per-channel basis, but for
1191-
// now we just bump the default for all channels.
1192-
user_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1193-
100;
1194-
}
11951184

11961185
if liquidity_source_config.and_then(|lsc| lsc.lsps2_service.as_ref()).is_some() {
11971186
// If we act as an LSPS2 service, we need to to be able to intercept HTLCs and forward the

src/event.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ use lightning::impl_writeable_tlv_based_enum;
3636
use lightning::ln::channelmanager::PaymentId;
3737
use lightning::ln::types::ChannelId;
3838
use lightning::routing::gossip::NodeId;
39+
use lightning::util::config::{
40+
ChannelConfigOverrides, ChannelConfigUpdate, ChannelHandshakeConfigUpdate,
41+
};
3942
use lightning::util::errors::APIError;
4043
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};
4144

@@ -1155,17 +1158,44 @@ where
11551158

11561159
let user_channel_id: u128 = rand::thread_rng().gen::<u128>();
11571160
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+
}
11581186
let res = if allow_0conf {
11591187
self.channel_manager.accept_inbound_channel_from_trusted_peer_0conf(
11601188
&temporary_channel_id,
11611189
&counterparty_node_id,
11621190
user_channel_id,
1191+
channel_override_config,
11631192
)
11641193
} else {
11651194
self.channel_manager.accept_inbound_channel(
11661195
&temporary_channel_id,
11671196
&counterparty_node_id,
11681197
user_channel_id,
1198+
channel_override_config,
11691199
)
11701200
};
11711201

0 commit comments

Comments
 (0)