GUIDE: Setting up dynamic fees with charge-lnd

Place for guides, manuals and other tips.
Post Reply
User avatar
Wiredancer
Jr. Member
Posts: 81
Joined: 28 Aug 2021, 05:01
Location: New Zealand
URL: https://lntxbot.com/@wiredancer
Contact:

GUIDE: Setting up dynamic fees with charge-lnd

Post by Wiredancer »

Charge-lnd is great tool which will allow you for automatic fee adjustment given the criteria you set up in the .conf file. It is great for proportional balancing of your channel depending on where the sats are. I highly recommend everyone to set it up as it will make your life much easier!

This setup has been tested on Raspi 4B 8GB ramm with myNode 0.2.41, but will likely work well independent on the version.

Lets get to it!

1. Login to your terminal.

Code: Select all

ssh admin@mynode.local or ssh admin@your.node.ip.address
(if you are using windows you can use putty to login to your node)

2. Switch to Bitcoin user for installation of charge-lnd.

Code: Select all

sudo su - bitcoin
3. Download charge-lnd.

Code: Select all

git clone https://github.com/accumulator/charge-lnd.git
4. Create macaroon (application key) authorizing charge-lnd to adjust your node.

Code: Select all

lncli bakemacaroon offchain:read offchain:write onchain:read info:read --save_to=~/.lnd/data/chain/bitcoin/mainnet/charge-lnd.macaroon
5. Move to the directory of charge-lnd.

Code: Select all

cd charge-lnd
6. Install setuptools to let you install other packages.

Code: Select all

pip install -U setuptools
7. Build and install charge-lnd on your node.

Code: Select all

pip install -r requirements.txt .
8. Test that charge-lnd is working.

Code: Select all

/home/bitcoin/.local/bin/charge-lnd -h
Output should show you options and arguments of charge-lnd. Should look like this:
Image

If you see this your charge-lnd is installed correctly and we can continue.

9. Exit bitcoin user and create default config file.

Code: Select all

exit
sudo nano /home/bitcoin/charge-lnd/charge.config
10. Use the editor to create your fee policies. This is the file where you will return often to tweak your policies.
You could use something like this for start:

Code: Select all

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

[proportional]
chan.min_ratio = 0.1
chan.max_ratio = 0.9
strategy = proportional
min_fee_ppm = 100
max_fee_ppm = 1000
# '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)

For complete list of charge-lnd policies please see this example and REadme

11. Once you have your policies ready you can try to run --dry-run (doesn't actually apply changes) and see how your fees would be changed.

Code: Select all

sudo -u bitcoin /home/bitcoin/.local/bin/charge-lnd -c /home/bitcoin/charge-lnd/charge.config --dry-run
12. After you run dry run and you are happy with the result you can run the command without --dry-run and changes will apply to your node.

Code: Select all

sudo -u bitcoin /home/bitcoin/.local/bin/charge-lnd -c /home/bitcoin/charge-lnd/charge.config 
13. Last thing we have to do is schedule the process to run every few hours to keep your fees updated. Log back to user bitcoin.

Code: Select all

sudo su bitcoin
14. Enter cron task list.

Code: Select all

crontab -e
15. Add the task to the end of the file for cron to run every two hours. You can change the interval by changing */2 to other intervals */1 for one hour etc..

Code: Select all

0 */2 * * * /home/bitcoin/.local/bin/charge-lnd -c /home/bitcoin/charge-lnd/charge.config
In order to not spam lightning network you should not change the fees more other than about once an hour. For more detailed setting of your cron interval please check crontab.guru
Save and done!

Congratulation! Your node is now adjusting fees automatically.
Please make sure you still check your fees for couple of days before you are sure all your settings are correct to avoid errors leading in bad fee settings.

If you find any mistakes or something not working correctly please let me know and I will do my best to correct.
Hope you will find this useful.
LNG

original article: https://nullcount.com/install-charge-ln ... autopilot/
Did you find my post helpful?
Why not send me few sats?
:arrow: Get LN QR code.
Happy routing!
Post Reply