@@ -715,7 +715,7 @@ mod test {
715
715
use crate :: sign:: PhantomKeysManager ;
716
716
use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
717
717
use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
718
- use crate :: ln:: channelmanager:: { PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
718
+ use crate :: ln:: channelmanager:: { Bolt11InvoiceParameters , PhantomRouteHints , MIN_FINAL_CLTV_EXPIRY_DELTA , PaymentId , RecipientOnionFields , Retry } ;
719
719
use crate :: ln:: functional_test_utils:: * ;
720
720
use crate :: ln:: msgs:: ChannelMessageHandler ;
721
721
use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
@@ -758,11 +758,17 @@ mod test {
758
758
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
759
759
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
760
760
create_unannounced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100000 , 10001 ) ;
761
+
762
+ let description = Bolt11InvoiceDescription :: Direct (
763
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
764
+ ) ;
761
765
let non_default_invoice_expiry_secs = 4200 ;
762
- let invoice = create_invoice_from_channelmanager (
763
- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "test" . to_string ( ) ,
764
- non_default_invoice_expiry_secs, None ,
765
- ) . unwrap ( ) ;
766
+ let invoice_params = Bolt11InvoiceParameters {
767
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
768
+ invoice_expiry_delta_secs : Some ( non_default_invoice_expiry_secs) ,
769
+ min_final_cltv_expiry_delta : None , payment_hash : None ,
770
+ } ;
771
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
766
772
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
767
773
// If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
768
774
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
@@ -810,10 +816,14 @@ mod test {
810
816
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
811
817
let custom_min_final_cltv_expiry_delta = Some ( 50 ) ;
812
818
813
- let invoice = create_invoice_from_channelmanager (
814
- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "" . into ( ) , 3600 ,
815
- if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ,
816
- ) . unwrap ( ) ;
819
+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
820
+ let min_final_cltv_expiry_delta =
821
+ if with_custom_delta { custom_min_final_cltv_expiry_delta } else { None } ;
822
+ let invoice_params = Bolt11InvoiceParameters {
823
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
824
+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta, payment_hash : None ,
825
+ } ;
826
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
817
827
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , if with_custom_delta {
818
828
custom_min_final_cltv_expiry_delta. unwrap( ) + 3 /* Buffer */ } else { MIN_FINAL_CLTV_EXPIRY_DELTA } as u64 ) ;
819
829
}
@@ -830,12 +840,16 @@ mod test {
830
840
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
831
841
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
832
842
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
833
- let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
834
843
835
- let invoice = create_invoice_from_channelmanager (
836
- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "" . into ( ) , 3600 ,
837
- custom_min_final_cltv_expiry_delta,
838
- ) . unwrap ( ) ;
844
+ let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
845
+ let description = Bolt11InvoiceDescription :: Direct ( Description :: empty ( ) ) ;
846
+ let invoice_params = Bolt11InvoiceParameters {
847
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
848
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
849
+ min_final_cltv_expiry_delta : custom_min_final_cltv_expiry_delta,
850
+ payment_hash : None ,
851
+ } ;
852
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
839
853
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
840
854
}
841
855
@@ -845,10 +859,16 @@ mod test {
845
859
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
846
860
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
847
861
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
848
- let description_hash = Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) ) ;
849
- let invoice = create_invoice_from_channelmanager_with_description_hash (
850
- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , description_hash, 3600 , None ,
851
- ) . unwrap ( ) ;
862
+
863
+ let description = Bolt11InvoiceDescription :: Hash (
864
+ Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) )
865
+ ) ;
866
+ let invoice_params = Bolt11InvoiceParameters {
867
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
868
+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
869
+ payment_hash : None ,
870
+ } ;
871
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
852
872
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
853
873
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
854
874
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Hash ( & Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
@@ -860,11 +880,17 @@ mod test {
860
880
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
861
881
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
862
882
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
883
+
863
884
let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
864
- let invoice = create_invoice_from_channelmanager_with_payment_hash (
865
- nodes[ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "test" . to_string ( ) , 3600 ,
866
- payment_hash, None ,
867
- ) . unwrap ( ) ;
885
+ let description = Bolt11InvoiceDescription :: Direct (
886
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
887
+ ) ;
888
+ let invoice_params = Bolt11InvoiceParameters {
889
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
890
+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
891
+ payment_hash : Some ( payment_hash) ,
892
+ } ;
893
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
868
894
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
869
895
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
870
896
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Direct ( & Description :: new( "test" . to_string( ) ) . unwrap( ) ) ) ;
@@ -1152,10 +1178,15 @@ mod test {
1152
1178
invoice_node : & Node < ' a , ' b , ' c > ,
1153
1179
mut chan_ids_to_match : HashSet < u64 >
1154
1180
) {
1155
- let invoice = create_invoice_from_channelmanager (
1156
- invoice_node. node , Currency :: BitcoinTestnet , invoice_amt, "test" . to_string ( ) , 3600 ,
1157
- None ,
1158
- ) . unwrap ( ) ;
1181
+ let description = Bolt11InvoiceDescription :: Direct (
1182
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
1183
+ ) ;
1184
+ let invoice_params = Bolt11InvoiceParameters {
1185
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : invoice_amt, description,
1186
+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
1187
+ payment_hash : None ,
1188
+ } ;
1189
+ let invoice = invoice_node. node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
1159
1190
let hints = invoice. private_routes ( ) ;
1160
1191
1161
1192
for hint in hints {
@@ -1790,11 +1821,16 @@ mod test {
1790
1821
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1791
1822
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1792
1823
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1793
- let result = create_invoice_from_channelmanager (
1794
- nodes [ 1 ] . node , Currency :: BitcoinTestnet , Some ( 10_000 ) , "Some description" . into ( ) , 3600 ,
1795
- Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) ,
1824
+
1825
+ let description = Bolt11InvoiceDescription :: Direct (
1826
+ Description :: new ( "Some description" . to_string ( ) ) . unwrap ( )
1796
1827
) ;
1797
- match result {
1828
+ let invoice_params = Bolt11InvoiceParameters {
1829
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
1830
+ invoice_expiry_delta_secs : Some ( 3600 ) ,
1831
+ min_final_cltv_expiry_delta : Some ( MIN_FINAL_CLTV_EXPIRY_DELTA - 4 ) , payment_hash : None ,
1832
+ } ;
1833
+ match nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) {
1798
1834
Err ( SignOrCreationError :: CreationError ( CreationError :: MinFinalCltvExpiryDeltaTooShort ) ) => { } ,
1799
1835
_ => panic ! ( ) ,
1800
1836
}
0 commit comments