Skip to content

Commit 10449b9

Browse files
Move public_intro_node util into Blinded{Message,Payment}Path
Helps move towards making the BlindedPath struct private.
1 parent cbc25fb commit 10449b9

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ impl BlindedMessagePath {
112112
}
113113
}
114114
}
115+
116+
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
117+
/// it is found in the network graph).
118+
pub fn public_introduction_node_id<'a>(
119+
&self, network_graph: &'a ReadOnlyNetworkGraph
120+
) -> Option<&'a NodeId> {
121+
self.0.public_introduction_node_id(network_graph)
122+
}
115123
}
116124

117125
/// An intermediate node, and possibly a short channel id leading to the next node.

lightning/src/blinded_path/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ pub struct BlindedHop {
118118
}
119119

120120
impl BlindedPath {
121-
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
122-
/// it is found in the network graph).
123-
pub fn public_introduction_node_id<'a>(
121+
pub(super) fn public_introduction_node_id<'a>(
124122
&self, network_graph: &'a ReadOnlyNetworkGraph
125123
) -> Option<&'a NodeId> {
126124
match &self.introduction_node {

lightning/src/blinded_path/payment.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::ln::onion_utils;
2424
use crate::offers::invoice::BlindedPayInfo;
2525
use crate::offers::invoice_request::InvoiceRequestFields;
2626
use crate::offers::offer::OfferId;
27+
use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
2728
use crate::sign::{EntropySource, NodeSigner, Recipient};
2829
use crate::util::ser::{FixedLengthReader, LengthReadableArgs, HighZeroBytesDroppedBigSize, Readable, Writeable, Writer};
2930

@@ -94,6 +95,14 @@ impl BlindedPaymentPath {
9495
).map_err(|_| ())?,
9596
})))
9697
}
98+
99+
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
100+
/// it is found in the network graph).
101+
pub fn public_introduction_node_id<'a>(
102+
&self, network_graph: &'a ReadOnlyNetworkGraph
103+
) -> Option<&'a NodeId> {
104+
self.0.public_introduction_node_id(network_graph)
105+
}
97106
}
98107

99108
/// An intermediate node, its outbound channel, and relay parameters.

lightning/src/ln/offers_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn announce_node_address<'a, 'b, 'c>(
141141
}
142142

143143
fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &BlindedMessagePath) -> PublicKey {
144-
path.0.public_introduction_node_id(&node.network_graph.read_only())
144+
path.public_introduction_node_id(&node.network_graph.read_only())
145145
.and_then(|node_id| node_id.as_pubkey().ok())
146146
.unwrap()
147147
}

lightning/src/onion_message/messenger.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ impl Destination {
699699
if let Destination::BlindedPath(path) = self {
700700
if let IntroductionNode::DirectedShortChannelId(..) = path.0.introduction_node {
701701
if let Some(pubkey) = path
702-
.0
703702
.public_introduction_node_id(network_graph)
704703
.and_then(|node_id| node_id.as_pubkey().ok())
705704
{

lightning/src/routing/router.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ where L::Target: Logger {
16461646
node_counters.node_counter_from_id(&NodeId::from_pubkey(&pubkey))
16471647
},
16481648
IntroductionNode::DirectedShortChannelId(direction, scid) => {
1649-
path.0.public_introduction_node_id(network_graph)
1649+
path.public_introduction_node_id(network_graph)
16501650
.map(|node_id_ref| *node_id_ref)
16511651
.or_else(|| {
16521652
first_hop_targets.iter().find(|(_, (channels, _))|
@@ -5671,7 +5671,7 @@ mod tests {
56715671
NodeId::from_pubkey(&path.hops.last().unwrap().pubkey),
56725672
payment_params.payee.blinded_route_hints().iter()
56735673
.find(|(p, _)| p.htlc_maximum_msat == path.final_value_msat())
5674-
.and_then(|(_, p)| p.0.public_introduction_node_id(&network_graph))
5674+
.and_then(|(_, p)| p.public_introduction_node_id(&network_graph))
56755675
.copied()
56765676
.unwrap()
56775677
);
@@ -7878,7 +7878,7 @@ mod tests {
78787878
let final_hop = route.paths[0].hops.last().unwrap();
78797879
assert_eq!(
78807880
NodeId::from_pubkey(&final_hop.pubkey),
7881-
*blinded_path.0.public_introduction_node_id(&network_graph).unwrap()
7881+
*blinded_path.public_introduction_node_id(&network_graph).unwrap()
78827882
);
78837883
if tail.hops.len() > 1 {
78847884
assert_eq!(final_hop.fee_msat,

0 commit comments

Comments
 (0)