@@ -59,6 +59,11 @@ const MAX_EXPIRY_TIME: u64 = 60 * 60 * 24 * 356;
59
59
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
60
60
const DEFAULT_EXPIRY_TIME : u64 = 3600 ;
61
61
62
+ /// Default minimum final CLTV expiry as defined by [BOLT 11].
63
+ ///
64
+ /// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
65
+ const DEFAULT_MIN_FINAL_CLTV_EXPIRY : u64 = 18 ;
66
+
62
67
/// This function is used as a static assert for the size of `SystemTime`. If the crate fails to
63
68
/// compile due to it this indicates that your system uses unexpected bounds for `SystemTime`. You
64
69
/// can remove this functions and run the test `test_system_time_bounds_assumptions`. In any case,
@@ -1033,9 +1038,12 @@ impl Invoice {
1033
1038
. unwrap_or ( Duration :: from_secs ( DEFAULT_EXPIRY_TIME ) )
1034
1039
}
1035
1040
1036
- /// Returns the invoice's `min_cltv_expiry` time if present
1037
- pub fn min_final_cltv_expiry ( & self ) -> Option < & u64 > {
1038
- self . signed_invoice . min_final_cltv_expiry ( ) . map ( |x| & x. 0 )
1041
+ /// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise
1042
+ /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
1043
+ pub fn min_final_cltv_expiry ( & self ) -> u64 {
1044
+ self . signed_invoice . min_final_cltv_expiry ( )
1045
+ . map ( |x| x. 0 )
1046
+ . unwrap_or ( DEFAULT_MIN_FINAL_CLTV_EXPIRY )
1039
1047
}
1040
1048
1041
1049
/// Returns a list of all fallback addresses
@@ -1596,7 +1604,7 @@ mod test {
1596
1604
) ;
1597
1605
assert_eq ! ( invoice. payee_pub_key( ) , Some ( & public_key) ) ;
1598
1606
assert_eq ! ( invoice. expiry_time( ) , Duration :: from_secs( 54321 ) ) ;
1599
- assert_eq ! ( invoice. min_final_cltv_expiry( ) , Some ( & 144 ) ) ;
1607
+ assert_eq ! ( invoice. min_final_cltv_expiry( ) , 144 ) ;
1600
1608
assert_eq ! ( invoice. fallbacks( ) , vec![ & Fallback :: PubKeyHash ( [ 0 ; 20 ] ) ] ) ;
1601
1609
assert_eq ! ( invoice. routes( ) , vec![ & RouteHint ( route_1) , & RouteHint ( route_2) ] ) ;
1602
1610
assert_eq ! (
0 commit comments