@@ -149,6 +149,16 @@ fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &Blinded
149
149
. unwrap ( )
150
150
}
151
151
152
+ fn check_compact_path_introduction_node < ' a , ' b , ' c > (
153
+ path : & BlindedMessagePath ,
154
+ lookup_node : & Node < ' a , ' b , ' c > ,
155
+ expected_introduction_node : PublicKey ,
156
+ ) -> bool {
157
+ let introduction_node_id = resolve_introduction_node ( lookup_node, path) ;
158
+ introduction_node_id == expected_introduction_node
159
+ && matches ! ( path. introduction_node( ) , IntroductionNode :: DirectedShortChannelId ( ..) )
160
+ }
161
+
152
162
fn route_bolt12_payment < ' a , ' b , ' c > (
153
163
node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , invoice : & Bolt12Invoice
154
164
) {
@@ -406,7 +416,7 @@ fn creates_short_lived_offer() {
406
416
#[ test]
407
417
fn creates_long_lived_offer ( ) {
408
418
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
409
- let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
419
+ let node_cfgs = create_node_cfgs_with_node_id_message_router ( 2 , & chanmon_cfgs) ;
410
420
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
411
421
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
412
422
@@ -470,7 +480,7 @@ fn creates_short_lived_refund() {
470
480
#[ test]
471
481
fn creates_long_lived_refund ( ) {
472
482
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
473
- let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
483
+ let node_cfgs = create_node_cfgs_with_node_id_message_router ( 2 , & chanmon_cfgs) ;
474
484
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
475
485
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
476
486
@@ -539,7 +549,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
539
549
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
540
550
assert ! ( !offer. paths( ) . is_empty( ) ) ;
541
551
for path in offer. paths ( ) {
542
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
552
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
543
553
}
544
554
545
555
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
@@ -569,7 +579,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
569
579
} ) ;
570
580
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
571
581
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
572
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
582
+ assert ! ( check_compact_path_introduction_node ( & reply_path , bob , charlie_id) ) ;
573
583
574
584
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( charlie_id) . unwrap ( ) ;
575
585
charlie. onion_messenger . handle_onion_message ( alice_id, & onion_message) ;
@@ -588,10 +598,8 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
588
598
// to Alice when she's handling the message. Therefore, either Bob or Charlie could
589
599
// serve as the introduction node for the reply path back to Alice.
590
600
assert ! (
591
- matches!(
592
- reply_path. introduction_node( ) ,
593
- & IntroductionNode :: NodeId ( node_id) if node_id == bob_id || node_id == charlie_id,
594
- )
601
+ check_compact_path_introduction_node( & reply_path, david, bob_id) ||
602
+ check_compact_path_introduction_node( & reply_path, david, charlie_id)
595
603
) ;
596
604
597
605
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
@@ -650,7 +658,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
650
658
assert_ne ! ( refund. payer_signing_pubkey( ) , david_id) ;
651
659
assert ! ( !refund. paths( ) . is_empty( ) ) ;
652
660
for path in refund. paths ( ) {
653
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
661
+ assert ! ( check_compact_path_introduction_node ( & path , david , charlie_id) ) ;
654
662
}
655
663
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
656
664
@@ -674,8 +682,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
674
682
for path in invoice. payment_paths ( ) {
675
683
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
676
684
}
677
- assert_eq ! ( reply_path. introduction_node( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
678
-
685
+ assert ! ( check_compact_path_introduction_node( & reply_path, alice, bob_id) ) ;
679
686
680
687
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
681
688
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
@@ -708,7 +715,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
708
715
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
709
716
assert ! ( !offer. paths( ) . is_empty( ) ) ;
710
717
for path in offer. paths ( ) {
711
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
718
+ assert ! ( check_compact_path_introduction_node ( & path , bob , alice_id) ) ;
712
719
}
713
720
714
721
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
@@ -730,7 +737,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
730
737
} ) ;
731
738
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
732
739
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
733
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
740
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , bob_id) ) ;
734
741
735
742
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
736
743
bob. onion_messenger . handle_onion_message ( alice_id, & onion_message) ;
@@ -742,7 +749,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
742
749
for path in invoice. payment_paths ( ) {
743
750
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
744
751
}
745
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
752
+ assert ! ( check_compact_path_introduction_node ( & reply_path , bob , alice_id) ) ;
746
753
747
754
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
748
755
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -779,7 +786,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
779
786
assert_ne ! ( refund. payer_signing_pubkey( ) , bob_id) ;
780
787
assert ! ( !refund. paths( ) . is_empty( ) ) ;
781
788
for path in refund. paths ( ) {
782
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
789
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
783
790
}
784
791
expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
785
792
@@ -798,7 +805,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
798
805
for path in invoice. payment_paths ( ) {
799
806
assert_eq ! ( path. introduction_node( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
800
807
}
801
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
808
+ assert ! ( check_compact_path_introduction_node ( & reply_path , bob , alice_id) ) ;
802
809
803
810
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
804
811
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
@@ -956,7 +963,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
956
963
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
957
964
assert ! ( !offer. paths( ) . is_empty( ) ) ;
958
965
for path in offer. paths ( ) {
959
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
966
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
960
967
}
961
968
962
969
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
@@ -975,7 +982,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
975
982
alice. onion_messenger . handle_onion_message ( bob_id, & onion_message) ;
976
983
977
984
let ( _, reply_path) = extract_invoice_request ( alice, & onion_message) ;
978
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
985
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , charlie_id) ) ;
979
986
980
987
// Send, extract and verify the second Invoice Request message
981
988
let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -985,7 +992,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
985
992
alice. onion_messenger . handle_onion_message ( bob_id, & onion_message) ;
986
993
987
994
let ( _, reply_path) = extract_invoice_request ( alice, & onion_message) ;
988
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
995
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
989
996
}
990
997
991
998
/// This test checks that when multiple potential introduction nodes are available for the payee,
@@ -1040,7 +1047,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1040
1047
. build ( ) . unwrap ( ) ;
1041
1048
assert_ne ! ( refund. payer_signing_pubkey( ) , alice_id) ;
1042
1049
for path in refund. paths ( ) {
1043
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1050
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
1044
1051
}
1045
1052
expect_recent_payment ! ( alice, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1046
1053
@@ -1056,7 +1063,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1056
1063
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1057
1064
1058
1065
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1059
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1066
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , charlie_id) ) ;
1060
1067
1061
1068
// Send, extract and verify the second Invoice Request message
1062
1069
let onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -1065,7 +1072,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
1065
1072
let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
1066
1073
1067
1074
let ( _, reply_path) = extract_invoice ( alice, & onion_message) ;
1068
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1075
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , nodes[ 6 ] . node. get_our_node_id( ) ) ) ;
1069
1076
}
1070
1077
1071
1078
/// Verifies that the invoice request message can be retried if it fails to reach the
@@ -1091,7 +1098,7 @@ fn creates_and_pays_for_offer_with_retry() {
1091
1098
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
1092
1099
assert ! ( !offer. paths( ) . is_empty( ) ) ;
1093
1100
for path in offer. paths ( ) {
1094
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( alice_id) ) ;
1101
+ assert ! ( check_compact_path_introduction_node ( & path , bob , alice_id) ) ;
1095
1102
}
1096
1103
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
1097
1104
bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , RouteParametersConfig :: default ( ) ) . unwrap ( ) ;
@@ -1119,7 +1126,7 @@ fn creates_and_pays_for_offer_with_retry() {
1119
1126
} ) ;
1120
1127
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1121
1128
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
1122
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1129
+ assert ! ( check_compact_path_introduction_node ( & reply_path , alice , bob_id) ) ;
1123
1130
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
1124
1131
bob. onion_messenger . handle_onion_message ( alice_id, & onion_message) ;
1125
1132
@@ -1391,7 +1398,7 @@ fn fails_authentication_when_handling_invoice_request() {
1391
1398
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
1392
1399
assert ! ( !offer. paths( ) . is_empty( ) ) ;
1393
1400
for path in offer. paths ( ) {
1394
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1401
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
1395
1402
}
1396
1403
1397
1404
let invalid_path = alice. node
@@ -1400,7 +1407,7 @@ fn fails_authentication_when_handling_invoice_request() {
1400
1407
. build ( ) . unwrap ( )
1401
1408
. paths ( ) . first ( ) . unwrap ( )
1402
1409
. clone ( ) ;
1403
- assert_eq ! ( invalid_path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1410
+ assert ! ( check_compact_path_introduction_node ( & invalid_path , alice , bob_id) ) ;
1404
1411
1405
1412
// Send the invoice request directly to Alice instead of using a blinded path.
1406
1413
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
@@ -1421,7 +1428,7 @@ fn fails_authentication_when_handling_invoice_request() {
1421
1428
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1422
1429
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1423
1430
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
1424
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1431
+ assert ! ( check_compact_path_introduction_node ( & reply_path , david , charlie_id) ) ;
1425
1432
1426
1433
assert_eq ! ( alice. onion_messenger. next_onion_message_for_peer( charlie_id) , None ) ;
1427
1434
@@ -1451,7 +1458,7 @@ fn fails_authentication_when_handling_invoice_request() {
1451
1458
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1452
1459
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1453
1460
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
1454
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1461
+ assert ! ( check_compact_path_introduction_node ( & reply_path , david , charlie_id) ) ;
1455
1462
1456
1463
assert_eq ! ( alice. onion_messenger. next_onion_message_for_peer( charlie_id) , None ) ;
1457
1464
}
@@ -1502,7 +1509,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
1502
1509
assert_ne ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
1503
1510
assert ! ( !offer. paths( ) . is_empty( ) ) ;
1504
1511
for path in offer. paths ( ) {
1505
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( bob_id) ) ;
1512
+ assert ! ( check_compact_path_introduction_node ( & path , alice , bob_id) ) ;
1506
1513
}
1507
1514
1508
1515
// Initiate an invoice request, but abandon tracking it.
@@ -1553,7 +1560,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
1553
1560
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1554
1561
assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1555
1562
assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
1556
- assert_eq ! ( reply_path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1563
+ assert ! ( check_compact_path_introduction_node ( & reply_path , david , charlie_id) ) ;
1557
1564
1558
1565
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( charlie_id) . unwrap ( ) ;
1559
1566
charlie. onion_messenger . handle_onion_message ( alice_id, & onion_message) ;
@@ -1610,7 +1617,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1610
1617
assert_ne ! ( refund. payer_signing_pubkey( ) , david_id) ;
1611
1618
assert ! ( !refund. paths( ) . is_empty( ) ) ;
1612
1619
for path in refund. paths ( ) {
1613
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1620
+ assert ! ( check_compact_path_introduction_node ( & path , david , charlie_id) ) ;
1614
1621
}
1615
1622
expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
1616
1623
@@ -1644,7 +1651,7 @@ fn fails_authentication_when_handling_invoice_for_refund() {
1644
1651
assert_ne ! ( refund. payer_signing_pubkey( ) , david_id) ;
1645
1652
assert ! ( !refund. paths( ) . is_empty( ) ) ;
1646
1653
for path in refund. paths ( ) {
1647
- assert_eq ! ( path . introduction_node ( ) , & IntroductionNode :: NodeId ( charlie_id) ) ;
1654
+ assert ! ( check_compact_path_introduction_node ( & path , david , charlie_id) ) ;
1648
1655
}
1649
1656
1650
1657
let expected_invoice = alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
0 commit comments