@@ -205,12 +205,12 @@ fn extract_invoice_request<'a, 'b, 'c>(
205
205
}
206
206
}
207
207
208
- fn extract_invoice < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> ( Bolt12Invoice , Option < BlindedPath > ) {
208
+ fn extract_invoice < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> ( Bolt12Invoice , BlindedPath ) {
209
209
match node. onion_messenger . peel_onion_message ( message) {
210
210
Ok ( PeeledOnion :: Receive ( message, _, reply_path) ) => match message {
211
211
ParsedOnionMessageContents :: Offers ( offers_message) => match offers_message {
212
212
OffersMessage :: InvoiceRequest ( invoice_request) => panic ! ( "Unexpected invoice_request: {:?}" , invoice_request) ,
213
- OffersMessage :: Invoice ( invoice) => ( invoice, reply_path) ,
213
+ OffersMessage :: Invoice ( invoice) => ( invoice, reply_path. unwrap ( ) ) ,
214
214
#[ cfg( async_payments) ]
215
215
OffersMessage :: StaticInvoice ( invoice) => panic ! ( "Unexpected static invoice: {:?}" , invoice) ,
216
216
OffersMessage :: InvoiceError ( error) => panic ! ( "Unexpected invoice_error: {:?}" , error) ,
@@ -494,15 +494,15 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
494
494
features. set_onion_messages_optional ( ) ;
495
495
features. set_route_blinding_optional ( ) ;
496
496
497
- let chanmon_cfgs = create_chanmon_cfgs ( 6 ) ;
498
- let node_cfgs = create_node_cfgs ( 6 , & chanmon_cfgs) ;
497
+ let chanmon_cfgs = create_chanmon_cfgs ( 7 ) ;
498
+ let node_cfgs = create_node_cfgs ( 7 , & chanmon_cfgs) ;
499
499
500
500
* node_cfgs[ 1 ] . override_init_features . borrow_mut ( ) = Some ( features) ;
501
501
502
502
let node_chanmgrs = create_node_chanmgrs (
503
- 6 , & node_cfgs, & [ None , Some ( accept_forward_cfg) , None , None , None , None ]
503
+ 7 , & node_cfgs, & [ None , Some ( accept_forward_cfg) , None , None , None , None , None ]
504
504
) ;
505
- let nodes = create_network ( 6 , & node_cfgs, & node_chanmgrs) ;
505
+ let nodes = create_network ( 7 , & node_cfgs, & node_chanmgrs) ;
506
506
507
507
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
508
508
create_unannounced_chan_between_nodes_with_value ( & nodes, 2 , 3 , 10_000_000 , 1_000_000_000 ) ;
@@ -512,6 +512,12 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
512
512
create_announced_chan_between_nodes_with_value ( & nodes, 2 , 4 , 10_000_000 , 1_000_000_000 ) ;
513
513
create_announced_chan_between_nodes_with_value ( & nodes, 2 , 5 , 10_000_000 , 1_000_000_000 ) ;
514
514
515
+ // Create an announced channel between Bob and node[6] to ensure that in the event of a tie
516
+ // between Bob and Charlie for becoming the introduction node candidate, Bob is deterministically
517
+ // preferred over Charlie.
518
+ create_announced_chan_between_nodes_with_value ( & nodes, 1 , 6 , 10_000_000 , 1_000_000_000 ) ;
519
+
520
+
515
521
let ( alice, bob, charlie, david) = ( & nodes[ 0 ] , & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 3 ] ) ;
516
522
let alice_id = alice. node . get_our_node_id ( ) ;
517
523
let bob_id = bob. node . get_our_node_id ( ) ;
@@ -566,13 +572,14 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
566
572
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
567
573
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
568
574
569
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
575
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
570
576
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
571
577
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
572
578
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
573
579
for ( _, path) in invoice. payment_paths ( ) {
574
580
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
575
581
}
582
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
576
583
577
584
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
578
585
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -645,7 +652,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
645
652
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
646
653
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
647
654
648
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
655
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
649
656
assert_eq ! ( invoice, expected_invoice) ;
650
657
651
658
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -654,6 +661,8 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
654
661
for ( _, path) in invoice. payment_paths ( ) {
655
662
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
656
663
}
664
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
665
+
657
666
658
667
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
659
668
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -712,13 +721,14 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
712
721
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
713
722
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
714
723
715
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
724
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
716
725
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
717
726
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
718
727
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
719
728
for ( _, path) in invoice. payment_paths ( ) {
720
729
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
721
730
}
731
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
722
732
723
733
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
724
734
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -765,7 +775,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
765
775
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
766
776
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
767
777
768
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
778
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
769
779
assert_eq ! ( invoice, expected_invoice) ;
770
780
771
781
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -774,6 +784,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
774
784
for ( _, path) in invoice. payment_paths ( ) {
775
785
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
776
786
}
787
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
777
788
778
789
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
779
790
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1044,7 +1055,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1044
1055
assert_ne ! ( invoice. signing_pubkey( ) , david_id) ;
1045
1056
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1046
1057
1047
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1058
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1048
1059
1049
1060
// Send, extract and verify the second Invoice Request message
1050
1061
let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -1059,7 +1070,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1059
1070
assert_ne ! ( invoice. signing_pubkey( ) , david_id) ;
1060
1071
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1061
1072
1062
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node, IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1073
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1063
1074
}
1064
1075
1065
1076
/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived.
@@ -1196,12 +1207,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
1196
1207
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1197
1208
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
1198
1209
1199
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1210
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1200
1211
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1201
1212
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1202
1213
for ( _, path) in invoice. payment_paths ( ) {
1203
1214
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1204
1215
}
1216
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1205
1217
1206
1218
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1207
1219
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1245,13 +1257,14 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
1245
1257
1246
1258
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1247
1259
1248
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1260
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1249
1261
assert_eq ! ( invoice, expected_invoice) ;
1250
1262
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1251
1263
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1252
1264
for ( _, path) in invoice. payment_paths ( ) {
1253
1265
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1254
1266
}
1267
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1255
1268
}
1256
1269
1257
1270
/// Fails creating or paying an offer when a blinded path cannot be created because no peers are
0 commit comments