Add a const and docs for the min `min_final_cltv_expiry` we allow 2021-04-features-chanman
authorMatt Corallo <git@bluematt.me>
Tue, 27 Apr 2021 16:06:00 +0000 (16:06 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 28 Apr 2021 19:30:25 +0000 (15:30 -0400)
lightning/src/ln/channelmanager.rs

index ea3c2be917f140308b0d29c92414ccb3fe553f04..31529343d56d22b646ab37c44f0f3639be7d2dec 100644 (file)
@@ -588,6 +588,11 @@ pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 2 * 6 * 24 * 7;
 pub const MIN_CLTV_EXPIRY_DELTA: u16 = 6 * 6;
 pub(super) const CLTV_FAR_FAR_AWAY: u32 = 6 * 24 * 7; //TODO?
 
+/// Minimum CLTV difference between the current block height and received inbound payments.
+/// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least
+/// this value.
+pub const MIN_FINAL_CLTV_EXPIRY: u32 = HTLC_FAIL_BACK_BUFFER;
+
 // Check that our CLTV_EXPIRY is at least CLTV_CLAIM_BUFFER + ANTI_REORG_DELAY + LATENCY_GRACE_PERIOD_BLOCKS,
 // ie that if the next-hop peer fails the HTLC within
 // LATENCY_GRACE_PERIOD_BLOCKS then we'll still have CLTV_CLAIM_BUFFER left to timeout it onchain,
@@ -3465,6 +3470,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
        ///
        /// May panic if `invoice_expiry_delta_secs` is greater than one year.
        ///
+       /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
+       /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
+       ///
        /// [`create_inbound_payment`]: Self::create_inbound_payment
        /// [`PaymentReceived`]: events::Event::PaymentReceived
        /// [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id