X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmanager.rs;h=31529343d56d22b646ab37c44f0f3639be7d2dec;hb=0725098eefd329f128a9ad6058fd431d0f3b5d75;hp=f147a8162ff3c53fe368c536648681bbde9965cd;hpb=3b8ac139ba4dc97ee02feb9a8b0787827bff4e11;p=rust-lightning diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index f147a816..31529343 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -451,7 +451,7 @@ pub struct ChannelManager>, @@ -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 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 @@ -3601,6 +3609,10 @@ where } max_time!(self.last_node_announcement_serial); max_time!(self.highest_seen_timestamp); + let mut payment_secrets = self.pending_inbound_payments.lock().unwrap(); + payment_secrets.retain(|_, inbound_payment| { + inbound_payment.expiry_time > header.time as u64 + }); } fn get_relevant_txids(&self) -> Vec {