]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Make BlindedPath type private.
authorValentine Wallace <vwallace@protonmail.com>
Tue, 13 Aug 2024 18:36:07 +0000 (14:36 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Fri, 16 Aug 2024 14:28:52 +0000 (10:28 -0400)
Users should use the Blinded{Message,Payment}Path types instead.

lightning/src/blinded_path/message.rs
lightning/src/blinded_path/mod.rs
lightning/src/blinded_path/payment.rs
lightning/src/routing/router.rs
lightning/src/routing/scoring.rs

index 27332f6929dae3557362551a8fb7d48886d7673c..c48e5d3cc21a67d59822eb4aeab24988cd9af3c8 100644 (file)
@@ -34,7 +34,7 @@ use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeabl
 use core::mem;
 use core::ops::Deref;
 
-/// A [`BlindedPath`] to be used for sending or receiving a message, hiding the identity of the
+/// A blinded path to be used for sending or receiving a message, hiding the identity of the
 /// recipient.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 pub struct BlindedMessagePath(pub(super) BlindedPath);
index f2b1e805f06dd7d5372c15b712e0fb7ba24e8563..08a30f589ce12811afcb25324b1361217c95058e 100644 (file)
@@ -37,7 +37,7 @@ pub enum NextMessageHop {
 /// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
 /// identity of the recipient.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
-pub struct BlindedPath {
+struct BlindedPath {
        /// To send to a blinded path, the sender first finds a route to the unblinded
        /// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
        /// message or payment's next hop and forward it along.
@@ -53,7 +53,7 @@ pub struct BlindedPath {
        pub blinded_hops: Vec<BlindedHop>,
 }
 
-/// The unblinded node in a [`BlindedPath`].
+/// The unblinded node in a blinded path.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 pub enum IntroductionNode {
        /// The node id of the introduction node.
@@ -63,8 +63,8 @@ pub enum IntroductionNode {
        DirectedShortChannelId(Direction, u64),
 }
 
-/// The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines
-/// which nodes is which in the [`ChannelAnnouncement`] message.
+/// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which
+/// nodes is which in the [`ChannelAnnouncement`] message.
 ///
 /// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
 /// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement
@@ -109,9 +109,9 @@ impl Deref for EmptyNodeIdLookUp {
 /// and thus can be used to hide the identity of the recipient.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 pub struct BlindedHop {
-       /// The blinded node id of this hop in a [`BlindedPath`].
+       /// The blinded node id of this hop in a blinded path.
        pub blinded_node_id: PublicKey,
-       /// The encrypted payload intended for this hop in a [`BlindedPath`].
+       /// The encrypted payload intended for this hop in a blinded path.
        // The node sending to this blinded path will later encode this payload into the onion packet for
        // this hop.
        pub encrypted_payload: Vec<u8>,
index 82d3fd3e5f5fd4f8781b2f22b958f22146f09715..f9615e7157fb03fcabbbfb37841029f6f21b9140 100644 (file)
@@ -34,7 +34,7 @@ use core::ops::Deref;
 #[allow(unused_imports)]
 use crate::prelude::*;
 
-/// A [`BlindedPath`] to be used for sending or receiving a payment, hiding the identity of the
+/// A blinded path to be used for sending or receiving a payment, hiding the identity of the
 /// recipient.
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 pub struct BlindedPaymentPath(pub(super) BlindedPath);
index ffc27cb0eaea019e5201b49155d611b87526b9dd..2d7450b91c53be82d3b26037692ad9c25f54dff6 100644 (file)
@@ -3541,7 +3541,7 @@ fn build_route_from_hops_internal<L: Deref>(
 
 #[cfg(test)]
 mod tests {
-       use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
+       use crate::blinded_path::BlindedHop;
        use crate::blinded_path::payment::BlindedPaymentPath;
        use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, EffectiveCapacity};
        use crate::routing::utxo::UtxoResult;
@@ -7682,22 +7682,6 @@ mod tests {
 
        #[test]
        fn blinded_route_ser() {
-               let blinded_path_1 = BlindedPath {
-                       introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(42)),
-                       blinding_point: ln_test_utils::pubkey(43),
-                       blinded_hops: vec![
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
-                       ],
-               };
-               let blinded_path_2 = BlindedPath {
-                       introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(46)),
-                       blinding_point: ln_test_utils::pubkey(47),
-                       blinded_hops: vec![
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
-                       ],
-               };
                // (De)serialize a Route with 1 blinded path out of two total paths.
                let mut route = Route { paths: vec![Path {
                        hops: vec![RouteHop {
@@ -7710,8 +7694,11 @@ mod tests {
                                maybe_announced_channel: true,
                        }],
                        blinded_tail: Some(BlindedTail {
-                               hops: blinded_path_1.blinded_hops,
-                               blinding_point: blinded_path_1.blinding_point,
+                               hops: vec![
+                                       BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
+                                       BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
+                               ],
+                               blinding_point: ln_test_utils::pubkey(43),
                                excess_final_cltv_expiry_delta: 40,
                                final_value_msat: 100,
                        })}, Path {
@@ -7733,8 +7720,11 @@ mod tests {
 
                // (De)serialize a Route with two paths, each containing a blinded tail.
                route.paths[1].blinded_tail = Some(BlindedTail {
-                       hops: blinded_path_2.blinded_hops,
-                       blinding_point: blinded_path_2.blinding_point,
+                       hops: vec![
+                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
+                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
+                       ],
+                       blinding_point: ln_test_utils::pubkey(47),
                        excess_final_cltv_expiry_delta: 41,
                        final_value_msat: 101,
                });
@@ -7749,11 +7739,6 @@ mod tests {
                // Ensure we'll score the channel that's inbound to a blinded path's introduction node, and
                // account for the blinded tail's final amount_msat.
                let mut inflight_htlcs = InFlightHtlcs::new();
-               let blinded_path = BlindedPath {
-                       introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
-                       blinding_point: ln_test_utils::pubkey(48),
-                       blinded_hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
-               };
                let path = Path {
                        hops: vec![RouteHop {
                                pubkey: ln_test_utils::pubkey(42),
@@ -7774,8 +7759,8 @@ mod tests {
                                maybe_announced_channel: false,
                        }],
                        blinded_tail: Some(BlindedTail {
-                               hops: blinded_path.blinded_hops,
-                               blinding_point: blinded_path.blinding_point,
+                               hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
+                               blinding_point: ln_test_utils::pubkey(48),
                                excess_final_cltv_expiry_delta: 0,
                                final_value_msat: 200,
                        }),
@@ -7788,14 +7773,6 @@ mod tests {
        #[test]
        fn blinded_path_cltv_shadow_offset() {
                // Make sure we add a shadow offset when sending to blinded paths.
-               let blinded_path = BlindedPath {
-                       introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
-                       blinding_point: ln_test_utils::pubkey(44),
-                       blinded_hops: vec![
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
-                               BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
-                       ],
-               };
                let mut route = Route { paths: vec![Path {
                        hops: vec![RouteHop {
                                pubkey: ln_test_utils::pubkey(42),
@@ -7817,8 +7794,11 @@ mod tests {
                        }
                        ],
                        blinded_tail: Some(BlindedTail {
-                               hops: blinded_path.blinded_hops,
-                               blinding_point: blinded_path.blinding_point,
+                               hops: vec![
+                                       BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
+                                       BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
+                               ],
+                               blinding_point: ln_test_utils::pubkey(44),
                                excess_final_cltv_expiry_delta: 0,
                                final_value_msat: 200,
                        }),
index a04a1850489c4be4b985e2a8af4eda5e1922b789..7945a5b80b3d400048bbad33099950555ea560cd 100644 (file)
@@ -2152,7 +2152,7 @@ impl Readable for ChannelLiquidity {
 #[cfg(test)]
 mod tests {
        use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters, ProbabilisticScorer};
-       use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
+       use crate::blinded_path::BlindedHop;
        use crate::util::config::UserConfig;
 
        use crate::ln::channelmanager;
@@ -3567,16 +3567,9 @@ mod tests {
 
                let mut path = payment_path_for_amount(768);
                let recipient_hop = path.hops.pop().unwrap();
-               let blinded_path = BlindedPath {
-                       introduction_node: IntroductionNode::NodeId(path.hops.last().as_ref().unwrap().pubkey),
-                       blinding_point: test_utils::pubkey(42),
-                       blinded_hops: vec![
-                               BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }
-                       ],
-               };
                path.blinded_tail = Some(BlindedTail {
-                       hops: blinded_path.blinded_hops,
-                       blinding_point: blinded_path.blinding_point,
+                       hops: vec![BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }],
+                       blinding_point: test_utils::pubkey(42),
                        excess_final_cltv_expiry_delta: recipient_hop.cltv_expiry_delta,
                        final_value_msat: recipient_hop.fee_msat,
                });