Include funding TXO in outputs to watch
authorJeffrey Czyz <jkczyz@gmail.com>
Sat, 29 Aug 2020 23:04:46 +0000 (16:04 -0700)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 1 Oct 2020 05:41:23 +0000 (22:41 -0700)
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
lightning/src/ln/channelmonitor.rs

index 7721408c4390e035cb9836a50c9e3f277762b879..0f1394352a847cc5454644580dd6de178468d2cc 100644 (file)
@@ -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
index fd6334d7029e7ffccf180e3d4a21634c5a3882f1..86799c7b6230434b7b054f6bd54dd0f811db3b86 100644 (file)
@@ -1252,6 +1252,9 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                };
                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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                        pending_events: Vec::new(),
 
                        onchain_events_waiting_threshold_conf: HashMap::new(),
-                       outputs_to_watch: HashMap::new(),
+                       outputs_to_watch,
 
                        onchain_tx_handler,