Skip to content

Instantly share code, notes, and snippets.

@rizalrenaldi
Last active March 25, 2024 22:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rizalrenaldi/42331f5666bf6471be63072f7e2388c0 to your computer and use it in GitHub Desktop.
Save rizalrenaldi/42331f5666bf6471be63072f7e2388c0 to your computer and use it in GitHub Desktop.
My charge-lnd setup with Lightning Shell in Umbrel

I've tested this script and workflow on Umbrel, and it works. See resource/credit at the end.

1. SSH to Umbrel

ssh -t umbrel@umbrel.local, and login with your password

2. Create config/policy file

Read more about charge-lnd here.

First step is to create charge-lnd config/policy file charge-lnd.config, and put it in /mnt/data/umbrel/app-data/lightning-shell/data Type: sudo nano /mnt/data/umbrel/app-data/lightning-shell/data/charge-lnd.config (retype your password if asked on prompt) here's my config file for example

3. Make sure the config file works

On Umbrel, open Lightning Shell (install it first via Umbrel app store).
To check whether the syntax on your policy is valid, type: charge-lnd --config /data/charge-lnd.config --check if it return Configuration file is valid, your config file is ready to go.

additional step is to run --dry-run to test the policy without applying it, type: charge-lnd --config /data/charge-lnd.config --dry-run if it works, it will return one of your channels that adjusted based on your policy/config file.

4. Schedule it to automate using crontab

type cd ~, then crontab -e to create new cron file. In the editor, type: 0 * * * * (docker exec -u lnshell -w /home/lnshell lightning-shell_web_1 /home/lnshell/.local/bin/charge-lnd --config /data/charge-lnd.config) 2>&1 | logger -t charge-lnd to set it trigger every hour. Change the interval based on your need, learn more https://crontab.guru/

exit the editor by type ctrl + x, save it, and it will starts triggering every hour from now on.

5. Check the syslog, make sure it works

type: cd /var/log and then nano syslog. It will open nano editor, scroll down to recent log. If it works, you can see log item with title charge-lnd on it.


I combined snippets from these resources:
https://community.getumbrel.com/t/guide-installing-charge-lnd-in-a-docker-to-automate-your-fee-policies/2187
https://gist.github.com/msimion/e756bbe95426a91d7a0aa9912c7d0619
https://community.getumbrel.com/t/running-charge-lnd-with-cron-from-lnshell/6207/2

@jonathanalevi
Copy link

lightning-shell_web_1

This is wrong, at least on Citadel. It should be lightning-shell-web-1

@GalvaniObst
Copy link

Thanks - works on Umbrel

@adlernscs50
Copy link

I had a little problem in this route because a was with no permission to use docker commands, solution:

sudo usermod -aG docker <your_username>

disconnect the session then connect again

now working very well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment