Skip to content

Commit 90b545f

Browse files
TheBlueMattAntoine Riard
authored andcommitted
Narrow ChainWatchInterface::install_watch_script
1 parent 68d0fcd commit 90b545f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

fuzz/fuzz_targets/router_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct DummyChainWatcher {
7676
}
7777

7878
impl ChainWatchInterface for DummyChainWatcher {
79-
fn install_watch_script(&self, _script_pub_key: &Script) { }
79+
fn install_watch_tx(&self, _txid: &Sha256dHash, _script_pub_key: &Script) { }
8080
fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) { }
8181
fn watch_all_txn(&self) { }
8282
fn register_listener(&self, _listener: Weak<ChainListener>) { }

src/chain/chaininterface.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub enum ChainError {
2525
/// called from inside the library in response to ChainListener events, P2P events, or timer
2626
/// events).
2727
pub trait ChainWatchInterface: Sync + Send {
28-
/// Provides a scriptPubKey which much be watched for.
29-
fn install_watch_script(&self, script_pub_key: &Script);
28+
/// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
29+
fn install_watch_tx(&self, txid: &Sha256dHash, script_pub_key: &Script);
3030

3131
/// Provides an outpoint which must be watched for, providing any transactions which spend the
3232
/// given outpoint.
@@ -54,9 +54,9 @@ pub trait BroadcasterInterface: Sync + Send {
5454
/// A trait indicating a desire to listen for events from the chain
5555
pub trait ChainListener: Sync + Send {
5656
/// Notifies a listener that a block was connected.
57-
/// Note that if a new script/transaction is watched during a block_connected call, the block
58-
/// *must* be re-scanned with the new script/transaction and block_connected should be called
59-
/// again with the same header and (at least) the new transactions.
57+
/// Note that if a new transaction/outpoint is watched during a block_connected call, the block
58+
/// *must* be re-scanned with the new transaction/outpoints and block_connected should be
59+
/// called again with the same header and (at least) the new transactions.
6060
/// This also means those counting confirmations using block_connected callbacks should watch
6161
/// for duplicate headers and not count them towards confirmations!
6262
fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]);
@@ -97,7 +97,7 @@ pub struct ChainWatchInterfaceUtil {
9797

9898
/// Register listener
9999
impl ChainWatchInterface for ChainWatchInterfaceUtil {
100-
fn install_watch_script(&self, script_pub_key: &Script) {
100+
fn install_watch_tx(&self, _txid: &Sha256dHash, script_pub_key: &Script) {
101101
let mut watched = self.watched.lock().unwrap();
102102
watched.0.push(script_pub_key.clone());
103103
self.reentered.fetch_add(1, Ordering::Relaxed);

src/ln/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static> SimpleManyChannelMonitor<Key>
9797
match &monitor.funding_txo {
9898
&None => self.chain_monitor.watch_all_txn(),
9999
&Some((ref outpoint, ref script)) => {
100-
self.chain_monitor.install_watch_script(script);
100+
self.chain_monitor.install_watch_tx(&outpoint.txid, script);
101101
self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script);
102102
},
103103
}

0 commit comments

Comments
 (0)