@@ -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) ;
@@ -1030,7 +1041,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1030
1041
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1031
1042
1032
1043
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1033
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1044
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( charlie_id) ) ;
1034
1045
1035
1046
// Send, extract and verify the second Invoice Request message
1036
1047
let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -1039,7 +1050,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1039
1050
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1040
1051
1041
1052
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1042
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node, IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1053
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1043
1054
}
1044
1055
1045
1056
/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived.
@@ -1176,12 +1187,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
1176
1187
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1177
1188
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
1178
1189
1179
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1190
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1180
1191
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1181
1192
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1182
1193
for ( _, path) in invoice. payment_paths ( ) {
1183
1194
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1184
1195
}
1196
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1185
1197
1186
1198
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1187
1199
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1225,13 +1237,14 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
1225
1237
1226
1238
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1227
1239
1228
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1240
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1229
1241
assert_eq ! ( invoice, expected_invoice) ;
1230
1242
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1231
1243
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1232
1244
for ( _, path) in invoice. payment_paths ( ) {
1233
1245
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1234
1246
}
1247
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
1235
1248
}
1236
1249
1237
1250
/// Fails creating or paying an offer when a blinded path cannot be created because no peers are
0 commit comments