lncli: reject negative sat_per_vbyte in close/open channel commands (fixes #9834)#10663
Conversation
The --sat_per_vbyte flag was declared as cli.Int64Flag, allowing negative values. When read via ctx.Uint64(), negative values silently wrapped to very large uint64 values (e.g., -1 → 18446744073709551615), producing absurdly high fee rates without any error. This was reported in lightningnetwork#9834 where `lncli closechannel --sat_per_vbyte=-1` silently initiated a close with a massive fee rate. Change the flag type from cli.Int64Flag to cli.Uint64Flag in: - closeChannelCommand - closeAllChannelsCommand - openChannelCommand - batchOpenChannelCommand urfave/cli rejects negative values at parse time for Uint64Flag, preventing the silent wrap-around entirely. Fixes lightningnetwork#9834 Storm Knight <storm-knight@openclaw.ai>
Summary of ChangesHello, 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 addresses a critical issue where negative fee rate inputs for channel operations could lead to unintended and excessively high transaction fees. By correctly typing the Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request updates the sat_per_vbyte flag type from cli.Int64Flag to cli.Uint64Flag for the openChannelCommand, batchOpenChannelCommand, closeChannelCommand, and closeAllChannelsCommand. This change correctly represents fee values as unsigned integers. There is no feedback to provide.
|
@ThomsenDrake, remember to re-request review from reviewers when ready |
|
@saubyk As requested by the CI bot — re-requesting your review on this PR when you have a moment. The change is minimal (Int64Flag → Uint64Flag for fee rate inputs) and addresses issue #9834 which is assigned to you. Changes:
All existing tests pass. The Gemini Code Assist bot review found no issues. |
Fixes #9834
Problem
The
--sat_per_vbyteflag was declared ascli.Int64Flagbut read viactx.Uint64(), causing negative values to wrap to huge positive numbers (e.g.,-1becomes2^63 - 1). This affects four commands:lncli closechannellncli closeallchannelslncli openchannellncli batchopenchannelA user passing
--sat_per_vbyte=-1would get a transaction with an absurdly high fee rate instead of an error.Fix
Changed
cli.Int64Flag→cli.Uint64Flagforsat_per_vbytein all four commands. Theurfave/clilibrary rejects negative values at parse time when the flag isUint64, producing a clear error message.Testing
urfave/cliUint64Flagrejects negative inputs with "invalid value "-1" for flag -sat_per_vbyte: parse error"Files Changed
cmd/commands/cmd_open_channel.go(2 changes: openchannel + batchopenchannel)cmd/commands/commands.go(2 changes: closechannel + closeallchannels)