@@ -157,7 +157,7 @@ where
157
157
. duration_since ( UNIX_EPOCH )
158
158
. expect ( "Time must be > 1970" )
159
159
. as_secs ( ) ,
160
- None ,
160
+ min_final_cltv_expiry_delta ,
161
161
)
162
162
. map_err ( |_| SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?;
163
163
( payment_hash, payment_secret)
@@ -171,7 +171,7 @@ where
171
171
. duration_since ( UNIX_EPOCH )
172
172
. expect ( "Time must be > 1970" )
173
173
. as_secs ( ) ,
174
- None ,
174
+ min_final_cltv_expiry_delta ,
175
175
)
176
176
. map_err ( |_| SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?
177
177
} ;
@@ -722,6 +722,22 @@ mod test {
722
722
assert_eq ! ( events. len( ) , 2 ) ;
723
723
}
724
724
725
+ #[ test]
726
+ fn test_create_invoice_with_custom_min_final_cltv_delta ( ) {
727
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
728
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
729
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
730
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
731
+ let description_hash = crate :: Sha256 ( Hash :: hash ( "Testing description_hash" . as_bytes ( ) ) ) ;
732
+ let invoice = crate :: utils:: create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch (
733
+ & nodes[ 1 ] . node , nodes[ 1 ] . keys_manager , nodes[ 1 ] . logger , Currency :: BitcoinTestnet ,
734
+ Some ( 10_000 ) , description_hash, Duration :: from_secs ( 1234567 ) , 3600 , None ,
735
+ ) . unwrap ( ) ;
736
+ assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 100_000 ) ) ;
737
+ assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , MIN_FINAL_CLTV_EXPIRY_DELTA as u64 ) ;
738
+ assert_eq ! ( invoice. description( ) , InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Testing description_hash" . as_bytes( ) ) ) ) ) ;
739
+ }
740
+
725
741
#[ test]
726
742
fn test_create_invoice_with_description_hash ( ) {
727
743
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -1141,6 +1157,35 @@ mod test {
1141
1157
assert_eq ! ( invoice. description( ) , InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Description hash phantom invoice" . as_bytes( ) ) ) ) ) ;
1142
1158
}
1143
1159
1160
+ #[ test]
1161
+ #[ cfg( feature = "std" ) ]
1162
+ fn create_phantom_invoice_with_custom_payment_hash_and_custom_min_final_cltv_delta ( ) {
1163
+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
1164
+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
1165
+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
1166
+ let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
1167
+
1168
+ let payment_amt = 20_000 ;
1169
+ let route_hints = vec ! [
1170
+ nodes[ 1 ] . node. get_phantom_route_hints( ) ,
1171
+ nodes[ 2 ] . node. get_phantom_route_hints( ) ,
1172
+ ] ;
1173
+ let user_payment_preimage = PaymentPreimage ( [ 1 ; 32 ] ) ;
1174
+ let payment_hash = Some ( PaymentHash ( Sha256 :: hash ( & user_payment_preimage. 0 [ ..] ) . into_inner ( ) ) ) ;
1175
+ let non_default_invoice_expiry_secs = 4200 ;
1176
+ let min_final_cltv_expiry_delta = Some ( 100 ) ;
1177
+ let invoice = crate :: utils:: create_phantom_invoice :: <
1178
+ & test_utils:: TestKeysInterface , & test_utils:: TestLogger ,
1179
+ > (
1180
+ Some ( payment_amt) , payment_hash, "" . into ( ) , non_default_invoice_expiry_secs, route_hints,
1181
+ & nodes[ 1 ] . keys_manager , & nodes[ 1 ] . logger , Currency :: BitcoinTestnet , min_final_cltv_expiry_delta,
1182
+ )
1183
+ . unwrap ( ) ;
1184
+ assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 200_000 ) ) ;
1185
+ assert_eq ! ( invoice. min_final_cltv_expiry_delta( ) , min_final_cltv_expiry_delta. unwrap( ) as u64 ) ;
1186
+ assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
1187
+ }
1188
+
1144
1189
#[ test]
1145
1190
#[ cfg( feature = "std" ) ]
1146
1191
fn test_multi_node_hints_includes_single_channels_to_participating_nodes ( ) {
0 commit comments