@@ -162,7 +162,8 @@ fn _create_phantom_invoice<Signer: Sign, K: Deref>(
162
162
. current_timestamp ( )
163
163
. payment_hash ( Hash :: from_slice ( & payment_hash. 0 ) . unwrap ( ) )
164
164
. payment_secret ( payment_secret)
165
- . min_final_cltv_expiry ( MIN_FINAL_CLTV_EXPIRY . into ( ) ) ;
165
+ . min_final_cltv_expiry ( MIN_FINAL_CLTV_EXPIRY . into ( ) )
166
+ . expiry_time ( Duration :: from_secs ( invoice_expiry_delta_secs. into ( ) ) ) ;
166
167
if let Some ( amt) = amt_msat {
167
168
invoice = invoice. amount_milli_satoshis ( amt) ;
168
169
}
@@ -799,8 +800,14 @@ mod test {
799
800
} else {
800
801
None
801
802
} ;
803
+ let non_default_invoice_expiry_secs = 4200 ;
802
804
803
- let invoice = :: utils:: create_phantom_invoice :: < EnforcingSigner , & test_utils:: TestKeysInterface > ( Some ( payment_amt) , payment_hash, "test" . to_string ( ) , 3600 , route_hints, & nodes[ 1 ] . keys_manager , Currency :: BitcoinTestnet ) . unwrap ( ) ;
805
+ let invoice = :: utils:: create_phantom_invoice :: <
806
+ EnforcingSigner , & test_utils:: TestKeysInterface
807
+ > (
808
+ Some ( payment_amt) , payment_hash, "test" . to_string ( ) , non_default_invoice_expiry_secs,
809
+ route_hints, & nodes[ 1 ] . keys_manager , Currency :: BitcoinTestnet
810
+ ) . unwrap ( ) ;
804
811
let ( payment_hash, payment_secret) = ( PaymentHash ( invoice. payment_hash ( ) . into_inner ( ) ) , * invoice. payment_secret ( ) ) ;
805
812
let payment_preimage = if user_generated_pmt_hash {
806
813
user_payment_preimage
@@ -811,6 +818,7 @@ mod test {
811
818
assert_eq ! ( invoice. min_final_cltv_expiry( ) , MIN_FINAL_CLTV_EXPIRY as u64 ) ;
812
819
assert_eq ! ( invoice. description( ) , InvoiceDescription :: Direct ( & Description ( "test" . to_string( ) ) ) ) ;
813
820
assert_eq ! ( invoice. route_hints( ) . len( ) , 2 ) ;
821
+ assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
814
822
assert ! ( !invoice. features( ) . unwrap( ) . supports_basic_mpp( ) ) ;
815
823
816
824
let payment_params = PaymentParameters :: from_node_id ( invoice. recover_payee_pub_key ( ) )
@@ -931,10 +939,17 @@ mod test {
931
939
] ;
932
940
933
941
let description_hash = crate :: Sha256 ( Hash :: hash ( "Description hash phantom invoice" . as_bytes ( ) ) ) ;
934
- let invoice = :: utils:: create_phantom_invoice_with_description_hash :: < EnforcingSigner , & test_utils:: TestKeysInterface > ( Some ( payment_amt) , None , 3600 , description_hash, route_hints, & nodes[ 1 ] . keys_manager , Currency :: BitcoinTestnet ) . unwrap ( ) ;
935
-
942
+ let non_default_invoice_expiry_secs = 4200 ;
943
+ let invoice = :: utils:: create_phantom_invoice_with_description_hash :: <
944
+ EnforcingSigner , & test_utils:: TestKeysInterface ,
945
+ > (
946
+ Some ( payment_amt) , None , non_default_invoice_expiry_secs, description_hash,
947
+ route_hints, & nodes[ 1 ] . keys_manager , Currency :: BitcoinTestnet
948
+ )
949
+ . unwrap ( ) ;
936
950
assert_eq ! ( invoice. amount_pico_btc( ) , Some ( 200_000 ) ) ;
937
951
assert_eq ! ( invoice. min_final_cltv_expiry( ) , MIN_FINAL_CLTV_EXPIRY as u64 ) ;
952
+ assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( non_default_invoice_expiry_secs. into( ) ) ) ;
938
953
assert_eq ! ( invoice. description( ) , InvoiceDescription :: Hash ( & crate :: Sha256 ( Sha256 :: hash( "Description hash phantom invoice" . as_bytes( ) ) ) ) ) ;
939
954
}
940
955
0 commit comments