event icon indicating copy to clipboard operation
event copied to clipboard

feat: Circular Rebalance of channels

Open cherry-1729-9090 opened this issue 6 months ago • 1 comments

Description

Circular Rebalance

Lightning Network channel rebalancing tool that allows users to redistribute liquidity between their own channels by creating a circular payment from a source channel to a destination channel.

Helps Lightning node operators optimize channel liquidity by moving funds from channels with excess outbound capacity to channels needing more outbound liquidity, improving payment routing success rates and fee earning potential.

Technical Implementation:

  • Creates invoice on destination channel
  • Executes payment from source channel with allow_self_payment enabled
  • Uses last_hop_pubkey to ensure payment routes through destination channel
  • Supports configurable fee limits and timeout

Please find the demo of the circular rebalance implementation over here : https://drive.google.com/file/d/1SKCE7l5bJShQld-ZyVS-RxGsMHrqnpYt/view?usp=drive_link

Relates to issue: #2157

This pull request is categorized as a:

  • [x] New feature
  • [ ] Bug fix
  • [ ] Code refactor
  • [ ] Configuration change
  • [x] Locales update
  • [ ] Quality assurance
  • [ ] Other

Checklist

  • [x] I’ve run yarn run tsc and made sure my code compiles correctly
  • [x] I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • [ ] I’ve run yarn run prettier and made sure my code is formatted correctly
  • [x] I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • [ ] No, I’m a fool
  • [ ] Yes
  • [x] N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • [x] Android
  • [ ] iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • [ ] Embedded LND
  • [x] LND (REST)
  • [ ] LND (Lightning Node Connect)
  • [ ] Core Lightning (CLNRest)
  • [ ] Nostr Wallet Connect
  • [ ] LndHub

Locales

  • [ ] I’ve added new locale text that requires translations
  • [ ] I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • [ ] Contributors will need to run yarn after this PR is merged in
  • [ ] 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • [ ] Changes were made that require an update to the README
  • [ ] Changes were made that require an update to onboarding

cherry-1729-9090 avatar May 29 '25 17:05 cherry-1729-9090

Let's move the link off the Channels list view and under Menu > Tools

kaloudis avatar Jun 01 '25 23:06 kaloudis

Can we also have a separate view to show successful rebalances? Maybe something that displays the amount rebalanced and the channels involved.

shubhamkmr04 avatar Jul 07 '25 09:07 shubhamkmr04

We still want to allow source and dest picking. Disabling channels based on direction and 0 amounts does make sense. Recording rebalance history is also a good idea.

kaloudis avatar Jul 07 '25 15:07 kaloudis

please check so many locales are not defined in here

shubhamkmr04 avatar Aug 14 '25 08:08 shubhamkmr04

Screenshot 2025-08-21 at 12 32 22 PM

The white 'Rebalance Amount:' text here is hard to read. Have the color match the color of the amount.

kaloudis avatar Aug 21 '25 16:08 kaloudis

@cherry-1729-9090 can you please test against embedded LND, LNC, and CLNRest and update the PR description with them once you do?

kaloudis avatar Aug 25 '25 23:08 kaloudis

Having some issues rebalancing with CLNRest in my tests. The self-payment is successful but it's not landing in the destination channel.

kaloudis avatar Aug 25 '25 23:08 kaloudis

When we hit Try Again after a failed rebalance, it would be nice to have all the fields still populated with the values you originally set.

kaloudis avatar Aug 25 '25 23:08 kaloudis

When we hit Try Again after a failed rebalance, it would be nice to have all the fields still populated with the values you originally set.

Hmm, sometimes this holds true, but other times it doesn't. Maybe my dev env or is it dependent on which error you hit?

EDIT: at least on LND REST, timeout errors clear the form, whereas insufficient balance errors do not.

kaloudis avatar Aug 25 '25 23:08 kaloudis

Have we done any further testing of CLN rebalancing? If it's not reliable, we should undo the changes for it and disable the functionality.

Curious to hear results from more thorough testing.

kaloudis avatar Sep 09 '25 15:09 kaloudis

Have we done any further testing of CLN rebalancing? If it's not reliable, we should undo the changes for it and disable the functionality.

Curious to hear results from more thorough testing.

I have implemented the CLN rebalancing changes and tested the functionality - the amount transfers between channels are working as expected.

cherry-1729-9090 avatar Sep 17 '25 10:09 cherry-1729-9090

@cherry-1729-9090 The "Rebalance Amount" text color is still not updated; it should match the amount color.

Screenshot 2025-10-27 at 12 42 24 PM

ajaysehwal avatar Oct 27 '25 07:10 ajaysehwal

tACK

ajaysehwal avatar Oct 30 '25 06:10 ajaysehwal