@@ -713,7 +713,7 @@ mod test {
713
713
use crate :: sign:: PhantomKeysManager ;
714
714
use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
715
715
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 } ;
717
717
use crate :: ln:: functional_test_utils:: * ;
718
718
use crate :: ln:: msgs:: ChannelMessageHandler ;
719
719
use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
@@ -756,11 +756,17 @@ mod test {
756
756
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
757
757
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
758
758
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
+ ) ;
759
763
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 ( ) ;
764
770
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
765
771
// If no `min_final_cltv_expiry_delta` is specified, then it should be `MIN_FINAL_CLTV_EXPIRY_DELTA`.
766
772
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
@@ -808,10 +814,14 @@ mod test {
808
814
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
809
815
let custom_min_final_cltv_expiry_delta = Some ( 50 ) ;
810
816
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 ( ) ;
815
825
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , if with_custom_delta {
816
826
custom_min_final_cltv_expiry_delta. unwrap( ) + 3 /* Buffer */ } else { MIN_FINAL_CLTV_EXPIRY_DELTA } as u64 ) ;
817
827
}
@@ -828,12 +838,16 @@ mod test {
828
838
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
829
839
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
830
840
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
831
- let custom_min_final_cltv_expiry_delta = Some ( 21 ) ;
832
841
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 ( ) ;
837
851
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
838
852
}
839
853
@@ -843,10 +857,16 @@ mod test {
843
857
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
844
858
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
845
859
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 ( ) ;
850
870
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
851
871
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
852
872
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Hash ( & Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
@@ -858,11 +878,17 @@ mod test {
858
878
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
859
879
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
860
880
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
881
+
861
882
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 ( ) ;
866
892
assert_eq ! ( invoice. amount_milli_satoshis( ) , Some ( 10_000 ) ) ;
867
893
assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
868
894
assert_eq ! ( invoice. description( ) , Bolt11InvoiceDescriptionRef :: Direct ( & Description :: new( "test" . to_string( ) ) . unwrap( ) ) ) ;
@@ -1150,10 +1176,15 @@ mod test {
1150
1176
invoice_node : & Node < ' a , ' b , ' c > ,
1151
1177
mut chan_ids_to_match : HashSet < u64 >
1152
1178
) {
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 ( ) ;
1157
1188
let hints = invoice. private_routes ( ) ;
1158
1189
1159
1190
for hint in hints {
@@ -1788,11 +1819,16 @@ mod test {
1788
1819
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1789
1820
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1790
1821
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 ( )
1794
1825
) ;
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) {
1796
1832
Err ( SignOrCreationError :: CreationError ( CreationError :: MinFinalCltvExpiryDeltaTooShort ) ) => { } ,
1797
1833
_ => panic ! ( ) ,
1798
1834
}
0 commit comments