2021-08-04 00:18:30 +02:00
#!/bin/bash
2021-12-17 21:43:19 +01:00
# "*** LND ***"
## based on https://raspibolt.github.io/raspibolt/raspibolt_40_lnd.html#lightning-lnd
## see LND releases: https://github.com/lightningnetwork/lnd/releases
## !!!! If you change here - make sure to also change interims version in lnd.update.sh !!!
2022-05-10 08:34:30 +01:00
lndVersion = "0.14.3-beta"
2021-12-17 21:43:19 +01:00
# olaoluwa
# PGPauthor="roasbeef"
# PGPpkeys="https://keybase.io/roasbeef/pgp_keys.asc"
# PGPcheck="E4D85299674B2D31FAA1892E372CBD7633C61696"
# guggero
PGPauthor = "guggero"
PGPpkeys = "https://keybase.io/guggero/pgp_keys.asc"
PGPcheck = "F4FC70F07310028424EFC20A8E4256593F177720"
# bitconner
#PGPauthor="bitconner"
#PGPpkeys="https://keybase.io/bitconner/pgp_keys.asc"
#PGPcheck="9C8D61868A7C492003B2744EE7D737B67FA592C7"
2021-08-04 00:18:30 +02:00
# command info
2021-12-07 14:00:44 +00:00
if [ $# -eq 0 ] || [ " $1 " = "-h" ] || [ " $1 " = "-help" ] ; then
2021-08-04 00:18:30 +02:00
echo
echo "Install or remove LND services on parallel chains"
2021-12-07 14:00:44 +00:00
echo "lnd.install.sh install - called by the build_sdcard.sh"
2022-01-12 14:03:18 +01:00
echo "lnd.install.sh info [?compareVersion]"
2021-09-12 22:36:57 +02:00
echo "lnd.install.sh on [mainnet|testnet|signet] [?initwallet]"
echo "lnd.install.sh off [mainnet|testnet|signet]"
echo "lnd.install.sh display-seed [mainnet|testnet|signet] [?delete]"
2021-08-04 00:18:30 +02:00
echo
exit 1
fi
2021-12-14 23:34:35 +01:00
source <( /home/admin/_cache.sh get network)
if [ " ${ network } " = = "" ] ; then
network = "bitcoin"
fi
2022-01-12 14:03:18 +01:00
if [ " $1 " = "info" ] ; then
2022-02-12 11:10:38 +01:00
2022-01-12 14:03:18 +01:00
# the version that this script installs by default
echo " lndDefaultInstallVersion=' ${ lndVersion } ' "
# the version that is installed
lndInstalledVersion = $( sudo -u admin lnd --version 2>/dev/null | cut -d " " -f3)
echo " lndInstalledVersion=' ${ lndInstalledVersion } ' "
# if a version string is given as second optional parameter - check update compatibility
# assumption: if the available version is one miner version lower then asked data is not compatible
compareVersion = $2
if [ " ${ compareVersion } " != "" ] ; then
# use version thats either installed or can be installed
availableVersion = " ${ lndInstalledVersion } "
if [ " ${ availableVersion } " = = "" ] ; then
availableVersion = " ${ lndVersion } "
fi
# check major & miner version value
availableMajor = $( echo ${ availableVersion } | cut -d "." -f1 | grep -o '[[:digit:]]*' | tail -n 1)
compareMajor = $( echo ${ compareVersion } | cut -d "." -f1 | grep -o '[[:digit:]]*' | tail -n 1)
availableMiner = $( echo ${ availableVersion } | cut -d "." -f2 | grep -o '[[:digit:]]*' | tail -n 1)
compareMiner = $( echo ${ compareVersion } | cut -d "." -f2 | grep -o '[[:digit:]]*' | tail -n 1)
#echo "# ${availableMajor} ${compareMajor} ${availableMiner} ${compareMiner}"
if [ " ${ compareMajor } " != "" ] && [ " ${ compareMiner } " != "" ] ; then
# check major
if [ ${ availableMajor } -lt ${ compareMajor } ] ; then
echo "compatible=0"
else
if [ ${ availableMiner } -lt ${ compareMiner } ] ; then
echo "compatible=0"
else
echo "compatible=1"
fi
fi
fi
fi
exit 0
fi
2021-12-07 14:00:44 +00:00
if [ " $1 " = "install" ] ; then
2021-12-17 21:43:19 +01:00
echo " # *** INSTALL LND ${ lndVersion } BINARY *** "
echo "# only binary install to system"
echo "# no configuration, no systemd service"
# check if lnd binary is already installed
if [ $( sudo -u admin lnd --version 2>/dev/null| grep -c 'lnd' ) -gt 0 ] ; then
echo "lnd binary already installed - done"
exit 1
fi
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
# get LND resources
cd /home/admin/download || exit 1
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
# download lnd binary checksum manifest
sudo -u admin wget -N https://github.com/lightningnetwork/lnd/releases/download/v${ lndVersion } /manifest-v${ lndVersion } .txt
# check if checksums are signed by lnd dev team
sudo -u admin wget -N https://github.com/lightningnetwork/lnd/releases/download/v${ lndVersion } /manifest-${ PGPauthor } -v${ lndVersion } .sig
sudo -u admin wget --no-check-certificate -N -O "pgp_keys.asc" ${ PGPpkeys }
gpg --import --import-options show-only ./pgp_keys.asc
2022-02-12 11:10:38 +01:00
fingerprint = $( sudo gpg --show-keys "pgp_keys.asc" 2>/dev/null | grep " ${ PGPcheck } " -c)
2021-12-07 14:00:44 +00:00
if [ ${ fingerprint } -lt 1 ] ; then
echo ""
echo "!!! BUILD WARNING --> LND PGP author not as expected"
echo " Should contain PGP: ${ PGPcheck } "
echo "PRESS ENTER to TAKE THE RISK if you think all is OK"
read key
fi
gpg --import ./pgp_keys.asc
sleep 3
verifyResult = $( gpg --verify manifest-${ PGPauthor } -v${ lndVersion } .sig manifest-v${ lndVersion } .txt 2>& 1)
goodSignature = $( echo ${ verifyResult } | grep 'Good signature' -c)
echo " goodSignature( ${ goodSignature } ) "
correctKey = $( echo ${ verifyResult } | tr -d " \t\n\r" | grep " ${ PGPcheck } " -c)
echo " correctKey( ${ correctKey } ) "
if [ ${ correctKey } -lt 1 ] || [ ${ goodSignature } -lt 1 ] ; then
echo
echo " !!! BUILD FAILED --> LND PGP Verify not OK / signature( ${ goodSignature } ) verify( ${ correctKey } ) "
exit 1
else
echo
echo "********************************************"
echo "OK --> THE LND MANIFEST SIGNATURE IS CORRECT"
echo "********************************************"
echo
fi
# get the lndSHA256 for the corresponding platform from manifest file
if [ " $( uname -m | grep -c 'arm' ) " -gt 0 ] ; then
lndOSversion = "armv7"
lndSHA256 = $( grep -i " linux- $lndOSversion " manifest-v$lndVersion .txt | cut -d " " -f1)
elif [ " $( uname -m | grep -c 'aarch64' ) " -gt 0 ] ; then
lndOSversion = "arm64"
lndSHA256 = $( grep -i " linux- $lndOSversion " manifest-v$lndVersion .txt | cut -d " " -f1)
elif [ " $( uname -m | grep -c 'x86_64' ) " -gt 0 ] ; then
lndOSversion = "amd64"
lndSHA256 = $( grep -i " linux- $lndOSversion " manifest-v$lndVersion .txt | cut -d " " -f1)
fi
echo " *** LND v ${ lndVersion } for ${ lndOSversion } *** "
echo " SHA256 hash: $lndSHA256 "
echo
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
# get LND binary
binaryName = " lnd-linux- ${ lndOSversion } -v ${ lndVersion } .tar.gz "
if [ ! -f " ./ ${ binaryName } " ] ; then
lndDownloadUrl = " https://github.com/lightningnetwork/lnd/releases/download/v ${ lndVersion } / ${ binaryName } "
echo " - downloading lnd binary --> ${ lndDownloadUrl } "
sudo -u admin wget ${ lndDownloadUrl }
echo "- download done"
else
echo "- using existing lnd binary"
fi
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
# check binary was not manipulated (checksum test)
echo "- checksum test"
binaryChecksum = $( sha256sum ${ binaryName } | cut -d " " -f1)
echo " Valid SHA256 checksum(s) should be: ${ lndSHA256 } "
echo " Downloaded binary SHA256 checksum: ${ binaryChecksum } "
checksumCorrect = $( echo " ${ lndSHA256 } " | grep -c " ${ binaryChecksum } " )
if [ " ${ checksumCorrect } " != "1" ] ; then
echo " !!! FAIL !!! Downloaded LND BINARY not matching SHA256 checksum in manifest: ${ lndSHA256 } "
rm -v ./${ binaryName }
exit 1
else
echo
echo "**************************************************"
echo "OK --> THE VERIFIED LND BINARY CHECKSUM IS CORRECT"
echo "**************************************************"
echo
sleep 10
fi
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
# install
echo "- install LND binary"
sudo -u admin tar -xzf ${ binaryName }
sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-${ lndOSversion } -v${ lndVersion } /*
sleep 3
installed = $( sudo -u admin lnd --version)
if [ ${# installed } -eq 0 ] ; then
echo
echo "!!! BUILD FAILED --> Was not able to install LND"
exit 1
fi
2022-02-12 11:10:38 +01:00
2021-12-07 14:00:44 +00:00
correctVersion = $( sudo -u admin lnd --version | grep -c " ${ lndVersion } " )
if [ ${ correctVersion } -eq 0 ] ; then
echo ""
echo " !!! BUILD FAILED --> installed LND is not version ${ lndVersion } "
sudo -u admin lnd --version
exit 1
fi
sudo chown -R admin /home/admin
echo "- OK install of LND done"
exit 0
fi
2021-08-04 00:18:30 +02:00
# CHAIN is signet | testnet | mainnet
CHAIN = $2
2021-09-13 10:36:45 +01:00
if [ ${ CHAIN } = testnet ] || [ ${ CHAIN } = mainnet ] || [ ${ CHAIN } = signet ] ; then
2021-08-04 00:18:30 +02:00
echo " # Configuring the LND instance on ${ CHAIN } "
else
echo " # ${ CHAIN } is not supported "
exit 1
fi
# prefix for parallel services
if [ ${ CHAIN } = testnet ] ; then
netprefix = "t"
portprefix = 1
rpcportmod = 1
zmqprefix = 21
elif [ ${ CHAIN } = signet ] ; then
netprefix = "s"
portprefix = 3
rpcportmod = 3
zmqprefix = 23
elif [ ${ CHAIN } = mainnet ] ; then
netprefix = ""
portprefix = ""
rpcportmod = 0
zmqprefix = 28
fi
2021-09-17 08:02:29 +01:00
source /home/admin/raspiblitz.info
2021-12-14 23:34:35 +01:00
source <( /home/admin/_cache.sh get state)
2021-09-17 08:02:29 +01:00
source /mnt/hdd/raspiblitz.conf
2021-08-04 00:18:30 +02:00
function removeParallelService( ) {
2021-08-28 18:57:49 +02:00
if [ -f " /etc/systemd/system/ ${ netprefix } lnd.service " ] ; then
2022-01-25 12:07:11 +01:00
echo " # Stopping ${ netprefix } lnd ... "
#sudo -u bitcoin /usr/local/bin/lncli --rpcserver localhost:1${rpcportmod}009 stop
2021-08-04 00:18:30 +02:00
sudo systemctl stop ${ netprefix } lnd
sudo systemctl disable ${ netprefix } lnd
2021-08-28 19:53:15 +02:00
sudo rm /etc/systemd/system/${ netprefix } lnd.service 2>/dev/null
2021-08-04 00:18:30 +02:00
echo " # ${ netprefix } lnd.service on ${ CHAIN } is stopped and disabled "
echo
fi
}
# switch on
if [ " $1 " = "1" ] || [ " $1 " = "on" ] ; then
2021-08-28 18:53:32 +02:00
if [ " ${ CHAIN } " = = "testnet" ] && [ " ${ testnet } " != "on" ] ; then
echo "# before activating testnet on lnd, first activate testnet on bitcoind"
echo "err='missing bitcoin testnet'"
exit 1
fi
if [ " ${ CHAIN } " = = "signet" ] && [ " ${ signet } " != "on" ] ; then
echo "# before activating signet on lnd, first activate signet on bitcoind"
echo "err='missing bitcoin signet'"
exit 1
fi
2021-09-12 22:36:57 +02:00
initwallet = 0
if [ " $3 " = = "initwallet" ] ; then
initwallet = 1
echo "# OK will init wallet if not exists (may ask for passwordc)"
fi
2021-12-17 21:43:19 +01:00
# make sure binary is installed (will skip if already done)
/home/admin/config.scripts/lnd.install.sh install
2022-01-04 19:08:38 +00:00
echo "# Make sure the user bitcoin is in the debian-tor group"
sudo usermod -a -G debian-tor bitcoin
2021-12-11 19:38:35 +01:00
sudo ufw allow ${ portprefix } 9735 comment " ${ netprefix } lnd "
sudo ufw allow ${ portprefix } 8080 comment " ${ netprefix } lnd REST "
sudo ufw allow 1${ rpcportmod } 009 comment " ${ netprefix } lnd RPC "
2021-08-28 16:41:51 +02:00
2021-09-13 09:56:04 +01:00
echo "# Prepare directories"
if [ ! -d /mnt/hdd/lnd ] ; then
echo "# Creating /mnt/hdd/lnd"
sudo mkdir /mnt/hdd/lnd
fi
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
if [ ! -L /home/bitcoin/.lnd ] ; then
echo "# Linking lnd for user bitcoin"
sudo rm /home/bitcoin/.lnd 2>/dev/null
sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd
fi
2021-08-04 00:18:30 +02:00
echo " # Create /home/bitcoin/.lnd/ ${ netprefix } lnd.conf "
if [ ! -f /home/bitcoin/.lnd/${ netprefix } lnd.conf ] ; then
2021-08-28 18:53:32 +02:00
echo " # LND configuration
2021-08-04 00:18:30 +02:00
[ Application Options]
# alias=ALIAS # up to 32 UTF-8 characters
# color=COLOR # choose from: https://www.color-hex.com/
listen = 0.0.0.0:${ portprefix } 9735
rpclisten = 0.0.0.0:1${ rpcportmod } 009
restlisten = 0.0.0.0:${ portprefix } 8080
nat = false
debuglevel = debug
2022-02-12 11:10:38 +01:00
gc-canceled-invoices-on-startup= true
gc-canceled-invoices-on-the-fly= true
ignore-historical-gossip-filters= 1
2021-08-04 00:18:30 +02:00
sync-freelist= true
stagger-initial-reconnect= true
tlsautorefresh = 1
tlsdisableautofill = 1
tlscertpath = /home/bitcoin/.lnd/tls.cert
tlskeypath = /home/bitcoin/.lnd/tls.key
[ Bitcoin]
bitcoin.active= 1
2021-08-28 18:53:32 +02:00
bitcoin.${ CHAIN } = 1
2021-08-04 00:18:30 +02:00
bitcoin.node= bitcoind
2022-02-16 21:02:34 +00:00
[ bolt]
db.bolt.auto-compact= true
db.bolt.auto-compact-min-age= 672h
2021-08-04 00:18:30 +02:00
" | sudo -u bitcoin tee /home/bitcoin/.lnd/ ${ netprefix } lnd.conf
else
echo " # The file /home/bitcoin/.lnd/ ${ netprefix } lnd.conf is already present "
fi
2022-02-12 11:10:38 +01:00
# systemd service
2021-08-04 00:18:30 +02:00
removeParallelService
echo "# Create /etc/systemd/system/.lnd.service"
2021-12-20 14:09:24 +00:00
# based on https://github.com/lightningnetwork/lnd/blob/master/contrib/init/lnd.service
2021-08-04 00:18:30 +02:00
echo "
[ Unit]
2021-12-20 14:09:24 +00:00
Description = Lightning Network Daemon on $CHAIN
# Make sure lnd starts after bitcoind is ready
Requires = ${ netprefix } bitcoind.service
After = ${ netprefix } bitcoind.service
2021-08-04 00:18:30 +02:00
[ Service]
2021-08-27 16:21:29 +02:00
EnvironmentFile = /mnt/hdd/raspiblitz.conf
2021-12-20 14:09:24 +00:00
2021-08-27 16:21:29 +02:00
ExecStartPre = -/home/admin/config.scripts/lnd.check.sh prestart ${ CHAIN }
2021-08-28 16:41:51 +02:00
ExecStart = /usr/local/bin/lnd --configfile= /home/bitcoin/.lnd/${ netprefix } lnd.conf
2021-12-21 15:33:41 +00:00
# avoid hanging on stop
# ExecStop=/usr/local/bin/lncli -n=${CHAIN} --rpcserver localhost:1${rpcportmod}009 stop
2021-12-20 14:09:24 +00:00
PIDFile = /home/bitcoin/.lnd/${ netprefix } lnd.pid
User = bitcoin
Group = bitcoin
# Try restarting lnd if it stops due to a failure
Restart = on-failure
RestartSec = 60
# Type=notify is required for lnd to notify systemd when it is ready
Type = notify
# An extended timeout period is needed to allow for database compaction
# and other time intensive operations during startup. We also extend the
# stop timeout to ensure graceful shutdowns of lnd.
TimeoutStartSec = 1200
TimeoutStopSec = 3600
2021-08-04 00:18:30 +02:00
StandardOutput = null
StandardError = journal
2021-12-20 14:09:24 +00:00
# Hardening Measures
####################
# Mount /usr, /boot/ and /etc read-only for the process.
2021-08-04 00:18:30 +02:00
ProtectSystem = full
2021-12-20 14:09:24 +00:00
# Disallow the process and all of its children to gain
# new privileges through execve().
2021-08-04 00:18:30 +02:00
NoNewPrivileges = true
2021-12-20 14:09:24 +00:00
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
2021-09-16 00:41:23 +02:00
PrivateDevices = true
2021-12-20 14:09:24 +00:00
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute = true
PrivateTmp = true
2021-08-04 00:18:30 +02:00
[ Install]
WantedBy = multi-user.target
" | sudo tee /etc/systemd/system/ ${ netprefix } lnd.service
2022-02-12 11:10:38 +01:00
sudo systemctl enable ${ netprefix } lnd
2021-08-04 00:18:30 +02:00
echo " # Enabled the ${ netprefix } lnd.service "
if [ " ${ state } " = = "ready" ] ; then
sudo systemctl start ${ netprefix } lnd
echo " # Started the ${ netprefix } lnd.service "
fi
echo
2021-12-20 07:40:19 +00:00
echo " # Add aliases ${ netprefix } lncli, ${ netprefix } lndlog, ${ netprefix } lndconf "
2021-12-23 20:32:07 +00:00
sudo -u admin touch /home/admin/_aliases
2022-02-12 11:10:38 +01:00
if [ $( grep -c " alias ${ netprefix } lncli " < /home/admin/_aliases) -eq 0 ] ; then
2021-11-30 11:58:06 +00:00
echo " \
2021-08-04 00:18:30 +02:00
alias ${ netprefix } lncli = \" sudo -u bitcoin /usr/local/bin/lncli\
-n= ${ CHAIN } --rpcserver localhost:1${ rpcportmod } 009\" \
" | sudo tee -a /home/admin/_aliases
2021-11-30 11:58:06 +00:00
fi
2022-02-12 11:10:38 +01:00
if [ $( grep -c " alias ${ netprefix } lndlog " < /home/admin/_aliases) -eq 0 ] ; then
2021-11-30 11:58:06 +00:00
echo " \
alias ${ netprefix } lndlog = \" sudo tail -n 30 -f /mnt/hdd/lnd/logs/${ network } /${ CHAIN } /lnd.log\" \
2021-12-20 07:40:19 +00:00
" | sudo tee -a /home/admin/_aliases
fi
2022-02-12 11:10:38 +01:00
if [ $( grep -c " alias ${ netprefix } lndconf " < /home/admin/_aliases) -eq 0 ] ; then
2021-12-20 07:40:19 +00:00
echo " \
alias ${ netprefix } lndconf = \" sudo nano /home/bitcoin/.lnd/${ netprefix } lnd.conf\" \
2021-11-30 11:58:06 +00:00
" | sudo tee -a /home/admin/_aliases
fi
2021-08-04 00:18:30 +02:00
2021-09-12 22:36:57 +02:00
# if parameter "initwallet" was set and wallet does not exist yet
2021-09-12 22:46:42 +02:00
walletExists = $( sudo ls /mnt/hdd/lnd/data/chain/${ network } /${ CHAIN } /wallet.db 2>/dev/null | grep -c "wallet.db" )
2021-09-12 22:36:57 +02:00
if [ " ${ initwallet } " = = "1" ] && [ " ${ walletExists } " = = "0" ] ; then
# only ask on mainnet for passwordC - for the testnet/signet its default 'raspiblitz'
2022-02-12 11:10:38 +01:00
if [ " ${ CHAIN } " = = "mainnet" ] ; then
2021-09-12 22:48:51 +02:00
tempFile = "/var/cache/raspiblitz/passwordc.tmp"
2022-05-05 10:59:50 +02:00
sudo /home/admin/config.scripts/blitz.passwords.sh set x "PASSWORD C - LND Wallet Password" ${ tempFile }
2021-09-12 22:46:42 +02:00
passwordC = $( sudo cat ${ tempFile } )
sudo rm ${ tempFile }
2021-09-12 22:36:57 +02:00
else
passwordC = "raspiblitz"
fi
2021-11-30 11:58:06 +00:00
if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio = = 1.38.1; fi
2021-09-13 10:26:38 +01:00
source <( sudo /home/admin/config.scripts/lnd.initwallet.py new ${ CHAIN } ${ passwordC } )
2021-09-12 22:36:57 +02:00
if [ " ${ err } " != "" ] ; then
clear
2021-09-13 10:26:38 +01:00
echo " # !!! LND ${ CHAIN } wallet creation failed "
2021-09-12 22:48:51 +02:00
echo " # ${ err } "
2021-09-12 22:55:29 +02:00
echo "# press ENTER to continue"
read key
2021-09-12 22:36:57 +02:00
else
seedFile = " /mnt/hdd/lnd/data/chain/ ${ network } / ${ CHAIN } /seedwords.info "
2021-09-13 10:08:23 +01:00
echo " seedwords=' ${ seedwords } ' " | sudo tee ${ seedFile }
echo " seedwords6x4=' ${ seedwords6x4 } ' " | sudo tee -a ${ seedFile }
2021-09-12 22:36:57 +02:00
fi
fi
2021-08-04 00:18:30 +02:00
echo
echo " # The installed LND version is: $( sudo -u bitcoin /usr/local/bin/lnd --version) "
2022-02-12 11:10:38 +01:00
echo
2021-08-04 00:18:30 +02:00
echo "# To activate the aliases reopen the terminal or use:"
echo "source ~/_aliases"
echo " # Monitor the ${ netprefix } lnd with: "
echo " sudo journalctl -fu ${ netprefix } lnd "
echo " sudo systemctl status ${ netprefix } lnd "
echo "# logs:"
echo " sudo tail -f /home/bitcoin/.lnd/logs/bitcoin/ ${ CHAIN } /lnd.log "
echo "# for the command line options use"
echo " ${ netprefix } lncli help "
echo
# setting value in raspi blitz config
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set ${ netprefix } lnd "on"
2021-08-04 00:18:30 +02:00
2021-09-26 10:30:09 +01:00
# if this is the first lightning mainnet turned on - make default
2022-01-25 12:07:11 +01:00
if [ " ${ CHAIN } " = = "mainnet" ] ; then
if [ " ${ lightning } " = = "" ] || [ " ${ lightning } " = = "none" ] ; then
echo "# LND is now default lighthning implementation"
/home/admin/config.scripts/blitz.conf.sh set lightning "lnd"
fi
2021-08-30 20:19:57 +02:00
fi
2021-08-04 00:18:30 +02:00
exit 0
fi
2021-09-12 21:41:48 +02:00
if [ " $1 " = "display-seed" ] ; then
2022-02-12 11:10:38 +01:00
2021-09-12 21:41:48 +02:00
# check if sudo
if [ " $EUID " -ne 0 ] ; then
echo "Please run as root (with sudo)"
exit 1
fi
# get network and aliasses from second parameter (default mainnet)
displayNetwork = $2
if [ " ${ displayNetwork } " = = "" ] ; then
displayNetwork = "mainnet"
fi
2021-09-12 22:36:57 +02:00
deleteSeedInfoAfterDisplay = 0
if [ " $3 " = = "delete" ] ; then
echo "# deleting seedinfo after display"
deleteSeedInfoAfterDisplay = 1
fi
2021-09-12 21:41:48 +02:00
# check if seedword file exists
seedwordFile = " /mnt/hdd/lnd/data/chain/ ${ network } / ${ CHAIN } /seedwords.info "
2021-12-14 17:25:41 +00:00
echo " # seedwordFile( ${ seedwordFile } ) "
2021-09-12 21:41:48 +02:00
seedwordFileExists = $( ls ${ seedwordFile } 2>/dev/null | grep -c "seedwords.info" )
2021-12-14 17:25:41 +00:00
echo " # seedwordFileExists( ${ seedwordFileExists } ) "
2021-09-12 21:41:48 +02:00
if [ " ${ seedwordFileExists } " = = "1" ] ; then
source ${ seedwordFile }
2021-12-14 23:34:35 +01:00
fi
if [ " ${ seedwords } " != "" ] ; then
2021-09-12 21:41:48 +02:00
#echo "# seedwords(${seedwords})"
#echo "# seedwords6x4(${seedwords6x4})"
ack = 0
while [ ${ ack } -eq 0 ]
do
whiptail --title " LND ${ displayNetwork } Wallet " \
--msgbox " This is your LND ${ displayNetwork } wallet seed. Store these numbered words in a safe location:\n\n ${ seedwords6x4 } " 13 76
whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55
if [ $? -eq 1 ] ; then
ack = 1
fi
done
2021-09-12 22:36:57 +02:00
if [ " ${ deleteSeedInfoAfterDisplay } " = = "1" ] ; then
echo "# deleting seed info"
sudo shred ${ seedwordFile }
2021-12-14 23:34:35 +01:00
sudo rm ${ seedwordFile } 2>/dev/null
2021-09-12 22:36:57 +02:00
fi
2021-09-12 21:41:48 +02:00
else
walletFile = " /mnt/hdd/lnd/data/chain/ ${ network } / ${ CHAIN } /wallet.db "
whiptail --title " LND ${ displayNetwork } Wallet Info " --msgbox " Your LND ${ displayNetwork } wallet was already created before - there are no seed words available.\n\nTo secure your wallet secret you can manually backup the file: ${ walletFile } " 11 76
fi
exit 0
fi
2021-08-04 00:18:30 +02:00
# switch off
if [ " $1 " = "0" ] || [ " $1 " = "off" ] ; then
2021-08-28 18:57:49 +02:00
echo " # removing ${ CHAIN } lnd service (if active) "
2021-08-04 00:18:30 +02:00
removeParallelService
2021-08-28 18:57:49 +02:00
# setting value in raspiblitz config
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set ${ netprefix } lnd "off"
echo " # ${ netprefix } lnd --> off "
2021-08-04 00:18:30 +02:00
2022-02-12 11:10:38 +01:00
# if lnd mainnet was default - remove
2021-08-30 20:19:57 +02:00
if [ " ${ CHAIN } " = = "mainnet" ] && [ " ${ lightning } " = = "lnd" ] ; then
echo "# LND is REMOVED as default lightning implementation"
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set lightning ""
2021-09-26 10:30:09 +01:00
if [ " ${ cl } " = = "on" ] ; then
echo "# CL is now the new default lightning implementation"
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set lightning "cl"
2021-08-30 20:19:57 +02:00
fi
fi
2021-08-04 00:18:30 +02:00
exit 0
fi
echo " # FAIL - Unknown Parameter $1 "
echo "# may need reboot to run"
2021-12-17 21:43:19 +01:00
exit 1