Skip to content

Commit 31464d9

Browse files
committed
Add rescan logic to ChainMonitor::block_connected
Electrum clients will only provide transaction data for outputs that have been explicitly registered. Hence, upon registering new outputs, recursively register any outputs to watch contained within dependent transactions from the same block.
1 parent 3726060 commit 31464d9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ where C::Target: chain::Filter,
9090
let block_hash = header.block_hash();
9191
for (txid, outputs) in txn_outputs.drain(..) {
9292
for (idx, output) in outputs.iter() {
93-
chain_source.register_output(WatchedOutput {
93+
// Register any new outputs with the chain source for filtering and recurse
94+
// if it indicates that there are dependent transactions within the block
95+
// that had not been previously included in txdata.
96+
let output = WatchedOutput {
9497
block_hash: Some(block_hash),
9598
outpoint: OutPoint { txid, index: *idx as u16 },
9699
script_pubkey: output.script_pubkey.clone(),
97-
});
100+
};
101+
if let Some((index, tx)) = chain_source.register_output(output) {
102+
self.block_connected(header, &[(index, &tx)], height);
103+
}
98104
}
99105
}
100106
}

0 commit comments

Comments
 (0)