Skip to content

Commit da5bcdc

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 c4b07e1 commit da5bcdc

5 files changed

Lines changed: 571 additions & 561 deletions

File tree

src/event.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,14 +1317,15 @@ where
13171317
);
13181318
let mut allow_0conf =
13191319
self.config.trusted_peers_0conf.contains(&counterparty_node_id);
1320-
let mut channel_override_config = None;
13211320

13221321
// If the peer is a configured LSP node, additionally honor its trust_peer_0conf flag.
1323-
if let Some(lsp) =
1324-
self.liquidity_source.get_lsp_config(&counterparty_node_id, 2).await
1325-
{
1326-
allow_0conf = allow_0conf || lsp.trust_peer_0conf;
1322+
if self.liquidity_source.get_lsp_trust_0conf(&counterparty_node_id) == Some(true) {
1323+
allow_0conf = true;
1324+
}
1325+
1326+
let mut channel_override_config = None;
13271327

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

src/liquidity/client/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// This file is Copyright its original authors, visible in version control history.
2-
//
3-
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5-
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
6-
// accordance with one or both of these licenses.
7-
8-
pub(crate) mod lsps1;
9-
pub(crate) mod lsps2;
10-
11-
pub use lsps1::LSPS1OrderStatus;
1+
// This file is Copyright its original authors, visible in version control history.
2+
//
3+
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5+
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
6+
// accordance with one or both of these licenses.
7+
8+
pub(crate) mod lsps1;
9+
pub(crate) mod lsps2;
10+
11+
pub use lsps1::LSPS1OrderStatus;

src/liquidity/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,15 @@ where
572572
.collect()
573573
}
574574

575+
pub(crate) fn get_lsp_trust_0conf(&self, node_id: &PublicKey) -> Option<bool> {
576+
self.lsp_nodes
577+
.read()
578+
.expect("lock")
579+
.iter()
580+
.find(|n| &n.node_id == node_id)
581+
.map(|n| n.trust_peer_0conf)
582+
}
583+
575584
/// Flips the `discovery_done` watch to `true`.
576585
///
577586
/// Called once after the *initial* batch of LSPs configured at build time has been

0 commit comments

Comments
 (0)