@@ -713,7 +713,7 @@ mod test {
713713 use crate :: sign:: PhantomKeysManager ;
714714 use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
715715 use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
716- use crate :: ln:: channelmanager:: { PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
716+ use crate :: ln:: channelmanager:: { Bolt11InvoiceParameters , PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
717717 use crate :: ln:: functional_test_utils:: * ;
718718 use crate :: ln:: msgs:: ChannelMessageHandler ;
719719 use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
@@ -756,11 +756,17 @@ mod test {
756756 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
757757 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
758758 create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 ) ;
759+
760+ let description = Bolt11InvoiceDescription :: Direct (
761+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
762+ ) ;
759763 let non_default_invoice_expiry_secs = 4200 ;
760- let invoice = create_invoice_from_channelmanager (
761- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "test" . to_string ( ) ,
762- non_default_invoice_expiry_secs, None ,
763- ) . unwrap ( ) ;
764+ let invoice_params = Bolt11InvoiceParameters {
765+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
766+ invoice_expiry_delta_secs : Some ( non_default_invoice_expiry_secs) ,
767+ min_final_cltv_expiry_delta : None , payment_hash : None ,
768+ } ;
769+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
764770 assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
765771 // If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
766772 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
@@ -808,10 +814,14 @@ mod test {
808814 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
809815 let custom_min_final_cltv_expiry_delta = Some ( 50 ) ;
810816
811- let invoice = create_invoice_from_channelmanager (
812- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "" . into ( ) , 3600 ,
813- if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ,
814- ) . unwrap ( ) ;
817+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
818+ let min_final_cltv_expiry_delta =
819+ if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ;
820+ let invoice_params = Bolt11InvoiceParameters {
821+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
822+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta, payment_hash : None ,
823+ } ;
824+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
815825 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , if with_custom_delta {
816826 custom_min_final_cltv_expiry_delta. unwrap( ) + 3 /* Buffer */ } else { MIN_FINAL_CLTV_EXPIRY_DELTA } as u64 ) ;
817827 }
@@ -828,12 +838,16 @@ mod test {
828838 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
829839 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
830840 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
831- let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
832841
833- let invoice = create_invoice_from_channelmanager (
834- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "" . into ( ) , 3600 ,
835- custom_min_final_cltv_expiry_delta,
836- ) . unwrap ( ) ;
842+ let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
843+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
844+ let invoice_params = Bolt11InvoiceParameters {
845+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
846+ invoice_expiry_delta_secs : Some ( 3600 ) ,
847+ min_final_cltv_expiry_delta : custom_min_final_cltv_expiry_delta,
848+ payment_hash : None ,
849+ } ;
850+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
837851 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
838852 }
839853
@@ -843,10 +857,16 @@ mod test {
843857 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
844858 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
845859 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
846- let description_hash = Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) ) ;
847- let invoice = create_invoice_from_channelmanager_with_description_hash (
848- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , description_hash, 3600 , None ,
849- ) . unwrap ( ) ;
860+
861+ let description = Bolt11InvoiceDescription :: Hash (
862+ Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) )
863+ ) ;
864+ let invoice_params = Bolt11InvoiceParameters {
865+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
866+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
867+ payment_hash : None ,
868+ } ;
869+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
850870 assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
851871 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
852872 assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Hash ( & Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
@@ -858,11 +878,17 @@ mod test {
858878 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
859879 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
860880 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
881+
861882 let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
862- let invoice = create_invoice_from_channelmanager_with_payment_hash (
863- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "test" . to_string ( ) , 3600 ,
864- payment_hash, None ,
865- ) . unwrap ( ) ;
883+ let description = Bolt11InvoiceDescription :: Direct (
884+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
885+ ) ;
886+ let invoice_params = Bolt11InvoiceParameters {
887+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
888+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
889+ payment_hash : Some ( payment_hash) ,
890+ } ;
891+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
866892 assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
867893 assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
868894 assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Direct ( & Description :: new( "test" . to_string( ) ) . unwrap( ) ) ) ;
@@ -1150,10 +1176,15 @@ mod test {
11501176 invoice_node : & Node < ' a , ' b , ' c > ,
11511177 mut chan_ids_to_match : HashSet < u64 >
11521178 ) {
1153- let invoice = create_invoice_from_channelmanager (
1154- invoice_node. node , Currency :: BitcoinTestnet , invoice_amt, "test" . to_string ( ) , 3600 ,
1155- None ,
1156- ) . unwrap ( ) ;
1179+ let description = Bolt11InvoiceDescription :: Direct (
1180+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
1181+ ) ;
1182+ let invoice_params = Bolt11InvoiceParameters {
1183+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : invoice_amt, description,
1184+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
1185+ payment_hash : None ,
1186+ } ;
1187+ let invoice = invoice_node. node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
11571188 let hints = invoice. private_routes ( ) ;
11581189
11591190 for hint in hints {
@@ -1788,11 +1819,16 @@ mod test {
17881819 let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
17891820 let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
17901821 let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1791- let result = create_invoice_from_channelmanager (
1792- nodes [ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "Some description" . into ( ) , 3600 ,
1793- Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) ,
1822+
1823+ let description = Bolt11InvoiceDescription :: Direct (
1824+ Description :: new ( "Some description" . to_string ( ) ) . unwrap ( )
17941825 ) ;
1795- match result {
1826+ let invoice_params = Bolt11InvoiceParameters {
1827+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
1828+ invoice_expiry_delta_secs : Some ( 3600 ) ,
1829+ min_final_cltv_expiry_delta : Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) , payment_hash : None ,
1830+ } ;
1831+ match nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) {
17961832 Err ( SignOrCreationError :: CreationError ( CreationError :: MinFinalCltvExpiryDeltaTooShort ) ) => { } ,
17971833 _ => panic ! ( ) ,
17981834 }
0 commit comments