Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

When we see a funding transaction for one of our chanels reorg'd out, we worry that its possible we've been double-spent and immediately force-close the channel to avoid accepting any more HTLCs on it. This isn't ideal, but is mostly fine as most nodes require 6 confirmations and 6 block reorgs are exceedingly rare.

However, this isn't so okay for 0-conf channels - in that case we elected to trust the funder anyway, so reorgs shouldn't worry us. Still, to handle this correctly we needed to track the old SCID and ensure our logic is safe across an SCID change. Luckily, we did that work for splices, and can now take advantage of it here.

Fixes #3836.

@TheBlueMatt TheBlueMatt added this to the 0.3 milestone Nov 18, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Nov 18, 2025

I've assigned @wpaulino as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

When we see a funding transaction for one of our chanels reorg'd
out, we worry that its possible we've been double-spent and
immediately force-close the channel to avoid accepting any more
HTLCs on it. This isn't ideal, but is mostly fine as most nodes
require 6 confirmations and 6 block reorgs are exceedingly rare.

However, this isn't so okay for 0-conf channels - in that case we
elected to trust the funder anyway, so reorgs shouldn't worry us.
Still, to handle this correctly we needed to track the old SCID and
ensure our logic is safe across an SCID change. Luckily, we did
that work for splices, and can now take advantage of it here.

Fixes lightningdevkit#3836.
@TheBlueMatt TheBlueMatt force-pushed the 2025-11-0conf-no-reorg-close branch from 83e1ae9 to b4f7fdf Compare November 18, 2025 17:21
// Reset the original short_channel_id so that we'll generate a closure
// `channel_update` broadcast event.
self.funding.short_channel_id = original_scid;
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no point in logging funding_tx_confirmations when we know it's 0

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @tankyleo

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 96.61017% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.36%. Comparing base (21110c8) to head (b4f7fdf).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/functional_test_utils.rs 81.25% 0 Missing and 3 partials ⚠️
lightning/src/ln/priv_short_conf_tests.rs 98.63% 2 Missing ⚠️
lightning/src/ln/channel.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4231      +/-   ##
==========================================
+ Coverage   89.33%   89.36%   +0.02%     
==========================================
  Files         180      180              
  Lines      138353   138616     +263     
  Branches   138353   138616     +263     
==========================================
+ Hits       123598   123870     +272     
+ Misses      12132    12123       -9     
  Partials     2623     2623              
Flag Coverage Δ
fuzzing 35.98% <12.90%> (+0.07%) ⬆️
tests 88.72% <96.61%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

} else {
debug_assert!(false);
}
if self.context.minimum_depth(&self.funding).expect("set for a ready channel") > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we also not want to force close for 1-conf minimum channels ? Zero-conf channels have min depth 0 iiuc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep 0conf channels live if funding gets reorg'd out

4 participants