Skip to content

Commit a92b3c2

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 796e0ad commit a92b3c2

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
@@ -101,11 +101,17 @@ where C::Target: chain::Filter,
101101
let block_hash = header.block_hash();
102102
for (txid, outputs) in txn_outputs.drain(..) {
103103
for (idx, output) in outputs.iter() {
104-
chain_source.register_output(WatchedOutput {
104+
// Register any new outputs with the chain source for filtering and recurse
105+
// if it indicates that there are dependent transactions within the block
106+
// that had not been previously included in txdata.
107+
let output = WatchedOutput {
105108
block_hash: Some(block_hash),
106109
outpoint: OutPoint { txid, index: *idx as u16 },
107110
script_pubkey: output.script_pubkey.clone(),
108-
});
111+
};
112+
if let Some((index, tx)) = chain_source.register_output(output) {
113+
self.block_connected(header, &[(index, &tx)], height);
114+
}
109115
}
110116
}
111117
}

0 commit comments

Comments
 (0)