12
12
use crate :: chain:: keysinterface:: { KeysInterface , Recipient } ;
13
13
use crate :: ln:: features:: InitFeatures ;
14
14
use 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 } ;
16
16
use crate :: util:: ser:: { Writeable , Writer } ;
17
17
use crate :: util:: test_utils;
18
18
@@ -136,9 +136,9 @@ fn two_unblinded_two_blinded() {
136
136
let test_msg = OnionMessageContents :: Custom ( TestCustomMessage { } ) ;
137
137
138
138
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 ( ) ;
140
140
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 ( ) ;
142
142
pass_along_path ( & nodes, None ) ;
143
143
}
144
144
@@ -148,9 +148,9 @@ fn three_blinded_hops() {
148
148
let test_msg = OnionMessageContents :: Custom ( TestCustomMessage { } ) ;
149
149
150
150
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 ( ) ;
152
152
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 ( ) ;
154
154
pass_along_path ( & nodes, None ) ;
155
155
}
156
156
@@ -168,42 +168,42 @@ fn too_big_packet_error() {
168
168
169
169
#[ test]
170
170
fn 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.
173
173
let mut nodes = create_nodes ( 3 ) ;
174
174
let test_msg = TestCustomMessage { } ;
175
175
176
176
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 ( ) ;
178
178
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 ( ) ;
180
180
pass_along_path ( & nodes, None ) ;
181
181
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 ( ) ;
185
185
nodes. remove ( 2 ) ;
186
186
pass_along_path ( & nodes, None ) ;
187
187
}
188
188
189
189
#[ 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.
192
192
let nodes = create_nodes ( 3 ) ;
193
193
let test_msg = TestCustomMessage { } ;
194
194
195
195
// 0 hops
196
196
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 ( ) ;
200
200
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
201
201
202
202
// 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 ( ) ;
207
207
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
208
208
}
209
209
@@ -214,19 +214,19 @@ fn reply_path() {
214
214
let secp_ctx = Secp256k1 :: new ( ) ;
215
215
216
216
// 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 ( ) ;
218
218
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 ( ) ;
219
219
pass_along_path ( & nodes, None ) ;
220
220
// Make sure the last node successfully decoded the reply path.
221
221
nodes[ 3 ] . logger . assert_log_contains (
222
222
"lightning::onion_message::messenger" . to_string ( ) ,
223
223
format ! ( "Received an onion message with path_id None and a reply_path" ) . to_string ( ) , 1 ) ;
224
224
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 ( ) ;
228
228
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 ( ) ;
230
230
pass_along_path ( & nodes, None ) ;
231
231
nodes[ 3 ] . logger . assert_log_contains (
232
232
"lightning::onion_message::messenger" . to_string ( ) ,
0 commit comments