Skip to content

Commit a06a7de

Browse files
committed
f - look at next SCID when retaining previous
1 parent 07908cf commit a06a7de

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11695,16 +11695,27 @@ where
1169511695
}
1169611696
}
1169711697

11698-
// Remove any scids used by old splice funding transactions
11699-
let mut short_to_chan_info = self.short_to_chan_info.write().unwrap();
11700-
channel.context.historical_scids.retain(|scid| {
11701-
let funding_height = block_from_scid(*scid);
11702-
let retain_scid = funding_height + CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY > height;
11703-
if !retain_scid {
11704-
short_to_chan_info.remove(scid);
11698+
// Remove any scids used by older funding transactions
11699+
if let Some(current_scid) = channel.funding.get_short_channel_id() {
11700+
let historical_scids = &mut channel.context.historical_scids;
11701+
if !historical_scids.is_empty() {
11702+
let mut short_to_chan_info = self.short_to_chan_info.write().unwrap();
11703+
11704+
// Remove an older SCID if the next funding has enough confirmations
11705+
for (scid, next_scid) in historical_scids
11706+
.iter()
11707+
.zip(historical_scids.iter().skip(1).chain(core::iter::once(&current_scid)))
11708+
{
11709+
let funding_height = block_from_scid(*next_scid);
11710+
let retain_scid = funding_height + CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY > height;
11711+
if !retain_scid {
11712+
short_to_chan_info.remove(scid);
11713+
}
11714+
}
11715+
11716+
historical_scids.retain(|scid| short_to_chan_info.contains_key(scid));
1170511717
}
11706-
retain_scid
11707-
});
11718+
}
1170811719

1170911720
channel.best_block_updated(height, header.time, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context, None))
1171011721
});

0 commit comments

Comments
 (0)