]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Move public_intro_node util into Blinded{Message,Payment}Path
authorValentine Wallace <vwallace@protonmail.com>
Fri, 9 Aug 2024 19:55:33 +0000 (12:55 -0700)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 15 Aug 2024 17:04:04 +0000 (13:04 -0400)
Helps move towards making the BlindedPath struct private.

lightning/src/blinded_path/message.rs
lightning/src/blinded_path/mod.rs
lightning/src/blinded_path/payment.rs
lightning/src/ln/offers_tests.rs
lightning/src/onion_message/messenger.rs
lightning/src/routing/router.rs

index 08ef90a84f561698d16f8a8bce8c419e1fc52f71..b2199d514876b431ddac688218b8dce7715f641b 100644 (file)
@@ -112,6 +112,14 @@ impl BlindedMessagePath {
                        }
                }
        }
+
+       /// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
+       /// it is found in the network graph).
+       pub fn public_introduction_node_id<'a>(
+               &self, network_graph: &'a ReadOnlyNetworkGraph
+       ) -> Option<&'a NodeId> {
+               self.0.public_introduction_node_id(network_graph)
+       }
 }
 
 /// An intermediate node, and possibly a short channel id leading to the next node.
index b2cb2c018d839f025d97e89d28b174c4e09fca4a..f2b1e805f06dd7d5372c15b712e0fb7ba24e8563 100644 (file)
@@ -118,9 +118,7 @@ pub struct BlindedHop {
 }
 
 impl BlindedPath {
-       /// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
-       /// it is found in the network graph).
-       pub fn public_introduction_node_id<'a>(
+       pub(super) fn public_introduction_node_id<'a>(
                &self, network_graph: &'a ReadOnlyNetworkGraph
        ) -> Option<&'a NodeId> {
                match &self.introduction_node {
index 27033c0585edb573bbaedcea0f26bda7ee93f7f2..0d40ecf610e0761c6665d2f16f262cbee0673dac 100644 (file)
@@ -24,6 +24,7 @@ use crate::ln::onion_utils;
 use crate::offers::invoice::BlindedPayInfo;
 use crate::offers::invoice_request::InvoiceRequestFields;
 use crate::offers::offer::OfferId;
+use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
 use crate::sign::{EntropySource, NodeSigner, Recipient};
 use crate::util::ser::{FixedLengthReader, LengthReadableArgs, HighZeroBytesDroppedBigSize, Readable, Writeable, Writer};
 
@@ -94,6 +95,14 @@ impl BlindedPaymentPath {
                        ).map_err(|_| ())?,
                })))
        }
+
+       /// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
+       /// it is found in the network graph).
+       pub fn public_introduction_node_id<'a>(
+               &self, network_graph: &'a ReadOnlyNetworkGraph
+       ) -> Option<&'a NodeId> {
+               self.0.public_introduction_node_id(network_graph)
+       }
 }
 
 /// An intermediate node, its outbound channel, and relay parameters.
index b4134d493081dcc1fe6b78d8ee7cea19ebe02633..221919d16d060b738c957f3c69c70a297ea0169a 100644 (file)
@@ -141,7 +141,7 @@ fn announce_node_address<'a, 'b, 'c>(
 }
 
 fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &BlindedMessagePath) -> PublicKey {
-       path.0.public_introduction_node_id(&node.network_graph.read_only())
+       path.public_introduction_node_id(&node.network_graph.read_only())
                .and_then(|node_id| node_id.as_pubkey().ok())
                .unwrap()
 }
index 2fde66b126c79ccfb45196d51d2b61f1d7b85f70..f64e2e739218483fd1bb46d6788b961c0e93c079 100644 (file)
@@ -699,7 +699,6 @@ impl Destination {
                if let Destination::BlindedPath(path) = self {
                        if let IntroductionNode::DirectedShortChannelId(..) = path.0.introduction_node {
                                if let Some(pubkey) = path
-                                       .0
                                        .public_introduction_node_id(network_graph)
                                        .and_then(|node_id| node_id.as_pubkey().ok())
                                {
index 99a9e008696cdfdd4a7ba9109613c4bb50a5be92..2a603c75dfc8f850f7b42fc414f2688a55b184ce 100644 (file)
@@ -1646,7 +1646,7 @@ where L::Target: Logger {
                                        node_counters.node_counter_from_id(&NodeId::from_pubkey(&pubkey))
                                },
                                IntroductionNode::DirectedShortChannelId(direction, scid) => {
-                                       path.0.public_introduction_node_id(network_graph)
+                                       path.public_introduction_node_id(network_graph)
                                                .map(|node_id_ref| *node_id_ref)
                                                .or_else(|| {
                                                        first_hop_targets.iter().find(|(_, (channels, _))|
@@ -5671,7 +5671,7 @@ mod tests {
                                                        NodeId::from_pubkey(&path.hops.last().unwrap().pubkey),
                                                        payment_params.payee.blinded_route_hints().iter()
                                                                .find(|(p, _)| p.htlc_maximum_msat == path.final_value_msat())
-                                                               .and_then(|(_, p)| p.0.public_introduction_node_id(&network_graph))
+                                                               .and_then(|(_, p)| p.public_introduction_node_id(&network_graph))
                                                                .copied()
                                                                .unwrap()
                                                );
@@ -7878,7 +7878,7 @@ mod tests {
                let final_hop = route.paths[0].hops.last().unwrap();
                assert_eq!(
                        NodeId::from_pubkey(&final_hop.pubkey),
-                       *blinded_path.0.public_introduction_node_id(&network_graph).unwrap()
+                       *blinded_path.public_introduction_node_id(&network_graph).unwrap()
                );
                if tail.hops.len() > 1 {
                        assert_eq!(final_hop.fee_msat,