Automate routing fee

This guide will help you automate your lightning routing fees.

Note: We do this installation on a Umbrel node. To avoid our installation getting deleted after every Umbrel update, we install this software on our SSD instead of our microSD card.

Installation

1. Login using ssh

2. Create a directory on the SSD for the config file

mkdir ~/umbrel/apps/charge-lnd

3. Create a config file within the directory:

sudo nano ~/umbrel/apps/charge-lnd/charge.config

4. Populate the file with the rules you want, using the sample config file

You can change the rules at any time and add to them as you go along. If you need an explanation of how the parameters and rules work, here is a list of thdde parameters and their explanations.

Here is a config file example:

[default]
# 'default' is special, it is used if no other policy matches a channel
strategy = static
base_fee_msat = 0
fee_ppm = 97

[ignored_channels]
# don't let charge-lnd set fees (strategy=ignore) for channels to/from the specified nodes
node.id = 021c97a90a411ff2b10dc2a8e32de2f29d2fa49d41bfbb52bd416e460db0747d0d

strategy = ignore

[leafnode]
# charge non-routing (private=true) peers a bit more for our service
chan.private = true
strategy = static
fee_ppm = 150

[proportional]
# 'proportional' can also be used to auto balance (lower fee rate when low remote balance & higher rate when higher remote balance)
# fee_ppm decreases linearly with the channel balance ratio (min_fee_ppm when ratio is 1, max_fee_ppm when ratio is 0
strategy = proportional
min_fee_ppm = 50
max_fee_ppm = 250

5. Log in to Github using an access token so that you can pull docker repo directly from there:

Create an access token that you can use from your github account (create one if you don’t have one yet)

Go to Github -> settings-> Developer Settings -> Personal access tokens - Create a new one.

Create it and copy the password. Save it, because you won’t see it again.

Back in the command line, use this info to login to the registry

docker login https://docker.pkg.github.com/[http://docker.pkg.github.com/]

Type your Github username and generated token string as password.

Be sure you execute these commands in the right folder: ~/umbrel/apps/charge-lnd

Use cd umbrel/apps/charge-lnd to enter the folder.

Example:

umbrel@umbrel:~/umbrel/apps/charge-lnd $ docker login https://docker.pkg.github.com/[http://docker.pkg.github.com/]
Username: buidlbuidl
Password: 
WARNING! Your password will be stored unencrypted in /home/umbrel/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

You should see “Login succeeded”

6. Find the IP of your docker.

Run this command:

sudo nano ~/umbrel/.env

Find the line with LND_IP in it, and copy that IP address. Exit without saving.

7. Run the docker

The way charge-lnd works is by running the container "one time" - rather than keeping it open and alive persistently. This is different from other docker installations that Umbrel uses, but it doesn't matter. We can ask our Pi to run the docker from the files hosted on the web.

First, make sure that you are in the right directory


cd ~

Now, create the docker w/ the file you’ve already created as the config file.

docker run --rm -it --network=umbrel_main_network \
-e GRPC_LOCATION=LND.IP.ADDRESS.GOES.HERE:10009 \
-e LND_DIR=/data/.lnd \
-e CONFIG_LOCATION=/app/charge.config \
-v /home/umbrel/umbrel/lnd:/data/.lnd \
-v /home/umbrel/umbrel/apps/charge-lnd/charge.config:/app/charge.config \
accumulator/charge-lnd:latest

If everything works as expected, you’ll see a list of all of your channels, and the changes that have been made according to your rules / policies.

Check that you’re happy with how it’s applying rules.

If not, go ahead and edit the charge.config file on your hard disk that we created, then run the above “run” command again.

8. Now, Automate it!

Once you’re happy with everything, you can optionally set up a “crontab” job to automatically run this command every X minutes or hours.

Simply type:

crontab -e

The system will create a new crontab file, since none exists.

In this file, you can put the following, all on one line:

Again, don't forget to edit the script with your own LND IP.

0 * * * * docker run --rm --network=umbrel_main_network  -e GRPC_LOCATION=YOUR.LND.IP.ADDRESS:10009 -e LND_DIR=/data/.lnd -e CONFIG_LOCATION=/app/charge.config -v /home/umbrel/umbrel/lnd:/data/.lnd  -v /home/umbrel/umbrel/apps/charge-lnd/charge.config:/app/charge.config accumulator/charge-lnd:latest

This will run your charge-lnd script once every hour. This is the maximum recommended frequency by charge-lnd, as running it more frequently can result in failed routes or other confusion and chatter on the network.

If you wish to run it more/less frequently, that's up to you, and you can find the instructions for changing the 0 * * * * part of the command above here: https://crontab.guru

That's all!

If you've followed the steps above correctly, everything should work just fine, and update your routing policies every hour on the hour.

Tip creators using @LNTXBot👇

/tip 100 @stocktoflow
/tip 100 @The_Lorax_LN
/tip 100 @jorijn
/tip 100 @yuvadm

Resources:

Setup routing fee

Automate routing fee

Last updated

Was this helpful?