Add lndk as a service option (#4320)

* Add script for starting/stopping lndk service
* Add lndk as a service option to the menu
This commit is contained in:
orbitalturtle 2024-02-14 13:00:14 -06:00 committed by GitHub
parent 168789c609
commit f67c8fd11c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 142 additions and 1 deletions

View file

@ -1,6 +1,6 @@
## What's new in Version 1.11.0 of RaspiBlitz?
- New: Enabling NVMe PCIe Hats
- New: RaspberryPi5 tested & enabling NVMe PCIe Hats
- Update: RaspberryOS base image 2023-12-05 (Debian 12 Bookworm)
- Update: amd64 base image: debian-12.5.0-amd64-netinst.iso
- Update: Bitcoin Core v26.0 [details](https://bitcoincore.org/en/releases/26.0/)
@ -17,6 +17,7 @@
- Update: Channel Tools (chantools) v0.12.0 [details](https://github.com/lightninglabs/chantools/releases/tag/v0.12.0)
- Update: LNbits 0.11.3 [details](https://github.com/lnbits/lnbits/releases/tag/0.11.3)
- Update: Circuitbreaker v0.5.1 [details](https://github.com/lightningequipment/circuitbreaker/blob/master/README.md)
- Experimental: LNDK (runs on top of LND to help forward onion messages (BOLT 12)) [details](https://github.com/lndk-org/lndk)
- Refactor: Wifi config with file on sd card
- Deprecated: Homer Dashboard (remove from SSH menus, config script will stay with possible future removal)
- Deprecated: Bitcoinminds (remove from SSH menus, config script will stay with possible future removal)

View file

@ -75,6 +75,7 @@ Further Services that are just available thru SSH menu (advanced users):
- **CL plugin: The Eye of Satoshi** (Watchtower) [details](https://github.com/talaia-labs/rust-teos/tree/master/watchtower-plugin)
- **Tallycoin Connect** (Use Tallycoin with your own node) [details](https://github.com/djbooth007/tallycoin_connect)
- **LNDg** (WebUI analyze/manage lnd with automation) [details](https://github.com/cryptosharks131/lndg)
- **LNDK** (runs on top of LND to help forward onion messages (BOLT 12)) [details](https://github.com/lndk-org/lndk)
You can connect the following Wallet-Apps to your RaspiBlitz (thru SSH menu):

View file

@ -108,6 +108,9 @@ fi
if [ "${loop}" == "on" ]; then
OPTIONS+=(LOOP "Loop In/Out Service")
fi
if [ "${lndk}" == "on" ]; then
OPTIONS+=(LNDK "LND BOLT 12 privacy")
fi
if [ "${mempoolExplorer}" == "on" ]; then
OPTIONS+=(MEMPOOL "Mempool Space")
fi
@ -271,6 +274,9 @@ case $CHOICE in
LNDMANAGE)
/home/admin/config.scripts/bonus.lndmanage.sh menu
;;
LNDK)
/home/admin/config.scripts/bonus.lndk.sh menu
;;
LIGHTNINGTIPBOT)
/home/admin/config.scripts/bonus.lightningtipbot.sh menu
;;

View file

@ -30,6 +30,7 @@ if [ ${#tallycoinConnect} -eq 0 ]; then tallycoinConnect="off"; fi
if [ ${#helipad} -eq 0 ]; then helipad="off"; fi
if [ ${#lightningtipbot} -eq 0 ]; then lightningtipbot="off"; fi
if [ ${#fints} -eq 0 ]; then fints="off"; fi
if [ ${#lndk} -eq 0 ]; then lndk="off"; fi
# show select dialog
echo "run dialog ..."
@ -66,6 +67,7 @@ if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
OPTIONS+=(xa 'LND Sphinx-Relay' ${sphinxrelay})
OPTIONS+=(fa 'LND Helipad Boostagram reader' ${helipad})
OPTIONS+=(da 'LND Tallycoin Connect' ${tallycoinConnect})
OPTIONS+=(lb 'LND LNDK (experimental BOLT 12)' ${lndk})
fi
# just available for CL
@ -500,6 +502,22 @@ else
echo "Tallycoin Setting unchanged."
fi
# LNDK
choice="off"; check=$(echo "${CHOICES}" | grep -c "lb")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${lndk}" != "${choice}" ]; then
echo "LNDK Setting changed .."
anychange=1
sudo -u admin /home/admin/config.scripts/bonus.lndk.sh ${choice}
if [ "${choice}" = "on" ]; then
whiptail --title " Installed LNDK" --msgbox "\
LNDK was installed.\n
" 10 45
fi
else
echo "LNDK Setting unchanged."
fi
# JoinMarket process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "ja")
if [ ${check} -eq 1 ]; then choice="on"; fi

View file

@ -0,0 +1,115 @@
#!/bin/bash
# https://github.com/lndk-org/lndk/releases/tag/v0.0.1
LNDKVERSION="v0.1.1"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch the LNDK Service on or off"
echo "installs the version $LNDKVERSION"
echo "bonus.lndk.sh [on|off|menu]"
exit 1
fi
# Switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# INSTALL LNDK"
lndkServicePath="/etc/systemd/system/lndk.service"
isInstalled=$(sudo ls $lndkServicePath 2>/dev/null | grep -c 'lndk.service')
if [ ${isInstalled} -eq 0 ]; then
# Install Rust for lndk, includes rustfmt
sudo -u bitcoin curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sudo -u bitcoin sh -s -- -y
# Clone and compile lndk onto Raspiblitz.
if [ ! -d "/home/bitcoin/lndk" ]; then
cd /home/bitcoin || exit 1
sudo -u bitcoin git clone https://github.com/lndk-org/lndk
cd /home/bitcoin/lndk || exit 1
sudo -u bitcoin git checkout tags/$LNDKVERSION -b $LNDKVERSION
sudo -u bitcoin /home/bitcoin/.cargo/bin/cargo build # Lndk bin will be built to /home/bitcoin/lndk/target/debug/lndk
fi
# LND needs the following configuration settings so lndk can run.
protocol=protocol
lnd_conf_file=/home/bitcoin/.lnd/lnd.conf
if grep $protocol $lnd_conf_file; then
echo "[protocol]
protocol.custom-message=513
protocol.custom-nodeann=39
protocol.custom-init=39
" | sudo tee -a $lnd_conf_file
fi
echo "[Unit]
Description=lndk Service
After=lnd.service
[Service]
ExecStart=/home/bitcoin/lndk/target/debug/lndk --address=https://localhost:10009 --cert=/mnt/hdd/lnd/tls.cert --macaroon=/mnt/hdd/lnd/data/chain/bitcoin/mainnet/admin.macaroon
User=bitcoin
Group=bitcoin
Type=simple
TimeoutSec=60
Restart=on-failure
RestartSec=60
StandardOutput=journal
StandardError=journal
LogLevelMax=4
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
" | sudo tee -a $lndkServicePath
sudo systemctl enable lndk
sudo systemctl start lndk
echo "OK - we've now started the LNDK service"
# Set value in raspiblitz config
/home/admin/config.scripts/blitz.conf.sh set lndk "on"
fi
exit 0
fi
# Show info menu
if [ "$1" = "menu" ]; then
whiptail --title " LNDK " --msgbox "Your node is now forwarding onion messages!\n
Check 'sudo systemctl status lndk' to see if it's running properly.\n
See more information about LNDK v0.0.1 here: https://github.com/lndk-org/lndk" 14 63
echo "please wait ..."
exit 0
fi
# Switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
isInstalled=$(sudo ls /etc/systemd/system/lndk.service 2>/dev/null | grep -c 'lndk.service')
if [ ${isInstalled} -eq 1 ]; then
echo "*** REMOVING LNDK ***"
# remove the systemd service
sudo systemctl stop lndk
sudo systemctl disable lndk
sudo rm /etc/systemd/system/lndk.service
sudo rm /home/bitcoin/lndk/target/debug/lndk
else
echo "# LNDK is not installed."
fi
# Set value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set lndk "off"
exit 0
fi
echo "FAIL - Unknown Parameter $1"
echo "may need reboot to run normal again"
exit 1