From a611ae4741fc213b2d59b49722121f0f7a1f6873 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 22 Jul 2018 13:57:55 -0400 Subject: [PATCH] Ensure the funding transaction is registered to be monitored --- src/chain/chaininterface.rs | 11 ++++++----- src/ln/channelmonitor.rs | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/chain/chaininterface.rs b/src/chain/chaininterface.rs index f99f581f..518b20b1 100644 --- a/src/chain/chaininterface.rs +++ b/src/chain/chaininterface.rs @@ -12,7 +12,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; /// events). pub trait ChainWatchInterface: Sync + Send { /// Provides a scriptPubKey which much be watched for. - fn install_watch_script(&self, script_pub_key: Script); + fn install_watch_script(&self, script_pub_key: &Script); /// Provides an outpoint which must be watched for, providing any transactions which spend the /// given outpoint. @@ -70,9 +70,9 @@ pub struct ChainWatchInterfaceUtil { /// Register listener impl ChainWatchInterface for ChainWatchInterfaceUtil { - fn install_watch_script(&self, script_pub_key: Script) { + fn install_watch_script(&self, script_pub_key: &Script) { let mut watched = self.watched.lock().unwrap(); - watched.0.push(Script::from(script_pub_key)); + watched.0.push(script_pub_key.clone()); self.reentered.fetch_add(1, Ordering::Relaxed); } @@ -103,7 +103,7 @@ impl ChainWatchInterfaceUtil { } } - /// Notify listeners that a block was connected. + /// Notify listeners that a block was connected given a full, unfiltered block. /// Handles re-scanning the block and calling block_connected again if listeners register new /// watch data during the callbacks for you (see ChainListener::block_connected for more info). pub fn block_connected_with_filtering(&self, block: &Block, height: u32) { @@ -135,7 +135,8 @@ impl ChainWatchInterfaceUtil { } } - /// Notify listeners that a block was connected. + /// Notify listeners that a block was connected, given pre-filtered list of transactions in the + /// block which matched the filter (probably using does_match_tx). /// Returns true if notified listeners registered additional watch data (implying that the /// block must be re-scanned and this function called again prior to further block_connected /// calls, see ChainListener::block_connected for more info). diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index 51f7d3cf..2ee5b37a 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -94,7 +94,10 @@ impl SimpleManyChannelMonitor }; match &monitor.funding_txo { &None => self.chain_monitor.watch_all_txn(), - &Some((ref outpoint, ref script)) => self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script), + &Some((ref outpoint, ref script)) => { + self.chain_monitor.install_watch_script(script); + self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script); + }, } monitors.insert(key, monitor); Ok(()) -- 2.30.2