From 9e14256b71003ed84ae36c6bb8bcab9a1fb60890 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Sat, 29 Aug 2020 16:04:46 -0700 Subject: [PATCH] Include funding TXO in outputs to watch The funding TXO was never added to ChannelMonitor's outputs_to_watch in 73dce207dd0ea6c3ac57af3ebb8b87ee03e82c9e. Include it when constructing a ChannelMonitor. --- lightning/src/chain/mod.rs | 6 +++--- lightning/src/ln/channelmonitor.rs | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index 7721408c4..0f1394352 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -72,9 +72,9 @@ pub trait Watch: Send + Sync { /// Watches a channel identified by `funding_txo` using `monitor`. /// /// Implementations are responsible for watching the chain for the funding transaction along - /// with spends of its output and any outputs returned by [`get_outputs_to_watch`]. In practice, - /// this means calling [`block_connected`] and [`block_disconnected`] on the monitor and - /// including all such transactions that meet this criteria. + /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + /// calling [`block_connected`] and [`block_disconnected`] on the monitor and including all such + /// transactions that meet this criteria. /// /// [`get_outputs_to_watch`]: ../ln/channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch /// [`block_connected`]: ../ln/channelmonitor/struct.ChannelMonitor.html#method.block_connected diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index fd6334d70..86799c7b6 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -1252,6 +1252,9 @@ impl ChannelMonitor { }; onchain_tx_handler.provide_latest_holder_tx(initial_holder_commitment_tx); + let mut outputs_to_watch = HashMap::new(); + outputs_to_watch.insert(funding_info.0.txid, vec![funding_info.1.clone()]); + ChannelMonitor { latest_update_id: 0, commitment_transaction_number_obscure_factor, @@ -1288,7 +1291,7 @@ impl ChannelMonitor { pending_events: Vec::new(), onchain_events_waiting_threshold_conf: HashMap::new(), - outputs_to_watch: HashMap::new(), + outputs_to_watch, onchain_tx_handler, -- 2.39.5