Skip to content

Make splice fee ceiling calculation overflow-safe - #1237

Open
elnafateh wants to merge 1 commit into
lightningdevkit:mainfrom
elnafateh:fix/splice-feerate-overflow
Open

elnafateh wants to merge 1 commit into
lightningdevkit:mainfrom
elnafateh:fix/splice-feerate-overflow

Conversation

@elnafateh

Copy link
Copy Markdown
Contributor

Problem

The splice fee ceiling uses unchecked multiplication. Extreme caller-supplied fee rates can overflow it, causing debug builds to panic and release builds to calculate an invalid ceiling.

Fix

Calculate the 1.5× ceiling using saturating arithmetic. Normal rates keep the same ceiling; unrepresentable results clamp to FeeRate::MAX. Add boundary coverage for rates above the multiplication limit and FeeRate::MAX.

  • Added two focused fee-estimator tests

@ldk-reviews-bot

ldk-reviews-bot commented Nov 16, 2026 •

Copy link
Copy Markdown

I've assigned @tnull 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.

@ajaysehwal ajaysehwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@elnafateh This looks like a local draft of the PR description that got committed by accident. Could you drop it from the commit?

Comment thread src/fee_estimator.rs Resolved
Comment thread src/fee_estimator.rs Resolved

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not quite sure this is worth fixing honestly, as the splicing API does assume the caller is trusted (they can otherwise mess with us in various other ways). That said, fine to switch to saturating arithmetic, but let's not add more than the 1-2 line diff.

Comment thread src/fee_estimator.rs Resolved
@elnafateh
elnafateh force-pushed the fix/splice-feerate-overflow branch from a77e5ba to b839bad Compare November 17, 2026 11:25
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.

4 participants