X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fchannelmonitor.rs;h=b8598eabb972daab40551eb3c7ada7f4b6ace80d;hb=8f1dc54e6d8db0b320948fbab57be026f77a0302;hp=66d083377b0e6c23b5f863adb1c2f2aa0b7f98a4;hpb=2c0fcf21f227ad1a01e4a884dda72b9537c16fae;p=rust-lightning diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 66d08337..b8598eab 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -34,7 +34,7 @@ use bitcoin::secp256k1; use bitcoin::sighash::EcdsaSighashType; use crate::ln::channel::INITIAL_COMMITMENT_NUMBER; -use crate::ln::{PaymentHash, PaymentPreimage, ChannelId}; +use crate::ln::types::{PaymentHash, PaymentPreimage, ChannelId}; use crate::ln::msgs::DecodeError; use crate::ln::channel_keys::{DelayedPaymentKey, DelayedPaymentBasepoint, HtlcBasepoint, HtlcKey, RevocationKey, RevocationBasepoint}; use crate::ln::chan_utils::{self,CommitmentTransaction, CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLCClaim, ChannelTransactionParameters, HolderCommitmentTransaction, TxCreationKeys}; @@ -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; @@ -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 }, @@ -4808,7 +4811,7 @@ mod tests { use crate::chain::package::{weight_offered_htlc, weight_received_htlc, weight_revoked_offered_htlc, weight_revoked_received_htlc, WEIGHT_REVOKED_OUTPUT}; use crate::chain::transaction::OutPoint; use crate::sign::InMemorySigner; - use crate::ln::{PaymentPreimage, PaymentHash, ChannelId}; + use crate::ln::types::{PaymentPreimage, PaymentHash, ChannelId}; use crate::ln::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcBasepoint, RevocationBasepoint, RevocationKey}; use crate::ln::chan_utils::{self,HTLCOutputInCommitment, ChannelPublicKeys, ChannelTransactionParameters, HolderCommitmentTransaction, CounterpartyChannelTransactionParameters}; use crate::ln::channelmanager::{PaymentSendFailure, PaymentId, RecipientOnionFields};