Skip to main content Link Search Menu Expand Document (external link)

Bonus guide: regolancer


regolancer simple LND rebalancer written in Go.

Difficulty: Easy

Status: Tested v3

regolancer


Table of contents

  1. Requirements
  2. Install Go
  3. Install regolancer
  4. Configuration
  5. First run
  6. Upgrade
  7. Uninstall

Requirements

  • LND
  • Go

Install Go

  • To install Go follow the instructions provided in the bonus guide.

Install regolancer

  • With user “admin”, create a new user “regolancer” and make it a member of the “lnd” group

    $ sudo adduser --disabled-password --gecos "" regolancer
    $ sudo adduser regolancer lnd
    
  • With the “regolancer” user map the LND folder and install the program

    $ sudo su - regolancer
    
    $ ln -s /data/lnd /home/regolancer/.lnd
    
    $ GOARCH=arm64 go install github.com/rkfg/regolancer@latest
    
  • Confirm installed version

    $ go/bin/regolancer -v
    Regolancer v1.9.0, built with go1.19.2
    Source: https://github.com/rkfg/regolancer
    
  • Create a working copy of the sample config file. You can use either .json or .toml configs, up to your preference.

    $ cp /home/regolancer/go/pkg/mod/github.com/rkfg/regolancer@v1.9.0/config.json.sample /home/regolancer/config.json
    

    Note: Adjust the “regolancer@v1.9.0” part from this commands to the actual version you have installed.

  • Make the newly created config.json file writable.

    $ chmod 644 /home/regolancer/config.json
    

Configuration

  • Edit the config file and make sure you have the following changes in the beginning.

    $ nano /home/regolancer/config.json
    
    "macaroon_dir": "/home/regolancer/.lnd/data/chain/bitcoin/mainnet/",
    "macaroon_filename": "admin.macaroon",
    "network": "mainnet",
    "tlscert": "/home/regolancer/.lnd/tls.cert",
    

Adjust the rest of the file as you wish with the options regolancer config sample provides, save, and exit.


First run

  • Run the Rebalancer (while in “regolancer” user session)

    $ go/bin/regolancer -f /home/regolancer/config.json
    

The regolancer will run until it finds a hit and will stop after that unless you have utilized the “–allow-rapid-rebalance” parameter, which will retry the same rebalance instantly until a fail. To run it continuously, you will need to run it in a loop or a cron.


Upgrade

  • From user “admin”, open a “regolancer” user session and run the install script.

    $ sudo su - regolancer
    $ go install github.com/rkfg/regolancer@latest
    
  • Confirm if the upgrade was successfull

    $ go/bin/regolancer -v
    Regolancer v1.9.0, built with go1.19.2
    Source: https://github.com/rkfg/regolancer
    

Uninstall

  • If you want to uninstall regolancer, delete the “regolancer” user with the “root” user.

    $ userdel -r regolancer
    

Don’t forget to remove any cronjobs or screens you may have set up in other users.