Skip to content

Commit 27082aa

Browse files
committed
Honor LSP trust_peer_0conf independent of supported protocols
Look up trust_peer_0conf by node id via a protocol-independent helper that does not depend on discovery
1 parent 878e187 commit 27082aa

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/event.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,14 +1327,15 @@ where
13271327
);
13281328
let mut allow_0conf =
13291329
self.config.trusted_peers_0conf.contains(&counterparty_node_id);
1330-
let mut channel_override_config = None;
13311330

13321331
// If the peer is a configured LSP node, additionally honor its trust_peer_0conf flag.
1333-
if let Some(lsp) =
1334-
self.liquidity_source.get_lsp_config(&counterparty_node_id, 2).await
1335-
{
1336-
allow_0conf = allow_0conf || lsp.trust_peer_0conf;
1332+
if self.liquidity_source.get_lsp_trust_0conf(&counterparty_node_id) == Some(true) {
1333+
allow_0conf = true;
1334+
}
1335+
1336+
let mut channel_override_config = None;
13371337

1338+
if self.liquidity_source.get_lsp_config(&counterparty_node_id, 2).await.is_some() {
13381339
// When we're an LSPS2 client, allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
13391340
// check that they don't take too much before claiming.
13401341
channel_override_config = Some(ChannelConfigOverrides {

src/liquidity/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,15 @@ where
527527
.collect()
528528
}
529529

530+
pub(crate) fn get_lsp_trust_0conf(&self, node_id: &PublicKey) -> Option<bool> {
531+
self.lsp_nodes
532+
.read()
533+
.expect("lock")
534+
.iter()
535+
.find(|n| &n.node_id == node_id)
536+
.map(|n| n.trust_peer_0conf)
537+
}
538+
530539
/// Flips the `discovery_done` watch to `true`.
531540
///
532541
/// Called once after the *initial* batch of LSPs configured at build time has been

0 commit comments

Comments
 (0)