]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Narrow ChainWatchInterface::install_watch_script
authorMatt Corallo <git@bluematt.me>
Fri, 7 Sep 2018 15:12:22 +0000 (11:12 -0400)
committerAntoine Riard <ariard@student.42.fr>
Sat, 8 Sep 2018 02:30:28 +0000 (02:30 +0000)
fuzz/fuzz_targets/router_target.rs
src/chain/chaininterface.rs
src/ln/channelmonitor.rs

index d8755956202a17d153825c79c66b4f50730a73e3..6476f812fb34dd2243ea1a585e6753eb44b3a52b 100644 (file)
@@ -76,7 +76,7 @@ struct DummyChainWatcher {
 }
 
 impl ChainWatchInterface for DummyChainWatcher {
-       fn install_watch_script(&self, _script_pub_key: &Script) { }
+       fn install_watch_tx(&self, _txid: &Sha256dHash, _script_pub_key: &Script) { }
        fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) { }
        fn watch_all_txn(&self) { }
        fn register_listener(&self, _listener: Weak<ChainListener>) { }
index 78a40099c35d69687962d33c88b058c06399e6ba..3a0b2d735d9a877eb98f95dd23739a472ad6a54d 100644 (file)
@@ -25,8 +25,8 @@ pub enum ChainError {
 /// called from inside the library in response to ChainListener events, P2P events, or timer
 /// events).
 pub trait ChainWatchInterface: Sync + Send {
-       /// Provides a scriptPubKey which much be watched for.
-       fn install_watch_script(&self, script_pub_key: &Script);
+       /// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
+       fn install_watch_tx(&self, txid: &Sha256dHash, script_pub_key: &Script);
 
        /// Provides an outpoint which must be watched for, providing any transactions which spend the
        /// given outpoint.
@@ -54,9 +54,9 @@ pub trait BroadcasterInterface: Sync + Send {
 /// A trait indicating a desire to listen for events from the chain
 pub trait ChainListener: Sync + Send {
        /// Notifies a listener that a block was connected.
-       /// Note that if a new script/transaction is watched during a block_connected call, the block
-       /// *must* be re-scanned with the new script/transaction and block_connected should be called
-       /// again with the same header and (at least) the new transactions.
+       /// Note that if a new transaction/outpoint is watched during a block_connected call, the block
+       /// *must* be re-scanned with the new transaction/outpoints and block_connected should be
+       /// called again with the same header and (at least) the new transactions.
        /// This also means those counting confirmations using block_connected callbacks should watch
        /// for duplicate headers and not count them towards confirmations!
        fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]);
@@ -97,7 +97,7 @@ pub struct ChainWatchInterfaceUtil {
 
 /// Register listener
 impl ChainWatchInterface for ChainWatchInterfaceUtil {
-       fn install_watch_script(&self, script_pub_key: &Script) {
+       fn install_watch_tx(&self, _txid: &Sha256dHash, script_pub_key: &Script) {
                let mut watched = self.watched.lock().unwrap();
                watched.0.push(script_pub_key.clone());
                self.reentered.fetch_add(1, Ordering::Relaxed);
index 52bb6d65c3c6bb61838c0b4c23691d78202a4d8b..e467772b1fa1628d4c795547073e944b720245c9 100644 (file)
@@ -97,7 +97,7 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static> SimpleManyChannelMonitor<Key>
                match &monitor.funding_txo {
                        &None => self.chain_monitor.watch_all_txn(),
                        &Some((ref outpoint, ref script)) => {
-                               self.chain_monitor.install_watch_script(script);
+                               self.chain_monitor.install_watch_tx(&outpoint.txid, script);
                                self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script);
                        },
                }