Skip to content

Commit 48104f7

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 a201d40 commit 48104f7

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
@@ -523,6 +523,15 @@ where
523523
.collect()
524524
}
525525

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

0 commit comments

Comments
 (0)