@@ -1120,12 +1120,20 @@ fn fails_authentication_when_handling_invoice_request() {
1120
1120
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1121
1121
}
1122
1122
1123
+ let invalid_path = alice. node
1124
+ . create_offer_builder ( None )
1125
+ . unwrap ( )
1126
+ . build ( ) . unwrap ( )
1127
+ . paths ( ) . first ( ) . unwrap ( )
1128
+ . clone ( ) ;
1129
+ assert_eq ! ( invalid_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1130
+
1131
+ // Send the invoice request directly to Alice instead of using a blinded path.
1123
1132
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
1124
1133
david. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None )
1125
1134
. unwrap ( ) ;
1126
1135
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1127
1136
1128
- // Send the invoice request directly to Alice instead of using a blinded path.
1129
1137
connect_peers ( david, alice) ;
1130
1138
#[ cfg( not( c_bindings) ) ] {
1131
1139
david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
@@ -1145,6 +1153,39 @@ fn fails_authentication_when_handling_invoice_request() {
1145
1153
assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1146
1154
1147
1155
assert_eq ! ( alice. onion_messenger. next_onion_message_for_peer( charlie_id) , None ) ;
1156
+
1157
+ david. node . abandon_payment ( payment_id) ;
1158
+ get_event ! ( david, Event :: InvoiceRequestFailed ) ;
1159
+
1160
+ // Send the invoice request to Alice using an invalid blinded path.
1161
+ let payment_id = PaymentId ( [ 2 ; 32 ] ) ;
1162
+ david. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None )
1163
+ . unwrap ( ) ;
1164
+ expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1165
+
1166
+ #[ cfg( not( c_bindings) ) ] {
1167
+ david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1168
+ Destination :: BlindedPath ( invalid_path) ;
1169
+ }
1170
+ #[ cfg( c_bindings) ] {
1171
+ david. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1172
+ Destination :: BlindedPath ( invalid_path) ;
1173
+ }
1174
+
1175
+ connect_peers ( david, bob) ;
1176
+
1177
+ let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1178
+ bob. onion_messenger . handle_onion_message ( & david_id, & onion_message) ;
1179
+
1180
+ let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1181
+ alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
1182
+
1183
+ let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1184
+ assert_eq ! ( invoice_request. amount_msats( ) , None ) ;
1185
+ assert_ne ! ( invoice_request. payer_id( ) , david_id) ;
1186
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1187
+
1188
+ assert_eq ! ( alice. onion_messenger. next_onion_message_for_peer( charlie_id) , None ) ;
1148
1189
}
1149
1190
1150
1191
/// Check that authentication fails when an invoice is handled using the wrong context (i.e., was
@@ -1308,9 +1349,9 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1308
1349
}
1309
1350
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1310
1351
1352
+ // Send the invoice directly to David instead of using a blinded path.
1311
1353
let expected_invoice = alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
1312
1354
1313
- // Send the invoice directly to David instead of using a blinded path.
1314
1355
connect_peers ( david, alice) ;
1315
1356
#[ cfg( not( c_bindings) ) ] {
1316
1357
alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
@@ -1328,6 +1369,43 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1328
1369
assert_eq ! ( invoice, expected_invoice) ;
1329
1370
1330
1371
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1372
+
1373
+ // Send the invoice to David using an invalid blinded path.
1374
+ let invalid_path = refund. paths ( ) . first ( ) . unwrap ( ) . clone ( ) ;
1375
+ let payment_id = PaymentId ( [ 2 ; 32 ] ) ;
1376
+ let refund = david. node
1377
+ . create_refund_builder ( 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None )
1378
+ . unwrap ( )
1379
+ . build ( ) . unwrap ( ) ;
1380
+ assert_ne ! ( refund. payer_id( ) , david_id) ;
1381
+ assert ! ( !refund. paths( ) . is_empty( ) ) ;
1382
+ for path in refund. paths ( ) {
1383
+ assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1384
+ }
1385
+
1386
+ let expected_invoice = alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
1387
+
1388
+ #[ cfg( not( c_bindings) ) ] {
1389
+ alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . destination =
1390
+ Destination :: BlindedPath ( invalid_path) ;
1391
+ }
1392
+ #[ cfg( c_bindings) ] {
1393
+ alice. node . pending_offers_messages . lock ( ) . unwrap ( ) . first_mut ( ) . unwrap ( ) . 1 =
1394
+ Destination :: BlindedPath ( invalid_path) ;
1395
+ }
1396
+
1397
+ connect_peers ( alice, charlie) ;
1398
+
1399
+ let onion_message = alice. onion_messenger . next_onion_message_for_peer ( charlie_id) . unwrap ( ) ;
1400
+ charlie. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
1401
+
1402
+ let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
1403
+ david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
1404
+
1405
+ let invoice = extract_invoice ( david, & onion_message) ;
1406
+ assert_eq ! ( invoice, expected_invoice) ;
1407
+
1408
+ expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1331
1409
}
1332
1410
1333
1411
/// Fails creating or paying an offer when a blinded path cannot be created because no peers are
0 commit comments