Skip to content

Commit a545d30

Browse files
committed
f Default to cur_hash if no first_broadcast_hash is set
1 parent 8cf207f commit a545d30

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lightning/src/util/sweep.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,23 @@ pub struct TrackedSpendableOutput {
4646
}
4747

4848
impl TrackedSpendableOutput {
49-
fn to_watched_output(&self) -> WatchedOutput {
49+
fn to_watched_output(&self, cur_hash: BlockHash) -> WatchedOutput {
50+
let block_hash = self.status.first_broadcast_hash().or(Some(cur_hash));
5051
match &self.descriptor {
5152
SpendableOutputDescriptor::StaticOutput { outpoint, output, channel_keys_id: _ } => {
5253
WatchedOutput {
53-
block_hash: self.status.first_broadcast_hash(),
54+
block_hash,
5455
outpoint: *outpoint,
5556
script_pubkey: output.script_pubkey.clone(),
5657
}
5758
},
5859
SpendableOutputDescriptor::DelayedPaymentOutput(output) => WatchedOutput {
59-
block_hash: self.status.first_broadcast_hash(),
60+
block_hash,
6061
outpoint: output.outpoint,
6162
script_pubkey: output.output.script_pubkey.clone(),
6263
},
6364
SpendableOutputDescriptor::StaticPaymentOutput(output) => WatchedOutput {
64-
block_hash: self.status.first_broadcast_hash(),
65+
block_hash,
6566
outpoint: output.outpoint,
6667
script_pubkey: output.output.script_pubkey.clone(),
6768
},
@@ -372,7 +373,7 @@ where
372373
) -> Self {
373374
if let Some(filter) = chain_data_source.as_ref() {
374375
for output_info in &outputs {
375-
let watched_output = output_info.to_watched_output();
376+
let watched_output = output_info.to_watched_output(best_block.block_hash);
376377
filter.register_output(watched_output);
377378
}
378379
}
@@ -506,7 +507,7 @@ where
506507
let respend_outputs = sweeper_state.outputs.iter_mut().filter(|o| filter_fn(&**o));
507508
for output_info in respend_outputs {
508509
if let Some(filter) = self.chain_data_source.as_ref() {
509-
let watched_output = output_info.to_watched_output();
510+
let watched_output = output_info.to_watched_output(cur_hash);
510511
filter.register_output(watched_output);
511512
}
512513

0 commit comments

Comments
 (0)