/bash-rebalancer

Rebalancing Channels on Lightning can be intimidating, or laboursome, or both. This light bash-script should allow some guidance with a menu, and allows up to 7 channels per run to be handed over to the rebalance-lnd script

Primary LanguageShellMIT LicenseMIT

bash-rebalancer

With bash-rebalancer as a wrapper, you can use Carsten Otto's rebalance-lnd with > more than one channel in a batch system. It'll allow to add a bunch of channels when calling the script, and then a menu will guide you through the next steps.

The prerequisits are

Optional but helpful to retrieve the right channels to rebalance

Key Feature Set

  • Add more than one channel to rebalance
  • Incrementally start the ratio to rebalance with 10%, 30%, 50%, 70% and remainder ratio to rebalance
  • For < 2M sats channels, the script will strive to achieve a 50:50 ratio. For > 2M Channel size, it'll aim to get 1M at either side
  • Alternatively, it allows to set a fixed amount of satoshis, and tries that amount divided into a set amount of attempts for every selected channel
  • Allows a PPM-limit ceiling for Fee-Factor, to avoid rebalancing high PPM sets by charge-lnd
  • Offers 'Reckless'-Mode, ignoring profitability settings

Installation

$ git clone https://github.com/TrezorHannes/bash-rebalancer
$ nano bash-rebalancer/my_rebalancer.sh
  1. In case not successfully identifying your LND directory, add a direct link in the header
  2. If your rebalance-lnd directory isn't stored in $HOME (~/rebalance-lnd/), add a direct link in the header, too

Syntax for one channel

$ ./bash-rebalancer/my_rebalancer.sh -j cidxxxxxxxxxxxxxxx

Syntax for one channel, excluding another

$ ./bash-rebalancer/my_rebalancer.sh -j cidxxxxxxxxxxxxxxx -e cidxxxxxxxxxxxxxxx This command will try one specific channel (j).

Syntax for more than one channel

$ ./bash-rebalancer/my_rebalancer.sh -j cidxxxxxxxxxxxxxxx -k cidxxxxxxxxxxxxxxx -l cidxxxxxxxxxxxxxxx -m cidxxxxxxxxxxxxxxx -n cidxxxxxxxxxxxxxxx -o cidxxxxxxxxxxxxxxx This command will try to rebalance for 6 different channels (j-o).

Syntax for one channel, excluding another, dividing your fixed amount of rebalances into 15 chunks

$ ./bash-rebalancer/my_rebalancer.sh -j cidxxxxxxxxxxxxxxx -e cidxxxxxxxxxxxxxxx -c 15 smaller chunks = higher probability of success

Attributes

  - Fee-Setting
  - Direction push (👉) outbound or pull (👈) inbound liquidity
  - -j Single channel ID of first and required channel
  - -k to -p arguments allow for passing additional optional channels to rebalance
  - -e exclude a specific channel ID. Only one ID is allowed at this point
  - -c allows for specifying how many chunks your total amount of satoshis are divided into
  - Specify Automated or Defined Amount to be rebalanced

Hints

  1. Since the process is going to take a long time, pending the number of channels you like to rebalance, it's generally advised to run the bash script via TMUX.
  2. Get a list of target rebalancing channels with $ lndmanage listchannels rebalance before-hand, and identify the top 1-7 with too much outbound or too much inbound by hand
  3. Focus on the channels with reasonable fee-settings. When you use charge-lnd, you may have channels with extra-ordinary high or low pricing to dis- or encourage balancing. Fee-Factor for those channels can have undersirable side-effects (too high or too low ppm).

Contribution

Please feel free to help this getting better, issues and pull requests @ https://github.com/TrezorHannes/bash-rebalancer I'm always grateful for inbound, feel free to connect or message me for a joined channel opening:

HODLmeTight: