Skip to content

lnwallet: improve ErrBelowChanReserve error message#10607

Open
Euler-B wants to merge 1 commit intolightningnetwork:masterfrom
Euler-B:issue-8957-reserve-error
Open

lnwallet: improve ErrBelowChanReserve error message#10607
Euler-B wants to merge 1 commit intolightningnetwork:masterfrom
Euler-B:issue-8957-reserve-error

Conversation

@Euler-B
Copy link

@Euler-B Euler-B commented Feb 24, 2026

Change Description

This PR modifies the ErrBelowChanReserve error message to provide more context to the user. Previously, the error only stated "commitment transaction dips peer below chan reserve", which could be slightly ambiguous for end users wondering why their logical balance was insufficient for a payment. By explicitly prepending "Cannot spend due to channel reserve:", it becomes immediately clear that the payment routing constraint is dictated by the channel reserve limit.

Fixes #8957.

Steps to Test

  1. Run the lnwallet test suite to ensure no regressions were introduced by the error string change:
   $ make unit pkg=lnwallet timeout=5m
  1. Attempt to send a payment or route an HTLC that would cause the local or peer's balance to dip below the required channel reserve constraint in a local cluster.
  2. Observe the returned error message via lncli or the RPC interface.
  3. Verify that the payment failure explicitly states: "Cannot spend due to channel reserve: commitment transaction dips peer below chan reserve".

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Euler-B, 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 focuses on enhancing user understanding by refining an existing error message. The change to ErrBelowChanReserve aims to eliminate ambiguity for end-users by clearly indicating that payment routing constraints are dictated by the channel reserve limit, thereby improving the diagnostic experience.

Highlights

  • Error Message Improvement: The ErrBelowChanReserve error message has been modified to provide clearer context to users. It now explicitly states "Cannot spend due to channel reserve:", making it immediately apparent why a payment might be insufficient.

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

Changelog
  • lnwallet/channel.go
    • Improved the ErrBelowChanReserve error message to provide more context to the user.
Activity
  • All CI checks have passed.
  • Tests covering both positive and negative (error paths) scenarios are included.
  • The change adheres to code style and documentation guidelines.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link

@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 improves an error message to be more user-friendly. The change is good, but I've suggested a more concise wording for the error message to avoid repetition and improve clarity even further.

Comment on lines 67 to 68
ErrBelowChanReserve = fmt.Errorf("Cannot spend due to channel " +
"reserve: commitment transaction dips peer below chan reserve")

Choose a reason for hiding this comment

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

medium

This improves the error message for users. To make it even more concise and avoid repeating the word 'reserve', consider rephrasing the entire message. The technical detail about the 'commitment transaction' might not be necessary for an end-user facing error.

Suggested change
ErrBelowChanReserve = fmt.Errorf("Cannot spend due to channel " +
"reserve: commitment transaction dips peer below chan reserve")
ErrBelowChanReserve = fmt.Errorf("cannot send payment: " +
"peer's balance would be below channel reserve")

This commit modifies the ErrBelowChanReserve error to provide more context to the user. It explicitly states that the lack of spendable balance is due to the channel reserve constraint.

Fixes issue lightningnetwork#8957
@Euler-B Euler-B force-pushed the issue-8957-reserve-error branch from 447dbee to 5e2dae7 Compare February 25, 2026 22:15
@lightninglabs-deploy lightninglabs-deploy added the severity-critical Requires expert review - security/consensus critical label Feb 25, 2026
@lightninglabs-deploy
Copy link
Collaborator

🔴 PR Severity: CRITICAL

Automated classification | 1 file | 4 lines changed

🔴 Critical (1 file)
  • lnwallet/channel.go - Core wallet/channel logic; falls under lnwallet/* which covers wallet operations, channel funding, signing, and commitment transactions

Analysis

This PR modifies lnwallet/channel.go, which is part of the lnwallet package — one of the most security-sensitive packages in lnd. The lnwallet package is responsible for wallet operations, channel funding, signing logic, and commitment transaction construction. Any change here, even a small one (this PR changes just 4 lines), warrants expert-level review due to the potential impact on fund safety and channel correctness.

The change is minimal in scope (2 additions, 2 deletions in a single file), which reduces risk, but the package classification alone mandates CRITICAL severity per policy.


To override, add a severity-override-{critical,high,medium,low} label.

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

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: More Descriptive Error on Attempted Spend from Reserve

2 participants