@@ -950,43 +950,75 @@ fn pays_bolt12_invoice_asynchronously() {
950
950
) ;
951
951
}
952
952
953
- /// Fails creating an offer when a blinded path cannot be created without exposing the node's id.
953
+ /// Checks that an offer can be created using an unannounced node as a blinded path's introduction
954
+ /// node. This is only preferred if there are no other options which may indicated either the offer
955
+ /// is intended for the unannounced node or that the node is actually announced (e.g., an LSP) but
956
+ /// the recipient doesn't have a network graph.
954
957
#[ test]
955
- fn fails_creating_offer_without_blinded_paths ( ) {
958
+ fn creates_offer_with_blinded_path_using_unannounced_introduction_node ( ) {
956
959
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
957
960
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
958
961
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
959
962
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
960
963
961
964
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
962
965
963
- match nodes[ 0 ] . node . create_offer_builder ( None ) {
964
- Ok ( _) => panic ! ( "Expected error" ) ,
965
- Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
966
+ let alice = & nodes[ 0 ] ;
967
+ let alice_id = alice. node . get_our_node_id ( ) ;
968
+ let bob = & nodes[ 1 ] ;
969
+ let bob_id = bob. node . get_our_node_id ( ) ;
970
+
971
+ let offer = alice. node
972
+ . create_offer_builder ( None ) . unwrap ( )
973
+ . amount_msats ( 10_000_000 )
974
+ . build ( ) . unwrap ( ) ;
975
+ assert_ne ! ( offer. signing_pubkey( ) , Some ( alice_id) ) ;
976
+ assert ! ( !offer. paths( ) . is_empty( ) ) ;
977
+ for path in offer. paths ( ) {
978
+ assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
966
979
}
980
+
981
+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
982
+ bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
983
+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
984
+
985
+ let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
986
+ alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
987
+
988
+ let ( _, reply_path) = extract_invoice_request ( alice, & onion_message) ;
989
+ assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
967
990
}
968
991
969
- /// Fails creating a refund when a blinded path cannot be created without exposing the node's id.
992
+ /// Checks that a refund can be created using an unannounced node as a blinded path's introduction
993
+ /// node. This is only preferred if there are no other options which may indicated either the refund
994
+ /// is intended for the unannounced node or that the node is actually announced (e.g., an LSP) but
995
+ /// the sender doesn't have a network graph.
970
996
#[ test]
971
- fn fails_creating_refund_without_blinded_paths ( ) {
997
+ fn creates_refund_with_blinded_path_using_unannounced_introduction_node ( ) {
972
998
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
973
999
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
974
1000
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
975
1001
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
976
1002
977
1003
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
978
1004
1005
+ let alice = & nodes[ 0 ] ;
1006
+ let alice_id = alice. node . get_our_node_id ( ) ;
1007
+ let bob = & nodes[ 1 ] ;
1008
+ let bob_id = bob. node . get_our_node_id ( ) ;
1009
+
979
1010
let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
980
1011
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
981
-
982
- match nodes[ 0 ] . node . create_refund_builder (
983
- 10_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None
984
- ) {
985
- Ok ( _) => panic ! ( "Expected error" ) ,
986
- Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
1012
+ let refund = bob. node
1013
+ . create_refund_builder ( 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None )
1014
+ . unwrap ( )
1015
+ . build ( ) . unwrap ( ) ;
1016
+ assert_ne ! ( refund. payer_id( ) , bob_id) ;
1017
+ assert ! ( !refund. paths( ) . is_empty( ) ) ;
1018
+ for path in refund. paths ( ) {
1019
+ assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
987
1020
}
988
-
989
- assert ! ( nodes[ 0 ] . node. list_recent_payments( ) . is_empty( ) ) ;
1021
+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
990
1022
}
991
1023
992
1024
/// Fails creating or paying an offer when a blinded path cannot be created because no peers are
@@ -1165,8 +1197,7 @@ fn fails_sending_invoice_with_unsupported_chain_for_refund() {
1165
1197
}
1166
1198
}
1167
1199
1168
- /// Fails creating an invoice request when a blinded reply path cannot be created without exposing
1169
- /// the node's id.
1200
+ /// Fails creating an invoice request when a blinded reply path cannot be created.
1170
1201
#[ test]
1171
1202
fn fails_creating_invoice_request_without_blinded_reply_path ( ) {
1172
1203
let chanmon_cfgs = create_chanmon_cfgs ( 6 ) ;
@@ -1183,7 +1214,7 @@ fn fails_creating_invoice_request_without_blinded_reply_path() {
1183
1214
let ( alice, bob, charlie, david) = ( & nodes[ 0 ] , & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 3 ] ) ;
1184
1215
1185
1216
disconnect_peers ( alice, & [ charlie, david, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1186
- disconnect_peers ( david, & [ bob, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1217
+ disconnect_peers ( david, & [ bob, charlie , & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
1187
1218
1188
1219
let offer = alice. node
1189
1220
. create_offer_builder ( None ) . unwrap ( )
0 commit comments