Skip to content

Conversation

@kunal-595
Copy link

fixes #1411
Adds a toggle to switch between percentage and PPM input for fee rate when setting channel fees. Only shows for LND-based backends since CLN already uses PPM natively

Copilot AI review requested due to automatic review settings January 24, 2026 10:18
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kunal-595, 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 improves the user experience for setting channel fees by introducing a flexible input mechanism. Users can now choose to specify fee rates in either traditional percentages or the more granular Parts Per Million (PPM), a common unit in the Lightning Network. This enhancement is specifically tailored for LND-based backends, providing a more intuitive and aligned interface for managing channel liquidity.

Highlights

  • Enhanced Fee Input: Introduced a toggle to switch between percentage and Parts Per Million (PPM) input for channel fee rates, providing more flexibility for users.
  • LND-Specific Functionality: The PPM toggle is exclusively displayed for LND-based backends, as CLN (c-lightning) already handles PPM natively, streamlining the interface for relevant users.
  • Dynamic UI Updates: The fee rate input field's placeholder and label dynamically adjust to reflect the currently selected fee rate mode (percentage or PPM), improving user clarity.
  • Backend Conversion Logic: The FeeStore now includes logic to convert PPM values to percentages before sending them to LND, ensuring correct fee application and compatibility.
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
Contributor

@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 adds a useful toggle for setting channel fees in either percentage or PPM for LND-based backends. The implementation is mostly correct, but a critical issue in the fee rate conversion logic was found that would lead to incorrect and excessively high fees being set. The detailed comment provides the fix.

Comment on lines 152 to 155
// convert PPM to percentage for LND
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased()) {
feeRate = new BigNumber(feeRate).dividedBy(10000).toString();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The conversion from PPM to the decimal fee rate for LND is incorrect. You are dividing by 10000, but it should be 1000000 to convert from Parts Per Million to a decimal rate.

For example, a 1000 PPM fee rate should be converted to 0.001 for the LND API. Your current implementation would convert it to 0.1, which is 100x larger and would result in a 10% fee, which is extremely high.

The comment is also a bit misleading. It's not converting to a percentage, but rather to a decimal fee rate that LND expects.

Here is the suggested correction:

Suggested change
// convert PPM to percentage for LND
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased()) {
feeRate = new BigNumber(feeRate).dividedBy(10000).toString();
}
// convert PPM to decimal rate for LND
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased()) {
feeRate = new BigNumber(feeRate).dividedBy(1000000).toString();
}

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a toggle to switch between percentage and PPM (parts per million) input modes for channel fee rates when setting fees. The toggle is only displayed for LND-based backends since Core Lightning (CLN) natively uses PPM units.

Changes:

  • Added PPM to percentage conversion logic in the fee store
  • Implemented a toggle button UI component to switch between percentage and PPM input modes
  • Updated labels and placeholders to reflect the selected unit mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
stores/FeeStore.ts Added feeRateMode parameter and PPM-to-percentage conversion logic for LND backends
components/SetFeesForm.tsx Added toggle button UI, updated labels/placeholders based on mode, and integrated mode selection with fee submission

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let feeRate = newFeeRate.replace(/,/g, '.');

// convert PPM to percentage for LND
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased()) {
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The conversion from PPM to percentage should handle empty or invalid input strings. When feeRate is an empty string, calling new BigNumber(feeRate) will throw an error. Consider adding a check to only perform the conversion when feeRate is non-empty: if (feeRateMode === 'ppm' && BackendUtils.isLNDBased() && feeRate) {

Suggested change
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased()) {
if (feeRateMode === 'ppm' && BackendUtils.isLNDBased() && feeRate) {

Copilot uses AI. Check for mistakes.
@kaloudis
Copy link
Contributor

I think we'd want to set up some sort of utility for this in FeeUtils with corresponding tests

@kunal-595
Copy link
Author

Sounds good, i will move that PPM → % logic into FeeUtils, add some unit tests, and update the store, pushing shortly.

@kaloudis
Copy link
Contributor

Looking mostly solid so far. Even if CLNRest uses PPM by default, you should be able to toggle between the two modes with it.

I think the next step after that would be being able to toggle between the units on the FeeBreakdown component

@kunal-595
Copy link
Author

That makes sense, i will hook that up in FeeBreakdown so users can switch modes on the fly, i will ping you here once i have pushed the update to the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PPM for channel fees

2 participants