Skip to content

funding: enforce BOLT-02 push_msat bound on fundee#10765

Open
erickcestari wants to merge 1 commit intolightningnetwork:masterfrom
erickcestari:enforce-bolt02-push-msat-bound
Open

funding: enforce BOLT-02 push_msat bound on fundee#10765
erickcestari wants to merge 1 commit intolightningnetwork:masterfrom
erickcestari:enforce-bolt02-push-msat-bound

Conversation

@erickcestari
Copy link
Copy Markdown
Collaborator

Reject incoming OpenChannel messages where push_msat exceeds 1000 * funding_satoshis, as required by BOLT-02. The existing RejectPush flag only gates on push_msat > 0 and does not cover the spec bound.

An over-sized push is eventually caught downstream in reservation.go when theirBalance = capacity - fee - push_msat goes negative and ErrFunderBalanceDust is returned. Rejecting it up front produces a clearer, spec-aligned error and avoids the chanacceptor and commitment type negotiation round-trips for a channel we will refuse anyway.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the channel funding process by enforcing the BOLT-02 requirement regarding the maximum allowed push amount. By validating this constraint early in the OpenChannel message processing, the system avoids unnecessary downstream computations and provides more descriptive error messages when a peer attempts to open a channel with an invalid configuration.

Highlights

  • BOLT-02 Compliance: Implemented a strict check to ensure that incoming OpenChannel messages do not have a push_msat value exceeding 1000 times the funding_satoshis, as mandated by the BOLT-02 specification.
  • Improved Error Handling: Added a specific ErrPushAmountTooLarge error to provide clearer, spec-aligned feedback when a channel opening request is rejected due to an invalid push amount.
  • Test Coverage: Added a new test case TestFundingManagerPushAmountExceedsCapacity to verify that the funding manager correctly rejects tampered OpenChannel messages that violate the push amount bound.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label Apr 20, 2026
@github-actions
Copy link
Copy Markdown

PR Severity: CRITICAL -- Automated classification -- 2 files (excl. tests) -- 23 lines changed (excl. tests) -- funding/manager.go (CRITICAL: funding/) -- lnwallet/errors.go (CRITICAL: lnwallet/) -- funding/manager_test.go excluded (test file) -- No bump rules triggered -- Expert review warranted. <!-- pr-severity-bot -->

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enforces the BOLT-02 requirement that the push_msat value must be less than or equal to the total funding amount during channel opening. To support this, a new error ErrPushAmountTooLarge was added to the lnwallet package, and a corresponding unit test was implemented in the funding manager to ensure proper rejection of invalid requests. I have no feedback to provide as the existing comments were purely explanatory.

@saubyk saubyk added this to lnd v0.22 Apr 20, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 Apr 20, 2026
@saubyk saubyk moved this from Backlog to In progress in lnd v0.22 Apr 20, 2026
Reject incoming OpenChannel messages where push_msat exceeds
1000 * funding_satoshis, as required by BOLT-02. The existing RejectPush
flag only gates on push_msat > 0 and does not cover the spec bound.

An over-sized push is eventually caught downstream in reservation.go when
theirBalance = capacity - fee - push_msat goes negative and
ErrFunderBalanceDust is returned. Rejecting it up front produces a
clearer, spec-aligned error and avoids the chanacceptor and commitment
type negotiation round-trips for a channel we will refuse anyway.
@erickcestari erickcestari force-pushed the enforce-bolt02-push-msat-bound branch from 7545f7f to d95c1bc Compare April 20, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-critical Requires expert review - security/consensus critical

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants