@@ -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 ) ;
@@ -580,13 +580,22 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
580
580
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
581
581
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
582
582
583
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
583
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
584
584
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
585
585
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
586
586
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
587
587
for path in invoice. payment_paths ( ) {
588
588
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
589
589
}
590
+ // Both Bob and Charlie have an equal number of channels and need to be connected
591
+ // to Alice when she's handling the message. Therefore, either Bob or Charlie could
592
+ // serve as the introduction node for the reply path back to Alice.
593
+ assert ! (
594
+ matches!(
595
+ reply_path. introduction_node( ) ,
596
+ & IntroductionNode :: NodeId ( node_id) if node_id == bob_id || node_id == charlie_id,
597
+ )
598
+ ) ;
590
599
591
600
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
592
601
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -659,7 +668,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
659
668
let onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ;
660
669
david. onion_messenger . handle_onion_message ( & charlie_id, & onion_message) ;
661
670
662
- let ( invoice, _ ) = extract_invoice ( david, & onion_message) ;
671
+ let ( invoice, reply_path ) = extract_invoice ( david, & onion_message) ;
663
672
assert_eq ! ( invoice, expected_invoice) ;
664
673
665
674
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -668,6 +677,8 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
668
677
for path in invoice. payment_paths ( ) {
669
678
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
670
679
}
680
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
681
+
671
682
672
683
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
673
684
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -726,13 +737,14 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
726
737
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
727
738
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
728
739
729
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
740
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
730
741
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
731
742
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
732
743
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
733
744
for path in invoice. payment_paths ( ) {
734
745
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
735
746
}
747
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
736
748
737
749
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
738
750
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -779,7 +791,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
779
791
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
780
792
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
781
793
782
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
794
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
783
795
assert_eq ! ( invoice, expected_invoice) ;
784
796
785
797
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
@@ -788,6 +800,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
788
800
for path in invoice. payment_paths ( ) {
789
801
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
790
802
}
803
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
791
804
792
805
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
793
806
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1044,7 +1057,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1044
1057
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1045
1058
1046
1059
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1047
- assert_eq ! ( reply_path. unwrap ( ) . introduction_node( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1060
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1048
1061
1049
1062
// Send, extract and verify the second Invoice Request message
1050
1063
let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -1053,7 +1066,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1053
1066
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1054
1067
1055
1068
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( ) ) ) ;
1069
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1057
1070
}
1058
1071
1059
1072
/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived.
@@ -1190,12 +1203,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
1190
1203
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1191
1204
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
1192
1205
1193
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1206
+ let ( invoice, reply_path ) = extract_invoice ( bob, & onion_message) ;
1194
1207
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1195
1208
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
1196
1209
for path in invoice. payment_paths ( ) {
1197
1210
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1198
1211
}
1212
+ assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1199
1213
1200
1214
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1201
1215
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -1239,7 +1253,7 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
1239
1253
1240
1254
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1241
1255
1242
- let ( invoice, _ ) = extract_invoice ( bob, & onion_message) ;
1256
+ let ( invoice, _reply_path ) = extract_invoice ( bob, & onion_message) ;
1243
1257
assert_eq ! ( invoice, expected_invoice) ;
1244
1258
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
1245
1259
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
0 commit comments