Merge pull request #3129 from optout21/splicing-msgs-update
[rust-lightning] / lightning / src / routing / router.rs
index 036d6372af098a05cee3c54dde87d8aafe6321f0..28aaba0513fb45de1e9ba9b24d42b463bd548ba4 100644 (file)
@@ -119,9 +119,10 @@ impl<G: Deref<Target = NetworkGraph<L>> + Clone, L: Deref, ES: Deref, S: Deref,
                        .filter(|details| amount_msats <= details.inbound_capacity_msat)
                        .filter(|details| amount_msats >= details.inbound_htlc_minimum_msat.unwrap_or(0))
                        .filter(|details| amount_msats <= details.inbound_htlc_maximum_msat.unwrap_or(u64::MAX))
+                       // Limit to peers with announced channels unless the recipient is unannounced.
                        .filter(|details| network_graph
                                        .node(&NodeId::from_pubkey(&details.counterparty.node_id))
-                                       .map(|node_info| node_info.channels.len() >= MIN_PEER_CHANNELS)
+                                       .map(|node| !is_recipient_announced || node.channels.len() >= MIN_PEER_CHANNELS)
                                        // Allow payments directly with the only peer when unannounced.
                                        .unwrap_or(!is_recipient_announced && has_one_peer)
                        )