Add init height in ChannelManager constructor
[rust-lightning] / src / ln / channelmanager.rs
index 2b22cbd89d0ec060d95f9d1a15793e2c733f607a..a6e5575b425b8b58112a9c580db68751d2b74126 100644 (file)
@@ -494,7 +494,10 @@ macro_rules! try_chan_entry {
                                                }
                                        }
                                }
-                               let mut shutdown_res = chan.force_shutdown(); // We drop closing transactions as they are toxic datas and MUST NOT be broadcast
+                               let mut shutdown_res = chan.force_shutdown();
+                               if shutdown_res.0.len() >= 1 {
+                                       log_error!($self, "You have a toxic local commitment transaction {} avaible in channel monitor, read comment in ChannelMonitor::get_latest_local_commitment_txn to be informed of manual action to take", shutdown_res.0[0].txid());
+                               }
                                shutdown_res.0.clear();
                                return Err(MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, shutdown_res, $self.get_channel_update(&chan).ok()))
                        }
@@ -582,7 +585,10 @@ impl ChannelManager {
        /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
        ///
        /// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
-       pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor>, chain_monitor: Arc<ChainWatchInterface>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface>, config: UserConfig) -> Result<Arc<ChannelManager>, secp256k1::Error> {
+       ///
+       /// User must provide the current blockchain height from which to track onchain channel
+       /// funding outpoints and send payments with reliable timelocks.
+       pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor>, chain_monitor: Arc<ChainWatchInterface>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface>, config: UserConfig, current_blockchain_height: usize) -> Result<Arc<ChannelManager>, secp256k1::Error> {
                let secp_ctx = Secp256k1::new();
 
                let res = Arc::new(ChannelManager {
@@ -593,7 +599,7 @@ impl ChannelManager {
                        chain_monitor,
                        tx_broadcaster,
 
-                       latest_block_height: AtomicUsize::new(0), //TODO: Get an init value
+                       latest_block_height: AtomicUsize::new(current_blockchain_height),
                        last_block_hash: Mutex::new(Default::default()),
                        secp_ctx,