@@ -709,7 +709,7 @@ mod test {
709
709
use crate :: sign:: PhantomKeysManager ;
710
710
use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
711
711
use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
712
- use crate :: ln:: channelmanager:: { PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
712
+ use crate :: ln:: channelmanager:: { Bolt11InvoiceParameters , PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
713
713
use crate :: ln:: functional_test_utils:: * ;
714
714
use crate :: ln:: msgs:: ChannelMessageHandler ;
715
715
use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
@@ -752,10 +752,18 @@ mod test {
752
752
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
753
753
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
754
754
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 ) ;
755
+
756
+ let description = Bolt11InvoiceDescription :: Direct (
757
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
758
+ ) ;
755
759
let non_default_invoice_expiry_secs = 4200 ;
756
- let invoice = create_invoice_from_channelmanager (
757
- nodes[ 1 ] . node , Some ( 10_000 ) , "test" . to_string ( ) , non_default_invoice_expiry_secs, None ,
758
- ) . unwrap ( ) ;
760
+ let invoice_params = Bolt11InvoiceParameters {
761
+ amount_msats : Some ( 10_000 ) ,
762
+ description,
763
+ invoice_expiry_delta_secs : Some ( non_default_invoice_expiry_secs) ,
764
+ ..Default :: default ( )
765
+ } ;
766
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
759
767
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
760
768
// If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
761
769
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
@@ -803,10 +811,17 @@ mod test {
803
811
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
804
812
let custom_min_final_cltv_expiry_delta = Some ( 50 ) ;
805
813
806
- let invoice = create_invoice_from_channelmanager (
807
- nodes[ 1 ] . node , Some ( 10_000 ) , "" . into ( ) , 3600 ,
808
- if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ,
809
- ) . unwrap ( ) ;
814
+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
815
+ let min_final_cltv_expiry_delta =
816
+ if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ;
817
+ let invoice_params = Bolt11InvoiceParameters {
818
+ amount_msats : Some ( 10_000 ) ,
819
+ description,
820
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
821
+ min_final_cltv_expiry_delta,
822
+ ..Default :: default ( )
823
+ } ;
824
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
810
825
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , if with_custom_delta {
811
826
custom_min_final_cltv_expiry_delta. unwrap( ) + 3 /* Buffer */ } else { MIN_FINAL_CLTV_EXPIRY_DELTA } as u64 ) ;
812
827
}
@@ -823,11 +838,17 @@ mod test {
823
838
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
824
839
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
825
840
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
826
- let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
827
841
828
- let invoice = create_invoice_from_channelmanager (
829
- nodes[ 1 ] . node , Some ( 10_000 ) , "" . into ( ) , 3600 , custom_min_final_cltv_expiry_delta,
830
- ) . unwrap ( ) ;
842
+ let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
843
+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
844
+ let invoice_params = Bolt11InvoiceParameters {
845
+ amount_msats : Some ( 10_000 ) ,
846
+ description,
847
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
848
+ min_final_cltv_expiry_delta : custom_min_final_cltv_expiry_delta,
849
+ ..Default :: default ( )
850
+ } ;
851
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
831
852
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
832
853
}
833
854
@@ -837,10 +858,17 @@ mod test {
837
858
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
838
859
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
839
860
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
840
- let description_hash = Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) ) ;
841
- let invoice = create_invoice_from_channelmanager_with_description_hash (
842
- nodes[ 1 ] . node , Some ( 10_000 ) , description_hash, 3600 , None ,
843
- ) . unwrap ( ) ;
861
+
862
+ let description = Bolt11InvoiceDescription :: Hash (
863
+ Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) )
864
+ ) ;
865
+ let invoice_params = Bolt11InvoiceParameters {
866
+ amount_msats : Some ( 10_000 ) ,
867
+ description,
868
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
869
+ ..Default :: default ( )
870
+ } ;
871
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
844
872
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
845
873
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
846
874
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Hash ( & Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
@@ -852,10 +880,19 @@ mod test {
852
880
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
853
881
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
854
882
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
883
+
855
884
let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
856
- let invoice = create_invoice_from_channelmanager_with_payment_hash (
857
- nodes[ 1 ] . node , Some ( 10_000 ) , "test" . to_string ( ) , 3600 , payment_hash, None ,
858
- ) . unwrap ( ) ;
885
+ let description = Bolt11InvoiceDescription :: Direct (
886
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
887
+ ) ;
888
+ let invoice_params = Bolt11InvoiceParameters {
889
+ amount_msats : Some ( 10_000 ) ,
890
+ description,
891
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
892
+ payment_hash : Some ( payment_hash) ,
893
+ ..Default :: default ( )
894
+ } ;
895
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
859
896
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
860
897
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
861
898
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Direct ( & Description :: new( "test" . to_string( ) ) . unwrap( ) ) ) ;
@@ -1143,9 +1180,16 @@ mod test {
1143
1180
invoice_node : & Node < ' a , ' b , ' c > ,
1144
1181
mut chan_ids_to_match : HashSet < u64 >
1145
1182
) {
1146
- let invoice = create_invoice_from_channelmanager (
1147
- invoice_node. node , invoice_amt, "test" . to_string ( ) , 3600 , None ,
1148
- ) . unwrap ( ) ;
1183
+ let description = Bolt11InvoiceDescription :: Direct (
1184
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
1185
+ ) ;
1186
+ let invoice_params = Bolt11InvoiceParameters {
1187
+ amount_msats : invoice_amt,
1188
+ description,
1189
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
1190
+ ..Default :: default ( )
1191
+ } ;
1192
+ let invoice = invoice_node. node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
1149
1193
let hints = invoice. private_routes ( ) ;
1150
1194
1151
1195
for hint in hints {
@@ -1780,11 +1824,18 @@ mod test {
1780
1824
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1781
1825
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1782
1826
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1783
- let result = create_invoice_from_channelmanager (
1784
- nodes [ 1 ] . node , Some ( 10_000 ) , "Some description" . into ( ) , 3600 ,
1785
- Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) ,
1827
+
1828
+ let description = Bolt11InvoiceDescription :: Direct (
1829
+ Description :: new ( "Some description" . to_string ( ) ) . unwrap ( )
1786
1830
) ;
1787
- match result {
1831
+ let invoice_params = Bolt11InvoiceParameters {
1832
+ amount_msats : Some ( 10_000 ) ,
1833
+ description,
1834
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
1835
+ min_final_cltv_expiry_delta : Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) ,
1836
+ ..Default :: default ( )
1837
+ } ;
1838
+ match nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) {
1788
1839
Err ( SignOrCreationError :: CreationError ( CreationError :: MinFinalCltvExpiryDeltaTooShort ) ) => { } ,
1789
1840
_ => panic ! ( ) ,
1790
1841
}
0 commit comments