1212use crate :: chain:: keysinterface:: { KeysInterface , Recipient } ;
1313use crate :: ln:: features:: InitFeatures ;
1414use crate :: ln:: msgs:: { self , DecodeError , OnionMessageHandler } ;
15- use super :: { BlindedRoute , CustomOnionMessageContents , CustomOnionMessageHandler , Destination , OnionMessageContents , OnionMessenger , SendError } ;
15+ use super :: { BlindedPath , CustomOnionMessageContents , CustomOnionMessageHandler , Destination , OnionMessageContents , OnionMessenger , SendError } ;
1616use crate :: util:: ser:: { Writeable , Writer } ;
1717use crate :: util:: test_utils;
1818
@@ -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 = BlindedRoute :: 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 :: BlindedRoute ( 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 = BlindedRoute :: 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 :: BlindedRoute ( 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
@@ -168,42 +168,42 @@ fn too_big_packet_error() {
168168
169169#[ test]
170170fn we_are_intro_node ( ) {
171- // If we are sending straight to a blinded route and we are the introduction node, we need to
172- // advance the blinded route by 1 hop so the second hop is the new introduction node.
171+ // If we are sending straight to a blinded path and we are the introduction node, we need to
172+ // advance the blinded path by 1 hop so the second hop is the new introduction node.
173173 let mut nodes = create_nodes ( 3 ) ;
174174 let test_msg = TestCustomMessage { } ;
175175
176176 let secp_ctx = Secp256k1 :: new ( ) ;
177- let blinded_route = BlindedRoute :: 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 :: BlindedRoute ( 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
182- // Try with a two-hop blinded route where we are the introduction node.
183- let blinded_route = BlindedRoute :: 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 :: BlindedRoute ( blinded_route ) , OnionMessageContents :: Custom ( test_msg) , None ) . unwrap ( ) ;
182+ // Try with a two-hop blinded path where we are the introduction node.
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 ( ) {
191- // Make sure we error as expected if a provided blinded route has 0 or 1 hops.
190+ fn invalid_blinded_path_error ( ) {
191+ // Make sure we error as expected if a provided blinded path 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 = BlindedRoute :: 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 :: BlindedRoute ( 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 = BlindedRoute :: 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 :: BlindedRoute ( 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
@@ -214,19 +214,19 @@ fn reply_path() {
214214 let secp_ctx = Secp256k1 :: new ( ) ;
215215
216216 // Destination::Node
217- let reply_path = BlindedRoute :: new ( & [ nodes[ 2 ] . get_node_pk ( ) , nodes[ 1 ] . get_node_pk ( ) , nodes[ 0 ] . get_node_pk ( ) ] , & * nodes[ 0 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
217+ 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 ( ) ;
218218 nodes[ 0 ] . messenger . send_onion_message ( & [ nodes[ 1 ] . get_node_pk ( ) , nodes[ 2 ] . get_node_pk ( ) ] , Destination :: Node ( nodes[ 3 ] . get_node_pk ( ) ) , OnionMessageContents :: Custom ( test_msg. clone ( ) ) , Some ( reply_path) ) . unwrap ( ) ;
219219 pass_along_path ( & nodes, None ) ;
220220 // Make sure the last node successfully decoded the reply path.
221221 nodes[ 3 ] . logger . assert_log_contains (
222222 "lightning::onion_message::messenger" . to_string ( ) ,
223223 format ! ( "Received an onion message with path_id None and a reply_path" ) . to_string ( ) , 1 ) ;
224224
225- // Destination::BlindedRoute
226- let blinded_route = BlindedRoute :: new ( & [ nodes[ 1 ] . get_node_pk ( ) , nodes[ 2 ] . get_node_pk ( ) , nodes[ 3 ] . get_node_pk ( ) ] , & * nodes[ 3 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
227- let reply_path = BlindedRoute :: new ( & [ nodes[ 2 ] . get_node_pk ( ) , nodes[ 1 ] . get_node_pk ( ) , nodes[ 0 ] . get_node_pk ( ) ] , & * nodes[ 0 ] . keys_manager , & secp_ctx) . unwrap ( ) ;
225+ // Destination::BlindedPath
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 ( ) ;
227+ 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 :: BlindedRoute ( 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 ( ) ,
0 commit comments