projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
25a3e04
)
Use default for invoice's min_final_cltv_expiry
author
Jeffrey Czyz
<jkczyz@gmail.com>
Mon, 26 Apr 2021 18:59:56 +0000
(11:59 -0700)
committer
Jeffrey Czyz
<jkczyz@gmail.com>
Thu, 29 Apr 2021 21:08:41 +0000
(14:08 -0700)
lightning-invoice/src/lib.rs
patch
|
blob
|
history
diff --git
a/lightning-invoice/src/lib.rs
b/lightning-invoice/src/lib.rs
index 0e469ff1e8600745cd97648cf7f9739524f18377..9c676e434fd22c1de24e011021345fb0d313128e 100644
(file)
--- a/
lightning-invoice/src/lib.rs
+++ b/
lightning-invoice/src/lib.rs
@@
-59,6
+59,11
@@
const MAX_EXPIRY_TIME: u64 = 60 * 60 * 24 * 356;
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
const DEFAULT_EXPIRY_TIME: u64 = 3600;
/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
const DEFAULT_EXPIRY_TIME: u64 = 3600;
+/// Default minimum final CLTV expiry as defined by [BOLT 11].
+///
+/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
+const DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = 18;
+
/// This function is used as a static assert for the size of `SystemTime`. If the crate fails to
/// compile due to it this indicates that your system uses unexpected bounds for `SystemTime`. You
/// can remove this functions and run the test `test_system_time_bounds_assumptions`. In any case,
/// This function is used as a static assert for the size of `SystemTime`. If the crate fails to
/// compile due to it this indicates that your system uses unexpected bounds for `SystemTime`. You
/// can remove this functions and run the test `test_system_time_bounds_assumptions`. In any case,
@@
-1053,9
+1058,12
@@
impl Invoice {
.unwrap_or(Duration::from_secs(DEFAULT_EXPIRY_TIME))
}
.unwrap_or(Duration::from_secs(DEFAULT_EXPIRY_TIME))
}
- /// Returns the invoice's `min_cltv_expiry` time if present
- pub fn min_final_cltv_expiry(&self) -> Option<u64> {
- self.signed_invoice.min_final_cltv_expiry().map(|x| x.0)
+ /// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise
+ /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
+ pub fn min_final_cltv_expiry(&self) -> u64 {
+ self.signed_invoice.min_final_cltv_expiry()
+ .map(|x| x.0)
+ .unwrap_or(DEFAULT_MIN_FINAL_CLTV_EXPIRY)
}
/// Returns a list of all fallback addresses
}
/// Returns a list of all fallback addresses
@@
-1620,7
+1628,7
@@
mod test {
);
assert_eq!(invoice.payee_pub_key(), Some(&public_key));
assert_eq!(invoice.expiry_time(), Duration::from_secs(54321));
);
assert_eq!(invoice.payee_pub_key(), Some(&public_key));
assert_eq!(invoice.expiry_time(), Duration::from_secs(54321));
- assert_eq!(invoice.min_final_cltv_expiry(),
Some(144)
);
+ assert_eq!(invoice.min_final_cltv_expiry(),
144
);
assert_eq!(invoice.fallbacks(), vec![&Fallback::PubKeyHash([0;20])]);
assert_eq!(invoice.routes(), vec![&RouteHint(route_1), &RouteHint(route_2)]);
assert_eq!(
assert_eq!(invoice.fallbacks(), vec![&Fallback::PubKeyHash([0;20])]);
assert_eq!(invoice.routes(), vec![&RouteHint(route_1), &RouteHint(route_2)]);
assert_eq!(