Skip to content

Commit bba6e90

Browse files
committed
Rename blinded_route variables and module to blinded_path
Following up on the previous commit, this also renames variables and the module used to `blinded_path`.
1 parent 1bb4abd commit bba6e90

File tree

6 files changed

+30
-261
lines changed

6 files changed

+30
-261
lines changed

lightning/src/onion_message/blinded_route.rs

-231
This file was deleted.

lightning/src/onion_message/functional_tests.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ fn two_unblinded_two_blinded() {
136136
let test_msg = OnionMessageContents::Custom(TestCustomMessage {});
137137

138138
let secp_ctx = Secp256k1::new();
139-
let blinded_route = BlindedPath::new(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
139+
let blinded_path = BlindedPath::new(&[nodes[3].get_node_pk(), nodes[4].get_node_pk()], &*nodes[4].keys_manager, &secp_ctx).unwrap();
140140

141-
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::BlindedPath(blinded_route), test_msg, None).unwrap();
141+
nodes[0].messenger.send_onion_message(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], Destination::BlindedPath(blinded_path), test_msg, None).unwrap();
142142
pass_along_path(&nodes, None);
143143
}
144144

@@ -148,9 +148,9 @@ fn three_blinded_hops() {
148148
let test_msg = OnionMessageContents::Custom(TestCustomMessage {});
149149

150150
let secp_ctx = Secp256k1::new();
151-
let blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
151+
let blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
152152

153-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), test_msg, None).unwrap();
153+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), test_msg, None).unwrap();
154154
pass_along_path(&nodes, None);
155155
}
156156

@@ -174,36 +174,36 @@ fn we_are_intro_node() {
174174
let test_msg = TestCustomMessage {};
175175

176176
let secp_ctx = Secp256k1::new();
177-
let blinded_route = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
177+
let blinded_path = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
178178

179-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg.clone()), None).unwrap();
179+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg.clone()), None).unwrap();
180180
pass_along_path(&nodes, None);
181181

182182
// Try with a two-hop blinded route where we are the introduction node.
183-
let blinded_route = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk()], &*nodes[1].keys_manager, &secp_ctx).unwrap();
184-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), None).unwrap();
183+
let blinded_path = BlindedPath::new(&[nodes[0].get_node_pk(), nodes[1].get_node_pk()], &*nodes[1].keys_manager, &secp_ctx).unwrap();
184+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), None).unwrap();
185185
nodes.remove(2);
186186
pass_along_path(&nodes, None);
187187
}
188188

189189
#[test]
190-
fn invalid_blinded_route_error() {
190+
fn invalid_blinded_path_error() {
191191
// Make sure we error as expected if a provided blinded route has 0 or 1 hops.
192192
let nodes = create_nodes(3);
193193
let test_msg = TestCustomMessage {};
194194

195195
// 0 hops
196196
let secp_ctx = Secp256k1::new();
197-
let mut blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
198-
blinded_route.blinded_hops.clear();
199-
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg.clone()), None).unwrap_err();
197+
let mut blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
198+
blinded_path.blinded_hops.clear();
199+
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg.clone()), None).unwrap_err();
200200
assert_eq!(err, SendError::TooFewBlindedHops);
201201

202202
// 1 hop
203-
let mut blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
204-
blinded_route.blinded_hops.remove(0);
205-
assert_eq!(blinded_route.blinded_hops.len(), 1);
206-
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), None).unwrap_err();
203+
let mut blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk()], &*nodes[2].keys_manager, &secp_ctx).unwrap();
204+
blinded_path.blinded_hops.remove(0);
205+
assert_eq!(blinded_path.blinded_hops.len(), 1);
206+
let err = nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), None).unwrap_err();
207207
assert_eq!(err, SendError::TooFewBlindedHops);
208208
}
209209

@@ -223,10 +223,10 @@ fn reply_path() {
223223
format!("Received an onion message with path_id None and a reply_path").to_string(), 1);
224224

225225
// Destination::BlindedPath
226-
let blinded_route = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
226+
let blinded_path = BlindedPath::new(&[nodes[1].get_node_pk(), nodes[2].get_node_pk(), nodes[3].get_node_pk()], &*nodes[3].keys_manager, &secp_ctx).unwrap();
227227
let reply_path = BlindedPath::new(&[nodes[2].get_node_pk(), nodes[1].get_node_pk(), nodes[0].get_node_pk()], &*nodes[0].keys_manager, &secp_ctx).unwrap();
228228

229-
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_route), OnionMessageContents::Custom(test_msg), Some(reply_path)).unwrap();
229+
nodes[0].messenger.send_onion_message(&[], Destination::BlindedPath(blinded_path), OnionMessageContents::Custom(test_msg), Some(reply_path)).unwrap();
230230
pass_along_path(&nodes, None);
231231
nodes[3].logger.assert_log_contains(
232232
"lightning::onion_message::messenger".to_string(),

lightning/src/onion_message/messenger.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::ln::features::{InitFeatures, NodeFeatures};
2020
use crate::ln::msgs::{self, OnionMessageHandler};
2121
use crate::ln::onion_utils;
2222
use crate::ln::peer_handler::IgnoringMessageHandler;
23-
use super::blinded_route::{BlindedPath, ForwardTlvs, ReceiveTlvs};
23+
use super::blinded_path::{BlindedPath, ForwardTlvs, ReceiveTlvs};
2424
pub use super::packet::{CustomOnionMessageContents, OnionMessageContents};
2525
use super::packet::{BIG_PACKET_HOP_DATA_LEN, ForwardControlTlvs, Packet, Payload, ReceiveControlTlvs, SMALL_PACKET_HOP_DATA_LEN};
2626
use super::utils;
@@ -92,14 +92,14 @@ use crate::prelude::*;
9292
/// // Create a blinded route to yourself, for someone to send an onion message to.
9393
/// # let your_node_id = hop_node_id1;
9494
/// let hops = [hop_node_id3, hop_node_id4, your_node_id];
95-
/// let blinded_route = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
95+
/// let blinded_path = BlindedPath::new(&hops, &keys_manager, &secp_ctx).unwrap();
9696
///
9797
/// // Send a custom onion message to a blinded route.
9898
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
9999
/// let reply_path = None;
100100
/// # let your_custom_message = YourCustomMessage {};
101101
/// let message = OnionMessageContents::Custom(your_custom_message);
102-
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_route), message, reply_path);
102+
/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_path), message, reply_path);
103103
/// ```
104104
///
105105
/// [offers]: <https://github.com/lightning/bolts/pull/798>
@@ -219,11 +219,11 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
219219
// If we are sending straight to a blinded route and we are the introduction node, we need to
220220
// advance the blinded route by 1 hop so the second hop is the new introduction node.
221221
if intermediate_nodes.len() == 0 {
222-
if let Destination::BlindedPath(ref mut blinded_route) = destination {
222+
if let Destination::BlindedPath(ref mut blinded_path) = destination {
223223
let our_node_id = self.keys_manager.get_node_id(Recipient::Node)
224224
.map_err(|()| SendError::GetNodeIdFailed)?;
225-
if blinded_route.introduction_node_id == our_node_id {
226-
blinded_route.advance_by_one(&self.keys_manager, &self.secp_ctx)
225+
if blinded_path.introduction_node_id == our_node_id {
226+
blinded_path.advance_by_one(&self.keys_manager, &self.secp_ctx)
227227
.map_err(|()| SendError::BlindedPathAdvanceFailed)?;
228228
}
229229
}

lightning/src/onion_message/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
//! [offers]: <https://github.com/lightning/bolts/pull/798>
2121
//! [blinded routes]: crate::onion_message::BlindedRoute
2222
23-
mod blinded_route;
23+
mod blinded_path;
2424
mod messenger;
2525
mod packet;
2626
mod utils;
2727
#[cfg(test)]
2828
mod functional_tests;
2929

3030
// Re-export structs so they can be imported with just the `onion_message::` module prefix.
31-
pub use self::blinded_route::{BlindedPath, BlindedHop};
31+
pub use self::blinded_path::{BlindedPath, BlindedHop};
3232
pub use self::messenger::{CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger};
3333
pub(crate) use self::packet::Packet;

0 commit comments

Comments
 (0)