@@ -20,7 +20,7 @@ use crate::ln::features::{InitFeatures, NodeFeatures};
20
20
use crate :: ln:: msgs:: { self , OnionMessageHandler } ;
21
21
use crate :: ln:: onion_utils;
22
22
use crate :: ln:: peer_handler:: IgnoringMessageHandler ;
23
- use super :: blinded_route:: { BlindedRoute , ForwardTlvs , ReceiveTlvs } ;
23
+ use super :: blinded_route:: { BlindedPath , ForwardTlvs , ReceiveTlvs } ;
24
24
pub use super :: packet:: { CustomOnionMessageContents , OnionMessageContents } ;
25
25
use super :: packet:: { BIG_PACKET_HOP_DATA_LEN , ForwardControlTlvs , Packet , Payload , ReceiveControlTlvs , SMALL_PACKET_HOP_DATA_LEN } ;
26
26
use super :: utils;
@@ -46,7 +46,7 @@ use crate::prelude::*;
46
46
/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
47
47
/// # use lightning::ln::msgs::DecodeError;
48
48
/// # use lightning::ln::peer_handler::IgnoringMessageHandler;
49
- /// # use lightning::onion_message::{BlindedRoute , CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
49
+ /// # use lightning::onion_message::{BlindedPath , CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
50
50
/// # use lightning::util::logger::{Logger, Record};
51
51
/// # use lightning::util::ser::{Writeable, Writer};
52
52
/// # use lightning::io;
@@ -92,14 +92,14 @@ use crate::prelude::*;
92
92
/// // Create a blinded route to yourself, for someone to send an onion message to.
93
93
/// # let your_node_id = hop_node_id1;
94
94
/// let hops = [hop_node_id3, hop_node_id4, your_node_id];
95
- /// let blinded_route = BlindedRoute ::new(&hops, &keys_manager, &secp_ctx).unwrap();
95
+ /// let blinded_route = BlindedPath ::new(&hops, &keys_manager, &secp_ctx).unwrap();
96
96
///
97
97
/// // Send a custom onion message to a blinded route.
98
98
/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
99
99
/// let reply_path = None;
100
100
/// # let your_custom_message = YourCustomMessage {};
101
101
/// let message = OnionMessageContents::Custom(your_custom_message);
102
- /// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute (blinded_route), message, reply_path);
102
+ /// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath (blinded_route), message, reply_path);
103
103
/// ```
104
104
///
105
105
/// [offers]: <https://github.com/lightning/bolts/pull/798>
@@ -123,14 +123,14 @@ pub enum Destination {
123
123
/// We're sending this onion message to a node.
124
124
Node ( PublicKey ) ,
125
125
/// We're sending this onion message to a blinded route.
126
- BlindedRoute ( BlindedRoute ) ,
126
+ BlindedPath ( BlindedPath ) ,
127
127
}
128
128
129
129
impl Destination {
130
130
pub ( super ) fn num_hops ( & self ) -> usize {
131
131
match self {
132
132
Destination :: Node ( _) => 1 ,
133
- Destination :: BlindedRoute ( BlindedRoute { blinded_hops, .. } ) => blinded_hops. len ( ) ,
133
+ Destination :: BlindedPath ( BlindedPath { blinded_hops, .. } ) => blinded_hops. len ( ) ,
134
134
}
135
135
}
136
136
}
@@ -145,7 +145,7 @@ pub enum SendError {
145
145
/// Because implementations such as Eclair will drop onion messages where the message packet
146
146
/// exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
147
147
TooBigPacket ,
148
- /// The provided [`Destination`] was an invalid [`BlindedRoute `], due to having fewer than two
148
+ /// The provided [`Destination`] was an invalid [`BlindedPath `], due to having fewer than two
149
149
/// blinded hops.
150
150
TooFewBlindedHops ,
151
151
/// Our next-hop peer was offline or does not support onion message forwarding.
@@ -162,7 +162,7 @@ pub enum SendError {
162
162
/// advance the blinded route to make the second hop the new introduction node. Either
163
163
/// [`KeysInterface::ecdh`] failed, we failed to tweak the current blinding point to get the
164
164
/// new blinding point, or we were attempting to send to ourselves.
165
- BlindedRouteAdvanceFailed ,
165
+ BlindedPathAdvanceFailed ,
166
166
}
167
167
168
168
/// Handler for custom onion messages. If you are using [`SimpleArcOnionMessenger`],
@@ -207,8 +207,8 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
207
207
208
208
/// Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`.
209
209
/// See [`OnionMessenger`] for example usage.
210
- pub fn send_onion_message < T : CustomOnionMessageContents > ( & self , intermediate_nodes : & [ PublicKey ] , mut destination : Destination , message : OnionMessageContents < T > , reply_path : Option < BlindedRoute > ) -> Result < ( ) , SendError > {
211
- if let Destination :: BlindedRoute ( BlindedRoute { ref blinded_hops, .. } ) = destination {
210
+ pub fn send_onion_message < T : CustomOnionMessageContents > ( & self , intermediate_nodes : & [ PublicKey ] , mut destination : Destination , message : OnionMessageContents < T > , reply_path : Option < BlindedPath > ) -> Result < ( ) , SendError > {
211
+ if let Destination :: BlindedPath ( BlindedPath { ref blinded_hops, .. } ) = destination {
212
212
if blinded_hops. len ( ) < 2 {
213
213
return Err ( SendError :: TooFewBlindedHops ) ;
214
214
}
@@ -219,12 +219,12 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
219
219
// If we are sending straight to a blinded route and we are the introduction node, we need to
220
220
// advance the blinded route by 1 hop so the second hop is the new introduction node.
221
221
if intermediate_nodes. len ( ) == 0 {
222
- if let Destination :: BlindedRoute ( ref mut blinded_route) = destination {
222
+ if let Destination :: BlindedPath ( ref mut blinded_route) = destination {
223
223
let our_node_id = self . keys_manager . get_node_id ( Recipient :: Node )
224
224
. map_err ( |( ) | SendError :: GetNodeIdFailed ) ?;
225
225
if blinded_route. introduction_node_id == our_node_id {
226
226
blinded_route. advance_by_one ( & self . keys_manager , & self . secp_ctx )
227
- . map_err ( |( ) | SendError :: BlindedRouteAdvanceFailed ) ?;
227
+ . map_err ( |( ) | SendError :: BlindedPathAdvanceFailed ) ?;
228
228
}
229
229
}
230
230
}
@@ -236,7 +236,7 @@ impl<K: Deref, L: Deref, CMH: Deref> OnionMessenger<K, L, CMH>
236
236
} else {
237
237
match destination {
238
238
Destination :: Node ( pk) => ( pk, PublicKey :: from_secret_key ( & self . secp_ctx , & blinding_secret) ) ,
239
- Destination :: BlindedRoute ( BlindedRoute { introduction_node_id, blinding_point, .. } ) =>
239
+ Destination :: BlindedPath ( BlindedPath { introduction_node_id, blinding_point, .. } ) =>
240
240
( introduction_node_id, blinding_point) ,
241
241
}
242
242
} ;
@@ -476,13 +476,13 @@ pub type SimpleRefOnionMessenger<'a, 'b, L> = OnionMessenger<&'a KeysManager, &'
476
476
/// `unblinded_path` to the given `destination`.
477
477
fn packet_payloads_and_keys < T : CustomOnionMessageContents , S : secp256k1:: Signing + secp256k1:: Verification > (
478
478
secp_ctx : & Secp256k1 < S > , unblinded_path : & [ PublicKey ] , destination : Destination ,
479
- message : OnionMessageContents < T > , mut reply_path : Option < BlindedRoute > , session_priv : & SecretKey
479
+ message : OnionMessageContents < T > , mut reply_path : Option < BlindedPath > , session_priv : & SecretKey
480
480
) -> Result < ( Vec < ( Payload < T > , [ u8 ; 32 ] ) > , Vec < onion_utils:: OnionKeys > ) , secp256k1:: Error > {
481
481
let num_hops = unblinded_path. len ( ) + destination. num_hops ( ) ;
482
482
let mut payloads = Vec :: with_capacity ( num_hops) ;
483
483
let mut onion_packet_keys = Vec :: with_capacity ( num_hops) ;
484
484
485
- let ( mut intro_node_id_blinding_pt, num_blinded_hops) = if let Destination :: BlindedRoute ( BlindedRoute {
485
+ let ( mut intro_node_id_blinding_pt, num_blinded_hops) = if let Destination :: BlindedPath ( BlindedPath {
486
486
introduction_node_id, blinding_point, blinded_hops } ) = & destination {
487
487
( Some ( ( * introduction_node_id, * blinding_point) ) , blinded_hops. len ( ) ) } else { ( None , 0 ) } ;
488
488
let num_unblinded_hops = num_hops - num_blinded_hops;
0 commit comments