Skip to content

Commit e4936a0

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 250f30b commit e4936a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ where C::Target: chain::Filter,
100100
if let Some(ref chain_source) = self.chain_source {
101101
for (txid, outputs) in txn_outputs.drain(..) {
102102
for (idx, output) in outputs.iter() {
103-
chain_source.register_output(&OutPoint { txid, index: *idx as u16 }, &output.script_pubkey);
103+
// Register any new outputs with the chain source for filtering and recurse
104+
// if it indicates that there are dependent transactions within the block
105+
// that had not been previously included in txdata.
106+
let outpoint = OutPoint { txid, index: *idx as u16 };
107+
if let Some((index, tx)) = chain_source.register_output(&outpoint, &output.script_pubkey) {
108+
self.block_connected(header, &[(index, &tx)], height);
109+
}
104110
}
105111
}
106112
}

0 commit comments

Comments
 (0)