@@ -219,12 +219,12 @@ fn extract_invoice_request<'a, 'b, 'c>(
219
219
}
220
220
}
221
221
222
- fn extract_invoice < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> ( Bolt12Invoice , Option < BlindedMessagePath > ) {
222
+ fn extract_invoice < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> ( Bolt12Invoice , BlindedMessagePath ) {
223
223
match node. onion_messenger . peel_onion_message ( message) {
224
224
Ok ( PeeledOnion :: Receive ( message, _, reply_path) ) => match message {
225
225
ParsedOnionMessageContents :: Offers ( offers_message) => match offers_message {
226
226
OffersMessage :: InvoiceRequest ( invoice_request) => panic ! ( "Unexpected invoice_request: {:?}" , invoice_request) ,
227
- OffersMessage :: Invoice ( invoice) => ( invoice, reply_path) ,
227
+ OffersMessage :: Invoice ( invoice) => ( invoice, reply_path. unwrap ( ) ) ,
228
228
#[ cfg( async_payments) ]
229
229
OffersMessage :: StaticInvoice ( invoice) => panic ! ( "Unexpected static invoice: {:?}" , invoice) ,
230
230
OffersMessage :: InvoiceError ( error) => panic ! ( "Unexpected invoice_error: {:?}" , error) ,
@@ -508,15 +508,15 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
508
508
features. set_onion_messages_optional ( ) ;
509
509
features. set_route_blinding_optional ( ) ;
510
510
511
- let chanmon_cfgs = create_chanmon_cfgs ( 6 ) ;
512
- let node_cfgs = create_node_cfgs ( 6 , & chanmon_cfgs) ;
511
+ let chanmon_cfgs = create_chanmon_cfgs ( 7 ) ;
512
+ let node_cfgs = create_node_cfgs ( 7 , & chanmon_cfgs) ;
513
513
514
514
* node_cfgs[ 1 ] . override_init_features . borrow_mut ( ) = Some ( features) ;
515
515
516
516
let node_chanmgrs = create_node_chanmgrs (
517
- 6 , & node_cfgs, & [ None , Some ( accept_forward_cfg) , None , None , None , None ]
517
+ 7 , & node_cfgs, & [ None , Some ( accept_forward_cfg) , None , None , None , None , None ]
518
518
) ;
519
- let nodes = create_network ( 6 , & node_cfgs, & node_chanmgrs) ;
519
+ let nodes = create_network ( 7 , & node_cfgs, & node_chanmgrs) ;
520
520
521
521
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
522
522
create_unannounced_chan_between_nodes_with_value ( & nodes, 2 , 3 , 10_000_000 , 1_000_000_000 ) ;
@@ -526,6 +526,12 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
526
526
create_announced_chan_between_nodes_with_value ( & nodes, 2 , 4 , 10_000_000 , 1_000_000_000 ) ;
527
527
create_announced_chan_between_nodes_with_value ( & nodes, 2 , 5 , 10_000_000 , 1_000_000_000 ) ;
528
528
529
+ // Create an announced channel between Bob and node[6] to ensure that in the event of a tie
530
+ // between Bob and Charlie for becoming the introduction node candidate, Bob is deterministically
531
+ // preferred over Charlie.
532
+ create_announced_chan_between_nodes_with_value ( & nodes, 1 , 6 , 10_000_000 , 1_000_000_000 ) ;
533
+
534
+
529
535
let ( alice, bob, charlie, david) = ( & nodes[ 0 ] , & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 3 ] ) ;
530
536
let alice_id = alice. node . get_our_node_id ( ) ;
531
537
let bob_id = bob. node . get_our_node_id ( ) ;
@@ -580,13 +586,14 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
580
586
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
581
587
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
582
588
583
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
589
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
584
590
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
585
591
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
586
592
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
587
593
for path in invoice. payment_paths ( ) {
588
594
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
589
595
}
596
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
590
597
591
598
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
592
599
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -659,7 +666,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
659
666
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
660
667
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
661
668
662
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
669
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
663
670
assert_eq ! ( invoice, expected_invoice) ;
664
671
665
672
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -668,6 +675,8 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
668
675
for path in invoice. payment_paths ( ) {
669
676
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
670
677
}
678
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
679
+
671
680
672
681
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
673
682
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -726,13 +735,14 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
726
735
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
727
736
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
728
737
729
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
738
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
730
739
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
731
740
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
732
741
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
733
742
for path in invoice. payment_paths ( ) {
734
743
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
735
744
}
745
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
736
746
737
747
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
738
748
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -779,7 +789,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
779
789
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
780
790
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
781
791
782
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
792
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
783
793
assert_eq ! ( invoice, expected_invoice) ;
784
794
785
795
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -788,6 +798,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
788
798
for path in invoice. payment_paths ( ) {
789
799
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
790
800
}
801
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
791
802
792
803
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
793
804
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1044,7 +1055,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1044
1055
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1045
1056
1046
1057
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
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 ( ) ;
@@ -1053,7 +1064,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1053
1064
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1054
1065
1055
1066
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1056
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node( ) , & IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1067
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1057
1068
}
1058
1069
1059
1070
/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived.
@@ -1190,12 +1201,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
1190
1201
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1191
1202
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
1192
1203
1193
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1204
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1194
1205
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1195
1206
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1196
1207
for path in invoice. payment_paths ( ) {
1197
1208
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1198
1209
}
1210
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1199
1211
1200
1212
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1201
1213
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1239,7 +1251,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
1239
1251
1240
1252
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1241
1253
1242
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1254
+ let ( invoice, _reply_path ) = extract_invoice ( bob, & onion_message) ;
1243
1255
assert_eq ! ( invoice, expected_invoice) ;
1244
1256
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1245
1257
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
0 commit comments