@@ -865,43 +865,75 @@ fn pays_for_refund_without_blinded_paths() {
865
865
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
866
866
}
867
867
868
- /// Fails creating an offer when a blinded path cannot be created without exposing the node's id.
868
+ /// Checks that an offer can be created using an unannounced node as a blinded path's introduction
869
+ /// node. This is only preferred if there are no other options which may indicated either the offer
870
+ /// is intended for the unannounced node or that the node is actually announced (e.g., an LSP) but
871
+ /// the recipient doesn't have a network graph.
869
872
#[ test]
870
- fn fails_creating_offer_without_blinded_paths ( ) {
873
+ fn creates_offer_with_blinded_path_using_unannounced_introduction_node ( ) {
871
874
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
872
875
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
873
876
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
874
877
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
875
878
876
879
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
877
880
878
- match nodes[ 0 ] . node . create_offer_builder ( None ) {
879
- Ok ( _) => panic ! ( "Expected error" ) ,
880
- Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
881
+ let alice = & nodes[ 0 ] ;
882
+ let alice_id = alice. node . get_our_node_id ( ) ;
883
+ let bob = & nodes[ 1 ] ;
884
+ let bob_id = bob. node . get_our_node_id ( ) ;
885
+
886
+ let offer = alice. node
887
+ . create_offer_builder ( None ) . unwrap ( )
888
+ . amount_msats ( 10_000_000 )
889
+ . build ( ) . unwrap ( ) ;
890
+ assert_ne ! ( offer. signing_pubkey( ) , Some ( alice_id) ) ;
891
+ assert ! ( !offer. paths( ) . is_empty( ) ) ;
892
+ for path in offer. paths ( ) {
893
+ assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
881
894
}
895
+
896
+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
897
+ bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
898
+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
899
+
900
+ let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
901
+ alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
902
+
903
+ let ( _, reply_path) = extract_invoice_request ( alice, & onion_message) ;
904
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
882
905
}
883
906
884
- /// Fails creating a refund when a blinded path cannot be created without exposing the node's id.
907
+ /// Checks that a refund can be created using an unannounced node as a blinded path's introduction
908
+ /// node. This is only preferred if there are no other options which may indicated either the refund
909
+ /// is intended for the unannounced node or that the node is actually announced (e.g., an LSP) but
910
+ /// the sender doesn't have a network graph.
885
911
#[ test]
886
- fn fails_creating_refund_without_blinded_paths ( ) {
912
+ fn creates_refund_with_blinded_path_using_unannounced_introduction_node ( ) {
887
913
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
888
914
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
889
915
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
890
916
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
891
917
892
918
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
893
919
920
+ let alice = & nodes[ 0 ] ;
921
+ let alice_id = alice. node . get_our_node_id ( ) ;
922
+ let bob = & nodes[ 1 ] ;
923
+ let bob_id = bob. node . get_our_node_id ( ) ;
924
+
894
925
let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
895
926
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
896
-
897
- match nodes[ 0 ] . node . create_refund_builder (
898
- 10_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None
899
- ) {
900
- Ok ( _) => panic ! ( "Expected error" ) ,
901
- Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
927
+ let refund = bob. node
928
+ . create_refund_builder ( 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None )
929
+ . unwrap ( )
930
+ . build ( ) . unwrap ( ) ;
931
+ assert_ne ! ( refund. payer_id( ) , bob_id) ;
932
+ assert ! ( !refund. paths( ) . is_empty( ) ) ;
933
+ for path in refund. paths ( ) {
934
+ assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
902
935
}
903
-
904
- assert ! ( nodes[ 0 ] . node. list_recent_payments( ) . is_empty( ) ) ;
936
+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
905
937
}
906
938
907
939
/// Fails creating or paying an offer when a blinded path cannot be created because no peers are
@@ -1080,8 +1112,7 @@ fn fails_sending_invoice_with_unsupported_chain_for_refund() {
1080
1112
}
1081
1113
}
1082
1114
1083
- /// Fails creating an invoice request when a blinded reply path cannot be created without exposing
1084
- /// the node's id.
1115
+ /// Fails creating an invoice request when a blinded reply path cannot be created.
1085
1116
#[ test]
1086
1117
fn fails_creating_invoice_request_without_blinded_reply_path ( ) {
1087
1118
let chanmon_cfgs = create_chanmon_cfgs ( 6 ) ;
@@ -1098,7 +1129,7 @@ fn fails_creating_invoice_request_without_blinded_reply_path() {
1098
1129
let ( alice, bob, charlie, david) = ( & nodes[ 0 ] , & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 3 ] ) ;
1099
1130
1100
1131
disconnect_peers ( alice, & [ charlie, david, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1101
- disconnect_peers ( david, & [ bob, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1132
+ disconnect_peers ( david, & [ bob, charlie , & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1102
1133
1103
1134
let offer = alice. node
1104
1135
. create_offer_builder ( None ) . unwrap ( )
0 commit comments