Skip to content

Commit 9fb62c0

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

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
@@ -103,6 +103,14 @@ impl BlindedMessagePath {
103103
}
104104
}
105105
}
106+
107+
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
108+
/// it is found in the network graph).
109+
pub fn public_introduction_node_id<'a>(
110+
&self, network_graph: &'a ReadOnlyNetworkGraph
111+
) -> Option<&'a NodeId> {
112+
self.0.public_introduction_node_id(network_graph)
113+
}
106114
}
107115

108116
/// 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
@@ -164,9 +164,7 @@ impl BlindedPath {
164164
})
165165
}
166166

167-
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
168-
/// it is found in the network graph).
169-
pub fn public_introduction_node_id<'a>(
167+
pub(super) fn public_introduction_node_id<'a>(
170168
&self, network_graph: &'a ReadOnlyNetworkGraph
171169
) -> Option<&'a NodeId> {
172170
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

@@ -80,6 +81,14 @@ impl BlindedPaymentPath {
8081
).map_err(|_| ())?,
8182
})))
8283
}
84+
85+
/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
86+
/// it is found in the network graph).
87+
pub fn public_introduction_node_id<'a>(
88+
&self, network_graph: &'a ReadOnlyNetworkGraph
89+
) -> Option<&'a NodeId> {
90+
self.0.public_introduction_node_id(network_graph)
91+
}
8392
}
8493

8594
/// 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
@@ -137,7 +137,7 @@ fn announce_node_address<'a, 'b, 'c>(
137137
}
138138

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

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
@@ -1667,7 +1667,7 @@ where L::Target: Logger {
16671667
node_counters.node_counter_from_id(&NodeId::from_pubkey(&pubkey))
16681668
},
16691669
IntroductionNode::DirectedShortChannelId(direction, scid) => {
1670-
path.0.public_introduction_node_id(network_graph)
1670+
path.public_introduction_node_id(network_graph)
16711671
.map(|node_id_ref| *node_id_ref)
16721672
.or_else(|| {
16731673
first_hop_targets.iter().find(|(_, (channels, _))|
@@ -5692,7 +5692,7 @@ mod tests {
56925692
NodeId::from_pubkey(&path.hops.last().unwrap().pubkey),
56935693
payment_params.payee.blinded_route_hints().iter()
56945694
.find(|(p, _)| p.htlc_maximum_msat == path.final_value_msat())
5695-
.and_then(|(_, p)| p.0.public_introduction_node_id(&network_graph))
5695+
.and_then(|(_, p)| p.public_introduction_node_id(&network_graph))
56965696
.copied()
56975697
.unwrap()
56985698
);
@@ -7899,7 +7899,7 @@ mod tests {
78997899
let final_hop = route.paths[0].hops.last().unwrap();
79007900
assert_eq!(
79017901
NodeId::from_pubkey(&final_hop.pubkey),
7902-
*blinded_path.0.public_introduction_node_id(&network_graph).unwrap()
7902+
*blinded_path.public_introduction_node_id(&network_graph).unwrap()
79037903
);
79047904
if tail.hops.len() > 1 {
79057905
assert_eq!(final_hop.fee_msat,

0 commit comments

Comments
 (0)