@@ -588,12 +588,13 @@ mod test {
588588 use super :: * ;
589589 use crate :: chain:: channelmonitor:: HTLC_FAIL_BACK_BUFFER ;
590590 use crate :: ln:: channelmanager:: {
591- Bolt11InvoiceParameters , PaymentId , PhantomRouteHints , RecipientOnionFields , Retry ,
592- MIN_FINAL_CLTV_EXPIRY_DELTA ,
591+ Bolt11InvoiceParameters , OptionalBolt11PaymentParams , PaymentId , PhantomRouteHints ,
592+ RecipientOnionFields , Retry , MIN_FINAL_CLTV_EXPIRY_DELTA ,
593593 } ;
594594 use crate :: ln:: functional_test_utils:: * ;
595595 use crate :: ln:: msgs:: { BaseMessageHandler , ChannelMessageHandler , MessageSendEvent } ;
596- use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
596+ use crate :: ln:: outbound_payment:: RecipientCustomTlvs ;
597+ use crate :: routing:: router:: { PaymentParameters , RouteParameters , RouteParametersConfig } ;
597598 use crate :: sign:: PhantomKeysManager ;
598599 use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
599600 use crate :: util:: config:: UserConfig ;
@@ -636,26 +637,26 @@ mod test {
636637 }
637638
638639 #[ test]
639- fn create_and_pay_for_bolt11_invoice ( ) {
640+ fn create_and_pay_for_bolt11_invoice_with_custom_tlvs ( ) {
640641 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
641642 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
642643 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
643644 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
644645 create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 ) ;
645646
646- let node_a_id = nodes[ 0 ] . node . get_our_node_id ( ) ;
647-
647+ let amt_msat = 10_000 ;
648648 let description =
649649 Bolt11InvoiceDescription :: Direct ( Description :: new ( "test" . to_string ( ) ) . unwrap ( ) ) ;
650650 let non_default_invoice_expiry_secs = 4200 ;
651+
651652 let invoice_params = Bolt11InvoiceParameters {
652- amount_msats : Some ( 10_000 ) ,
653+ amount_msats : Some ( amt_msat ) ,
653654 description,
654655 invoice_expiry_delta_secs : Some ( non_default_invoice_expiry_secs) ,
655656 ..Default :: default ( )
656657 } ;
657658 let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
658- assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
659+ assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( amt_msat ) ) ;
659660 // If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
660661 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
661662 assert_eq ! (
@@ -667,6 +668,10 @@ mod test {
667668 Duration :: from_secs( non_default_invoice_expiry_secs. into( ) )
668669 ) ;
669670
671+ let ( payment_hash, payment_secret) = ( invoice. payment_hash ( ) , * invoice. payment_secret ( ) ) ;
672+
673+ let preimage = nodes[ 1 ] . node . get_payment_preimage ( payment_hash, payment_secret) . unwrap ( ) ;
674+
670675 // Invoice SCIDs should always use inbound SCID aliases over the real channel ID, if one is
671676 // available.
672677 let chan = & nodes[ 1 ] . node . list_usable_channels ( ) [ 0 ] ;
@@ -680,21 +685,34 @@ mod test {
680685 assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_minimum_msat, chan. inbound_htlc_minimum_msat) ;
681686 assert_eq ! ( invoice. route_hints( ) [ 0 ] . 0 [ 0 ] . htlc_maximum_msat, chan. inbound_htlc_maximum_msat) ;
682687
683- let retry = Retry :: Attempts ( 0 ) ;
688+ let custom_tlvs = RecipientCustomTlvs :: new ( vec ! [ ( 65537 , vec![ 42 ; 42 ] ) ] ) . unwrap ( ) ;
689+ let optional_params = OptionalBolt11PaymentParams {
690+ custom_tlvs : custom_tlvs. clone ( ) ,
691+ route_params_config : RouteParametersConfig :: default ( ) ,
692+ retry_strategy : Retry :: Attempts ( 0 ) ,
693+ } ;
694+
684695 nodes[ 0 ]
685696 . node
686- . pay_for_bolt11_invoice ( & invoice, PaymentId ( [ 42 ; 32 ] ) , None , Default :: default ( ) , retry )
697+ . pay_for_bolt11_invoice ( & invoice, PaymentId ( [ 42 ; 32 ] ) , None , optional_params )
687698 . unwrap ( ) ;
688699 check_added_monitors ( & nodes[ 0 ] , 1 ) ;
689700
690701 let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
691702 assert_eq ! ( events. len( ) , 1 ) ;
692- let payment_event = SendEvent :: from_event ( events. remove ( 0 ) ) ;
693- nodes[ 1 ] . node . handle_update_add_htlc ( node_a_id, & payment_event. msgs [ 0 ] ) ;
694- nodes[ 1 ] . node . handle_commitment_signed_batch_test ( node_a_id, & payment_event. commitment_msg ) ;
695- check_added_monitors ( & nodes[ 1 ] , 1 ) ;
696- let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
697- assert_eq ! ( events. len( ) , 2 ) ;
703+ let ev = remove_first_msg_event_to_node ( & nodes[ 1 ] . node . get_our_node_id ( ) , & mut events) ;
704+
705+ let path = & [ & nodes[ 1 ] ] ;
706+ let args = PassAlongPathArgs :: new ( & nodes[ 0 ] , path, amt_msat, payment_hash, ev)
707+ . with_payment_preimage ( preimage)
708+ . with_payment_secret ( payment_secret)
709+ . with_custom_tlvs ( custom_tlvs. clone ( ) . into_inner ( ) ) ;
710+
711+ do_pass_along_path ( args) ;
712+ claim_payment_along_route (
713+ ClaimAlongRouteArgs :: new ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] ] ] , preimage)
714+ . with_custom_tlvs ( custom_tlvs. into_inner ( ) ) ,
715+ ) ;
698716 }
699717
700718 fn do_create_invoice_min_final_cltv_delta ( with_custom_delta : bool ) {
0 commit comments