Skip to content

Commit 0e3c3b9

Browse files
committed
Fail PendingInboundPayments after their expiry time is reached
1 parent 5811530 commit 0e3c3b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
451451
/// Storage for PaymentSecrets and any requirements on future inbound payments before we will
452452
/// expose them to users via a PaymentReceived event. HTLCs which do not meet the requirements
453453
/// here are failed when we process them as pending-forwardable-HTLCs, and entries are removed
454-
/// after we generate a PaymentReceived upon receipt of all MPP parts.
454+
/// after we generate a PaymentReceived upon receipt of all MPP parts or when they time out.
455455
/// Locked *after* channel_state.
456456
pending_inbound_payments: Mutex<HashMap<PaymentHash, PendingInboundPayment>>,
457457

@@ -3597,6 +3597,10 @@ where
35973597
}
35983598
max_time!(self.last_node_announcement_serial);
35993599
max_time!(self.highest_seen_timestamp);
3600+
let mut payment_secrets = self.pending_inbound_payments.lock().unwrap();
3601+
payment_secrets.retain(|_, inbound_payment| {
3602+
inbound_payment.expiry_time > header.time as u64
3603+
});
36003604
}
36013605

36023606
fn get_relevant_txids(&self) -> Vec<Txid> {
@@ -3712,6 +3716,10 @@ where
37123716
});
37133717
!htlcs.is_empty() // Only retain this entry if htlcs has at least one entry.
37143718
});
3719+
let mut payment_secrets = self.pending_inbound_payments.lock().unwrap();
3720+
payment_secrets.retain(|_, inbound_payment| {
3721+
inbound_payment.expiry_height > height
3722+
});
37153723
}
37163724
}
37173725

0 commit comments

Comments
 (0)