2020-03-21 23:18:19 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# based on: https://github.com/rootzoll/raspiblitz/issues/1000
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "activate/deactivate LND keysend feature"
|
|
|
|
echo "lnd.keysend.sh [on|off|status]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-21 23:29:58 -07:00
|
|
|
# note: this script is not run during provision/recovery
|
|
|
|
# because if the lnd extra parameter is set in raspiblitz.conf,
|
|
|
|
# it will automatically be used by the service
|
|
|
|
|
2020-03-21 23:18:19 -07:00
|
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
|
|
|
|
parameter=$1
|
|
|
|
if [ "${parameter}" == "on" ]; then
|
|
|
|
|
|
|
|
# store to raspiblitz config (delete old line / add new)
|
|
|
|
sudo sed -i '/lndExtraParameter=.*/d' /mnt/hdd/raspiblitz.conf
|
2021-09-20 19:08:29 +02:00
|
|
|
sudo sed -i '/lndKeysend=.*/d' /mnt/hdd/raspiblitz.conf
|
2021-08-27 22:38:33 +02:00
|
|
|
echo "lndKeysend=on" >> /mnt/hdd/raspiblitz.conf
|
2020-03-21 23:18:19 -07:00
|
|
|
|
|
|
|
echo "# OK - keysend feature is switched ON"
|
2021-08-27 22:38:33 +02:00
|
|
|
echo "# will be enfored by lnd.check.sh prestart"
|
2020-03-21 23:43:01 -07:00
|
|
|
echo "# LND or RaspiBlitz needs restart"
|
2020-03-21 23:18:19 -07:00
|
|
|
|
|
|
|
elif [ "${parameter}" == "off" ]; then
|
|
|
|
|
|
|
|
# just remove the parameter from the config file
|
|
|
|
sudo sed -i '/lndExtraParameter=.*/d' /mnt/hdd/raspiblitz.conf
|
2021-08-27 22:38:33 +02:00
|
|
|
sudo sed -i '/lndKeysend=.*/d' /mnt/hdd/raspiblitz.conf
|
|
|
|
sudo sed -i '/accept-keysend=.*/d' /mnt/hdd/lnd/lnd.conf 2>/dev/null
|
|
|
|
sudo sed -i '/accept-keysend=.*/d' /mnt/hdd/lnd/tlnd.conf 2>/dev/null
|
|
|
|
sudo sed -i '/accept-keysend=.*/d' /mnt/hdd/lnd/slnd.conf 2>/dev/null
|
2020-03-21 23:18:19 -07:00
|
|
|
|
2021-08-27 22:38:33 +02:00
|
|
|
echo "# OK - keysend enforcement is switched OFF"
|
2020-03-21 23:43:01 -07:00
|
|
|
echo "# LND or RaspiBlitz needs restart"
|
2020-03-21 23:18:19 -07:00
|
|
|
|
|
|
|
elif [ "${parameter}" == "status" ]; then
|
|
|
|
|
2021-08-27 22:38:33 +02:00
|
|
|
keysendOn=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c '^lndKeysend=on')
|
|
|
|
keysendRunning=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c '^accept-keysend\=true')
|
2020-03-21 23:18:19 -07:00
|
|
|
echo "keysendOn=${keysendOn}"
|
|
|
|
echo "keysendRunning=${keysendRunning}"
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "err='unknown parameter'"
|
|
|
|
fi
|