Skip to content

fix: SCID preference for outbound payments on spliced channel#4376

Open
okekefrancis112 wants to merge 2 commits intolightningdevkit:mainfrom
okekefrancis112:prefer_outbound_scid
Open

fix: SCID preference for outbound payments on spliced channel#4376
okekefrancis112 wants to merge 2 commits intolightningdevkit:mainfrom
okekefrancis112:prefer_outbound_scid

Conversation

@okekefrancis112
Copy link

Summary

Spliced channels can cause real SCIDs to change unexpectedly, which breaks the
assumption that they are more stable than SCID aliases. This PR corrects the
outbound payment SCID selection logic to reflect this reality.

Details

ChannelDetails::get_outbound_payment_scid now prefers SCID aliases.

This aligns outbound routing with current splicing behavior.

Tests that depended on the old assumption were updated accordingly.

Closes: #4249

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 3, 2026

👋 Thanks for assigning @TheBlueMatt 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.

@TheBlueMatt TheBlueMatt requested review from TheBlueMatt and removed request for wpaulino February 3, 2026 16:18
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Please fix rustfmt.

@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.

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.02%. Comparing base (f43803d) to head (a153dbe).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4376   +/-   ##
=======================================
  Coverage   86.01%   86.02%           
=======================================
  Files         156      156           
  Lines      102857   102857           
  Branches   102857   102857           
=======================================
+ Hits        88474    88480    +6     
+ Misses      11876    11868    -8     
- Partials     2507     2509    +2     
Flag Coverage Δ
tests 86.02% <100.00%> (+<0.01%) ⬆️

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.

@okekefrancis112
Copy link
Author

@TheBlueMatt, please, are all the checks needed to pass before my work gets reviewed?. Just asking, because while the checks are happening, maybe a new commit is added to main that causes a conflict, and before you know it, my check here is failing.

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @joostjager

@okekefrancis112 okekefrancis112 force-pushed the prefer_outbound_scid branch 2 times, most recently from f6dd57d to e00baa1 Compare February 4, 2026 17:56
@okekefrancis112
Copy link
Author

All checks pass now. @TheBlueMatt and @joostjager


// intermediate node failure
let short_channel_id = channels[1].0.contents.short_channel_id;
let short_channel_id = route.paths[0].hops[1].short_channel_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is some independent refactoring/correctness improvement here that could go in a separate commit?

The commit that makes the actual change can then also contain the test changes/additions that it requires.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, I will work on it and get back to you. @joostjager

Copy link
Author

Choose a reason for hiding this comment

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

Hi @joostjager, I have made the fix and pushed. Can you help me review?

okekefrancis112 and others added 2 commits February 5, 2026 10:15
In onion failure tests, use the SCID from the actual route
(route.paths[0].hops[N].short_channel_id) instead of from the
channel announcement (channels[N].0.contents.short_channel_id).

This is more correct as tests should verify what actually happened
in the route, especially now that routes may use SCID aliases for
first hops while channel announcements contain real SCIDs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
With channel splicing, channels may spontaneously change their
on-chain short channel IDs (SCIDs) as new funding transactions are
created. However, SCID aliases remain stable across splices.

Change get_outbound_payment_scid() to prefer outbound_scid_alias
over short_channel_id (previously was the opposite). This ensures
first-hop routing uses stable identifiers that won't change when
channels are spliced.

Updated tests to reflect that:
- First hop uses the alias (from get_outbound_payment_scid)
- Subsequent hops use real SCIDs from network gossip

Closes lightningdevkit#3268

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@TheBlueMatt
Copy link
Collaborator

You don't need to tag people to ask for review so urgently. There's a lot going on on the project, you can hit the review request button and people will get to it when they have a chance.

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.

Prefer outbound SCID alias over real SCID when routing

4 participants