Fail PendingInboundPayments after their expiry time is reached
authorMatt Corallo <git@bluematt.me>
Fri, 23 Apr 2021 23:56:58 +0000 (23:56 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 28 Apr 2021 19:30:25 +0000 (15:30 -0400)
lightning/src/ln/channelmanager.rs

index f147a8162ff3c53fe368c536648681bbde9965cd..ea3c2be917f140308b0d29c92414ccb3fe553f04 100644 (file)
@@ -451,7 +451,7 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
        /// Storage for PaymentSecrets and any requirements on future inbound payments before we will
        /// expose them to users via a PaymentReceived event. HTLCs which do not meet the requirements
        /// here are failed when we process them as pending-forwardable-HTLCs, and entries are removed
-       /// after we generate a PaymentReceived upon receipt of all MPP parts.
+       /// after we generate a PaymentReceived upon receipt of all MPP parts or when they time out.
        /// Locked *after* channel_state.
        pending_inbound_payments: Mutex<HashMap<PaymentHash, PendingInboundPayment>>,
 
@@ -3601,6 +3601,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<Txid> {