Skip to content

Commit aa9b03a

Browse files
Make BlindedPath type private.
Users should use the Blinded{Message,Payment}Path types instead.
1 parent 5a8cf06 commit aa9b03a

File tree

5 files changed

+29
-56
lines changed

5 files changed

+29
-56
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Readable, Writeabl
3434
use core::mem;
3535
use core::ops::Deref;
3636

37-
/// A [`BlindedPath`] to be used for sending or receiving a message, hiding the identity of the
37+
/// A blinded path to be used for sending or receiving a message, hiding the identity of the
3838
/// recipient.
3939
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
4040
pub struct BlindedMessagePath(pub(super) BlindedPath);

lightning/src/blinded_path/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum NextMessageHop {
3737
/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
3838
/// identity of the recipient.
3939
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
40-
pub struct BlindedPath {
40+
struct BlindedPath {
4141
/// To send to a blinded path, the sender first finds a route to the unblinded
4242
/// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
4343
/// message or payment's next hop and forward it along.
@@ -53,7 +53,7 @@ pub struct BlindedPath {
5353
pub blinded_hops: Vec<BlindedHop>,
5454
}
5555

56-
/// The unblinded node in a [`BlindedPath`].
56+
/// The unblinded node in a blinded path.
5757
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
5858
pub enum IntroductionNode {
5959
/// The node id of the introduction node.
@@ -63,8 +63,8 @@ pub enum IntroductionNode {
6363
DirectedShortChannelId(Direction, u64),
6464
}
6565

66-
/// The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines
67-
/// which nodes is which in the [`ChannelAnnouncement`] message.
66+
/// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which
67+
/// nodes is which in the [`ChannelAnnouncement`] message.
6868
///
6969
/// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7070
/// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement
@@ -109,9 +109,9 @@ impl Deref for EmptyNodeIdLookUp {
109109
/// and thus can be used to hide the identity of the recipient.
110110
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
111111
pub struct BlindedHop {
112-
/// The blinded node id of this hop in a [`BlindedPath`].
112+
/// The blinded node id of this hop in a blinded path.
113113
pub blinded_node_id: PublicKey,
114-
/// The encrypted payload intended for this hop in a [`BlindedPath`].
114+
/// The encrypted payload intended for this hop in a blinded path.
115115
// The node sending to this blinded path will later encode this payload into the onion packet for
116116
// this hop.
117117
pub encrypted_payload: Vec<u8>,

lightning/src/blinded_path/payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use core::ops::Deref;
3434
#[allow(unused_imports)]
3535
use crate::prelude::*;
3636

37-
/// A [`BlindedPath`] to be used for sending or receiving a payment, hiding the identity of the
37+
/// A blinded path to be used for sending or receiving a payment, hiding the identity of the
3838
/// recipient.
3939
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
4040
pub struct BlindedPaymentPath(pub(super) BlindedPath);

lightning/src/routing/router.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,7 @@ fn build_route_from_hops_internal<L: Deref>(
35413541

35423542
#[cfg(test)]
35433543
mod tests {
3544-
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
3544+
use crate::blinded_path::BlindedHop;
35453545
use crate::blinded_path::payment::BlindedPaymentPath;
35463546
use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, EffectiveCapacity};
35473547
use crate::routing::utxo::UtxoResult;
@@ -7682,22 +7682,6 @@ mod tests {
76827682

76837683
#[test]
76847684
fn blinded_route_ser() {
7685-
let blinded_path_1 = BlindedPath {
7686-
introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(42)),
7687-
blinding_point: ln_test_utils::pubkey(43),
7688-
blinded_hops: vec![
7689-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
7690-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
7691-
],
7692-
};
7693-
let blinded_path_2 = BlindedPath {
7694-
introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(46)),
7695-
blinding_point: ln_test_utils::pubkey(47),
7696-
blinded_hops: vec![
7697-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
7698-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
7699-
],
7700-
};
77017685
// (De)serialize a Route with 1 blinded path out of two total paths.
77027686
let mut route = Route { paths: vec![Path {
77037687
hops: vec![RouteHop {
@@ -7710,8 +7694,11 @@ mod tests {
77107694
maybe_announced_channel: true,
77117695
}],
77127696
blinded_tail: Some(BlindedTail {
7713-
hops: blinded_path_1.blinded_hops,
7714-
blinding_point: blinded_path_1.blinding_point,
7697+
hops: vec![
7698+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
7699+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
7700+
],
7701+
blinding_point: ln_test_utils::pubkey(43),
77157702
excess_final_cltv_expiry_delta: 40,
77167703
final_value_msat: 100,
77177704
})}, Path {
@@ -7733,8 +7720,11 @@ mod tests {
77337720

77347721
// (De)serialize a Route with two paths, each containing a blinded tail.
77357722
route.paths[1].blinded_tail = Some(BlindedTail {
7736-
hops: blinded_path_2.blinded_hops,
7737-
blinding_point: blinded_path_2.blinding_point,
7723+
hops: vec![
7724+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
7725+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
7726+
],
7727+
blinding_point: ln_test_utils::pubkey(47),
77387728
excess_final_cltv_expiry_delta: 41,
77397729
final_value_msat: 101,
77407730
});
@@ -7749,11 +7739,6 @@ mod tests {
77497739
// Ensure we'll score the channel that's inbound to a blinded path's introduction node, and
77507740
// account for the blinded tail's final amount_msat.
77517741
let mut inflight_htlcs = InFlightHtlcs::new();
7752-
let blinded_path = BlindedPath {
7753-
introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
7754-
blinding_point: ln_test_utils::pubkey(48),
7755-
blinded_hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
7756-
};
77577742
let path = Path {
77587743
hops: vec![RouteHop {
77597744
pubkey: ln_test_utils::pubkey(42),
@@ -7774,8 +7759,8 @@ mod tests {
77747759
maybe_announced_channel: false,
77757760
}],
77767761
blinded_tail: Some(BlindedTail {
7777-
hops: blinded_path.blinded_hops,
7778-
blinding_point: blinded_path.blinding_point,
7762+
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
7763+
blinding_point: ln_test_utils::pubkey(48),
77797764
excess_final_cltv_expiry_delta: 0,
77807765
final_value_msat: 200,
77817766
}),
@@ -7788,14 +7773,6 @@ mod tests {
77887773
#[test]
77897774
fn blinded_path_cltv_shadow_offset() {
77907775
// Make sure we add a shadow offset when sending to blinded paths.
7791-
let blinded_path = BlindedPath {
7792-
introduction_node: IntroductionNode::NodeId(ln_test_utils::pubkey(43)),
7793-
blinding_point: ln_test_utils::pubkey(44),
7794-
blinded_hops: vec![
7795-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
7796-
BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
7797-
],
7798-
};
77997776
let mut route = Route { paths: vec![Path {
78007777
hops: vec![RouteHop {
78017778
pubkey: ln_test_utils::pubkey(42),
@@ -7817,8 +7794,11 @@ mod tests {
78177794
}
78187795
],
78197796
blinded_tail: Some(BlindedTail {
7820-
hops: blinded_path.blinded_hops,
7821-
blinding_point: blinded_path.blinding_point,
7797+
hops: vec![
7798+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
7799+
BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }
7800+
],
7801+
blinding_point: ln_test_utils::pubkey(44),
78227802
excess_final_cltv_expiry_delta: 0,
78237803
final_value_msat: 200,
78247804
}),

lightning/src/routing/scoring.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,7 @@ impl Readable for ChannelLiquidity {
21522152
#[cfg(test)]
21532153
mod tests {
21542154
use super::{ChannelLiquidity, HistoricalBucketRangeTracker, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters, ProbabilisticScorer};
2155-
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
2155+
use crate::blinded_path::BlindedHop;
21562156
use crate::util::config::UserConfig;
21572157

21582158
use crate::ln::channelmanager;
@@ -3567,16 +3567,9 @@ mod tests {
35673567

35683568
let mut path = payment_path_for_amount(768);
35693569
let recipient_hop = path.hops.pop().unwrap();
3570-
let blinded_path = BlindedPath {
3571-
introduction_node: IntroductionNode::NodeId(path.hops.last().as_ref().unwrap().pubkey),
3572-
blinding_point: test_utils::pubkey(42),
3573-
blinded_hops: vec![
3574-
BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }
3575-
],
3576-
};
35773570
path.blinded_tail = Some(BlindedTail {
3578-
hops: blinded_path.blinded_hops,
3579-
blinding_point: blinded_path.blinding_point,
3571+
hops: vec![BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }],
3572+
blinding_point: test_utils::pubkey(42),
35803573
excess_final_cltv_expiry_delta: recipient_hop.cltv_expiry_delta,
35813574
final_value_msat: recipient_hop.fee_msat,
35823575
});

0 commit comments

Comments
 (0)