Skip to content

Conversation

Suvrat1629
Copy link

Change Description

This PR addresses issue #9155 by making error messages for lncli closechannel more actionable and less confusing:

  • When the mempool minimum fee is not met, the error now explains that a cooperative close transaction was created but not accepted, and suggests using lncli wallet bumpfee.
  • If a channel is already in the process of closing, the error now clearly states this and guides users to check lncli pendingchannels and use bumpfee if needed.
    All error strings follow Go style guidelines.

Steps to Test

  • Attempt to close a channel with a low fee and verify the new error message suggests bumpfee.
  • Try to close a channel that is already closing and confirm the error directs you to pendingchannels and bumpfee.

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.

… state

- Enhance user-facing error when mempool fee is too low, suggesting bumpfee usage.
- Add clear error when channel is already closing, guiding users to pendingchannels and bumpfee.
Copy link

Summary of Changes

Hello @Suvrat1629, 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 significantly enhances the user experience for lncli closechannel by providing more actionable and less confusing error messages. It addresses common scenarios where channel closure fails due to insufficient transaction fees or when a channel is already in a closing state, guiding users with clear instructions on how to proceed and resolve these issues.

Highlights

  • Improved Mempool Fee Error Message: The error message for lncli closechannel when the mempool minimum fee is not met now explicitly states that the cooperative close transaction was created but not accepted due to low fees, and suggests using lncli wallet bumpfee to resolve the issue.
  • Enhanced Channel Closing State Error: If a channel is already in the process of closing, the error message now clearly informs the user of this state and guides them to check lncli pendingchannels for status and use lncli wallet bumpfee if the transaction is unconfirmed.
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 error messages in lncli closechannel to be more actionable. The changes are good, but I have a couple of suggestions. In lnwallet/btcwallet/btcwallet.go, the new error message is too specific and assumes a cooperative close, which might not always be the case. I've suggested a more generic message. In rpcserver.go, there are some indentation issues and long error strings that could be improved for readability, following the repository's style guide.

errors.Is(err, chain.ErrMinRelayFeeNotMet):

return fmt.Errorf("%w: %v", lnwallet.ErrMempoolFee, err.Error())
return fmt.Errorf("%w: %v. The cooperative close transaction was created but not accepted into the mempool due to low fees. You may need to use 'lncli wallet bumpfee' to increase the fee and get the transaction confirmed", lnwallet.ErrMempoolFee, err.Error())

Choose a reason for hiding this comment

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

high

The new error message is specific to cooperative close transactions, but mapRpcclientError is a generic function that can be called for other transaction types as well. This could lead to confusing error messages for users. Consider making the message more generic.

Additionally, the error string is very long and should be split across multiple lines to improve readability, as per the style guide.1

return fmt.Errorf("%w: %v. The transaction was not accepted into the "+
	"mempool due to low fees. If this was a cooperative channel close, "+
	"you may need to use 'lncli wallet bumpfee' to get the transaction "+
	"confirmed", lnwallet.ErrMempoolFee, err.Error())

Style Guide References

Footnotes

Comment on lines +2852 to +2861
rpcsLog.Debugf("Trying to non-force close "+
"offline channel with chan_point=%v",
chanPoint)

return fmt.Errorf("unable to gracefully close "+
"channel while peer is offline (try "+
"force closing it instead): %v", err)
// Check if the channel is already closed or has a pending close tx.
if channel.HasChanStatus(channeldb.ChanStatusCoopBroadcasted) {
return fmt.Errorf("channel is already in the process of closing. Check 'lncli pendingchannels' for status. If the close transaction is not confirmed, you may need to use 'lncli wallet bumpfee'")
}

return fmt.Errorf("unable to gracefully close channel while peer is offline (try force closing it instead): %v", err)

Choose a reason for hiding this comment

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

medium

This new block of code has some indentation issues. The rpcsLog.Debugf call is not indented correctly, and the following if statement is over-indented. Additionally, the error messages are quite long. According to the style guide, long strings should be split to improve readability.1

				rpcsLog.Debugf("Trying to non-force close "+
					"offline channel with chan_point=%v",
					chanPoint)

				// Check if the channel is already closed or has a pending close tx.
				if channel.HasChanStatus(channeldb.ChanStatusCoopBroadcasted) {
					return fmt.Errorf("channel is already in the process of closing. " +
						"Check 'lncli pendingchannels' for status. If the close " +
						"transaction is not confirmed, you may need to use " +
						"'lncli wallet bumpfee'")
				}

				return fmt.Errorf("unable to gracefully close channel while peer "+
					"is offline (try force closing it instead): %v", err)

Style Guide References

Footnotes

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.

1 participant