@@ -22,6 +22,7 @@ use crate::ln::functional_test_utils::*;
2222use crate :: ln:: msgs:: { ChannelMessageHandler , Init , OnionMessage , OnionMessageHandler } ;
2323use crate :: offers:: invoice:: Bolt12Invoice ;
2424use crate :: offers:: invoice_request:: InvoiceRequest ;
25+ use crate :: offers:: parse:: Bolt12SemanticError ;
2526use crate :: onion_message:: { OffersMessage , ParsedOnionMessageContents , PeeledOnion } ;
2627
2728use crate :: prelude:: * ;
@@ -495,3 +496,77 @@ fn pays_for_refund_without_blinded_paths() {
495496 claim_bolt12_payment ( bob, & [ alice] ) ;
496497 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
497498}
499+
500+ /// Fails creating an offer when a blinded path cannot be created without exposing the node's id.
501+ #[ test]
502+ fn fails_creating_offer_without_blinded_paths ( ) {
503+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
504+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
505+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
506+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
507+
508+ create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
509+
510+ match nodes[ 0 ] . node . create_offer_builder ( "coffee" . to_string ( ) ) {
511+ Ok ( _) => panic ! ( "Expected error" ) ,
512+ Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
513+ }
514+ }
515+
516+ /// Fails creating a refund when a blinded path cannot be created without exposing the node's id.
517+ #[ test]
518+ fn fails_creating_refund_without_blinded_paths ( ) {
519+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
520+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
521+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
522+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
523+
524+ create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
525+
526+ let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
527+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
528+
529+ match nodes[ 0 ] . node . create_refund_builder (
530+ "refund" . to_string ( ) , 10_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None
531+ ) {
532+ Ok ( _) => panic ! ( "Expected error" ) ,
533+ Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
534+ }
535+
536+ assert ! ( nodes[ 0 ] . node. list_recent_payments( ) . is_empty( ) ) ;
537+ }
538+
539+ /// Fails creating an invoice request when a blinded reply path cannot be created without exposing
540+ /// the node's id.
541+ #[ test]
542+ fn fails_creating_invoice_request_without_blinded_reply_path ( ) {
543+ let chanmon_cfgs = create_chanmon_cfgs ( 6 ) ;
544+ let node_cfgs = create_node_cfgs ( 6 , & chanmon_cfgs) ;
545+ let node_chanmgrs = create_node_chanmgrs ( 6 , & node_cfgs, & [ None , None , None , None , None , None ] ) ;
546+ let nodes = create_network ( 6 , & node_cfgs, & node_chanmgrs) ;
547+
548+ create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
549+ create_unannounced_chan_between_nodes_with_value ( & nodes, 2 , 3 , 10_000_000 , 1_000_000_000 ) ;
550+ create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 10_000_000 , 1_000_000_000 ) ;
551+ create_announced_chan_between_nodes_with_value ( & nodes, 1 , 4 , 10_000_000 , 1_000_000_000 ) ;
552+ create_announced_chan_between_nodes_with_value ( & nodes, 1 , 5 , 10_000_000 , 1_000_000_000 ) ;
553+
554+ let ( alice, bob, charlie, david) = ( & nodes[ 0 ] , & nodes[ 1 ] , & nodes[ 2 ] , & nodes[ 3 ] ) ;
555+
556+ disconnect_peers ( alice, & [ charlie, david, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
557+ disconnect_peers ( david, & [ bob, & nodes[ 4 ] , & nodes[ 5 ] ] ) ;
558+
559+ let offer = alice. node
560+ . create_offer_builder ( "coffee" . to_string ( ) ) . unwrap ( )
561+ . amount_msats ( 10_000_000 )
562+ . build ( ) . unwrap ( ) ;
563+
564+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
565+
566+ match david. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) {
567+ Ok ( _) => panic ! ( "Expected error" ) ,
568+ Err ( e) => assert_eq ! ( e, Bolt12SemanticError :: MissingPaths ) ,
569+ }
570+
571+ assert ! ( nodes[ 0 ] . node. list_recent_payments( ) . is_empty( ) ) ;
572+ }
0 commit comments