From 71fef35eb26c434d896998e3b482d295db89ee22 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 18 Apr 2024 21:40:41 +0000 Subject: [PATCH 1/2] Correct `ChannelMonitor::is_fully_resolved` docs The block count at which the monitor will become prunable was changed by an update while the PR was pending but not propagated to the docs. --- lightning/src/chain/channelmonitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index c05b6b30922..853fbbbe8bf 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -1865,7 +1865,7 @@ impl ChannelMonitor { /// its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set). /// /// This function returns true only if [`Self::get_claimable_balances`] has been empty for at least - /// 2016 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + /// 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. pub fn is_fully_resolved(&self, logger: &L) -> bool { let mut is_all_funds_claimed = self.get_claimable_balances().is_empty(); let current_height = self.current_best_block().height; From fd0c3e45793e7ce9efe5b164170dc3563a0e588c Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 18 Apr 2024 21:42:48 +0000 Subject: [PATCH 2/2] Log when a ChannelMonitor's claimable balances set goes empty --- lightning/src/chain/channelmonitor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 853fbbbe8bf..58d9795978f 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -1878,10 +1878,10 @@ impl ChannelMonitor { } } + const BLOCKS_THRESHOLD: u32 = 4032; // ~four weeks match (inner.balances_empty_height, is_all_funds_claimed) { (Some(balances_empty_height), true) => { // Claimed all funds, check if reached the blocks threshold. - const BLOCKS_THRESHOLD: u32 = 4032; // ~four weeks return current_height >= balances_empty_height + BLOCKS_THRESHOLD; }, (Some(_), false) => { @@ -1897,6 +1897,9 @@ impl ChannelMonitor { (None, true) => { // Claimed all funds but `balances_empty_height` is None. It is set to the // current block height. + log_debug!(logger, + "ChannelMonitor funded at {} is now fully resolved. It will become archivable in {} blocks", + inner.get_funding_txo().0, BLOCKS_THRESHOLD); inner.balances_empty_height = Some(current_height); false },