Merge pull request #3035 from TheBlueMatt/2024-04-upstream-123-bindings
[rust-lightning] / lightning / src / chain / channelmonitor.rs
index 853fbbbe8bf147d217b9df305bf73f087fc259ed..b8598eabb972daab40551eb3c7ada7f4b6ace80d 100644 (file)
@@ -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};
@@ -1878,10 +1878,10 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                        }
                }
 
+               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<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
                        (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
                        },
@@ -4381,6 +4384,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                                revocation_pubkey: broadcasted_holder_revokable_script.2,
                                                channel_keys_id: self.channel_keys_id,
                                                channel_value_satoshis: self.channel_value_satoshis,
+                                               channel_transaction_parameters: Some(self.onchain_tx_handler.channel_transaction_parameters.clone()),
                                        }));
                                }
                        }
@@ -4807,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};