mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-25 07:07:46 +01:00
Merge pull request #2334 from openoms/cblitz-merge
Merge C-lightning development with the refactored provision
This commit is contained in:
commit
acc21b5f59
35 changed files with 2728 additions and 463 deletions
|
@ -103,6 +103,7 @@ In the end your RaspiBlitz should look like this:
|
|||
|
||||
## Downloading the Software
|
||||
|
||||
|
||||
|Method|Install the image|Build the sd card|
|
||||
|------|-----------------|-----------------|
|
||||
|Philosophy|Trust|Sovereignty|
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 00infoBlitz.sh <cln|lnd> <testnet|mainnet|signet>
|
||||
|
||||
# load code software version
|
||||
source /home/admin/_version.info
|
||||
|
||||
|
@ -14,6 +16,12 @@ color_gray='\033[0;37m'
|
|||
source /home/admin/raspiblitz.info 2>/dev/null
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
## get HDD/SSD info
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
hdd="${hddUsedInfo}"
|
||||
|
@ -45,7 +53,7 @@ if [ ${#network} -eq 0 ]; then
|
|||
if [ ${litecoinActive} -eq 1 ]; then
|
||||
network="litecoin"
|
||||
else
|
||||
network=`sudo cat /home/admin/.network 2>/dev/null`
|
||||
network=$(sudo cat /home/admin/.network 2>/dev/null)
|
||||
fi
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
network="bitcoin"
|
||||
|
@ -62,7 +70,6 @@ if [ ${#chain} -eq 0 ]; then
|
|||
fi
|
||||
|
||||
# set datadir
|
||||
bitcoin_dir="/home/bitcoin/.${network}"
|
||||
lnd_dir="/home/bitcoin/.lnd"
|
||||
lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net"
|
||||
|
||||
|
@ -74,9 +81,13 @@ cpu=0
|
|||
if [ -d "/sys/class/thermal/thermal_zone0/" ]; then
|
||||
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
|
||||
fi
|
||||
tempC=$((cpu/1000))
|
||||
tempF=$(((tempC * 18 + 325) / 10))
|
||||
|
||||
if [ $cpu = 0 ];then
|
||||
tempC=""
|
||||
tempF=""
|
||||
else
|
||||
tempC=$((cpu/1000))
|
||||
tempF=$(((tempC * 18 + 325) / 10))
|
||||
fi
|
||||
# get memory
|
||||
ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
|
||||
ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")
|
||||
|
@ -90,14 +101,14 @@ fi
|
|||
# Bitcoin blockchain
|
||||
btc_path=$(command -v ${network}-cli)
|
||||
blockInfo="-"
|
||||
if [ -n ${btc_path} ]; then
|
||||
if [ -n "${btc_path}" ]; then
|
||||
btc_title=$network
|
||||
blockchaininfo="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo 2>/dev/null)"
|
||||
blockchaininfo="$($bitcoincli_alias getblockchaininfo 2>/dev/null)"
|
||||
if [ ${#blockchaininfo} -gt 0 ]; then
|
||||
btc_title="${btc_title} (${chain}net)"
|
||||
|
||||
# get sync status
|
||||
block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)"
|
||||
block_chain="$($bitcoincli_alias getblockcount 2>/dev/null)"
|
||||
block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')"
|
||||
block_diff=$(expr ${block_chain} - ${block_verified})
|
||||
blockInfo="${block_verified}/${block_chain}"
|
||||
|
@ -124,13 +135,13 @@ if [ -n ${btc_path} ]; then
|
|||
fi
|
||||
|
||||
# get last known block
|
||||
last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)"
|
||||
last_block="$($bitcoincli_alias getblockcount 2>/dev/null)"
|
||||
if [ ! -z "${last_block}" ]; then
|
||||
btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
|
||||
fi
|
||||
|
||||
# get mem pool transactions
|
||||
mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo 2>/dev/null | jq -r '.size')"
|
||||
mempool="$($bitcoincli_alias getmempoolinfo 2>/dev/null | jq -r '.size')"
|
||||
|
||||
else
|
||||
btc_line2="${color_red}NOT RUNNING\t\t"
|
||||
|
@ -138,7 +149,7 @@ if [ -n ${btc_path} ]; then
|
|||
fi
|
||||
|
||||
# get IP address & port
|
||||
networkInfo=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo 2>/dev/null)
|
||||
networkInfo=$($bitcoincli_alias getnetworkinfo 2>/dev/null)
|
||||
local_ip="${localip}" # from internet.sh
|
||||
public_ip="${cleanip}"
|
||||
public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')"
|
||||
|
@ -152,9 +163,14 @@ fi
|
|||
|
||||
# check if RTL web interface is installed
|
||||
webinterfaceInfo=""
|
||||
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
||||
runningRTL=$(systemctl status ${netprefix}${typeprefix}RTL.service 2>/dev/null | grep -c active)
|
||||
if [ ${runningRTL} -eq 1 ]; then
|
||||
webinterfaceInfo="Web admin --> ${color_green}http://${local_ip}:3000"
|
||||
if [ ${LNTYPE} = "cln" ]; then
|
||||
RTLHTTP=${portprefix}7000
|
||||
elif [ ${LNTYPE} = "lnd" ];then
|
||||
RTLHTTP=${portprefix}3000
|
||||
fi
|
||||
webinterfaceInfo="Web admin --> ${color_green}http://${local_ip}:${RTLHTTP}"
|
||||
fi
|
||||
|
||||
# CHAIN NETWORK
|
||||
|
@ -162,9 +178,9 @@ public_addr_pre="Public "
|
|||
public_addr="??"
|
||||
torInfo=""
|
||||
# Version
|
||||
networkVersion=$(${network}-cli -datadir=${bitcoin_dir} -version 2>/dev/null | cut -d ' ' -f6)
|
||||
networkVersion=$($bitcoincli_alias -version 2>/dev/null | cut -d ' ' -f6)
|
||||
# TOR or IP
|
||||
networkInfo=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo)
|
||||
networkInfo=$($bitcoincli_alias getnetworkinfo)
|
||||
networkConnections=$(echo ${networkInfo} | jq -r '.connections')
|
||||
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections"
|
||||
|
||||
|
@ -222,69 +238,167 @@ else
|
|||
fi
|
||||
|
||||
# LIGHTNING NETWORK
|
||||
|
||||
ln_baseInfo="-"
|
||||
ln_channelInfo="\n"
|
||||
ln_external="\n"
|
||||
ln_alias="${hostname}"
|
||||
ln_publicColor=""
|
||||
ln_port=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':')
|
||||
if [ ${#ln_port} -eq 0 ]; then
|
||||
ln_port="9735"
|
||||
fi
|
||||
|
||||
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock)
|
||||
if [ "$wallet_unlocked" -gt 0 ] ; then
|
||||
alias_color="${color_red}"
|
||||
ln_alias="Wallet Locked"
|
||||
else
|
||||
ln_getInfo=$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
|
||||
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
|
||||
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
|
||||
if [ ${ln_tor} -eq 1 ]; then
|
||||
ln_publicColor="${color_green}"
|
||||
else
|
||||
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
|
||||
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
|
||||
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
|
||||
ln_publicColor="${color_amber}"
|
||||
else
|
||||
ln_publicColor="${color_red}"
|
||||
fi
|
||||
if [ ${LNTYPE} = "cln" ]; then
|
||||
ln_baseInfo="-"
|
||||
ln_channelInfo="\n"
|
||||
ln_external="\n"
|
||||
ln_alias="$(sudo cat /home/bitcoin/.lightning/${netprefix}config | grep "^alias=*" | cut -f2 -d=)"
|
||||
if [ ${#ln_alias} -eq 0 ];then
|
||||
ln_alias=$(lightningcli_alias getinfo | grep '"alias":' | cut -d '"' -f4)
|
||||
fi
|
||||
alias_color="${color_grey}"
|
||||
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
|
||||
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1)
|
||||
if [ ${ln_sync} -eq 0 ]; then
|
||||
if [ ${#ln_getInfo} -eq 0 ]; then
|
||||
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
|
||||
else
|
||||
ln_baseInfo="${color_amber} Waiting for Chain Sync"
|
||||
fi
|
||||
if [ ${#ln_alias} -eq 0 ];then
|
||||
ln_alias=${hostname}
|
||||
fi
|
||||
ln_publicColor=""
|
||||
ln_port=$(sudo cat /home/bitcoin/.lightning/${netprefix}config | grep "^bind-addr=*" | cut -f2 -d':')
|
||||
if [ ${#ln_port} -eq 0 ]; then
|
||||
ln_port=$(lightningcli_alias getinfo | grep '"port":' | cut -d: -f2 | tail -1 | bc)
|
||||
fi
|
||||
wallet_unlocked=0 #TODO
|
||||
if [ "$wallet_unlocked" -gt 0 ] ; then
|
||||
alias_color="${color_red}"
|
||||
ln_alias="Wallet Locked"
|
||||
else
|
||||
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
|
||||
pubkey=$(echo "${ln_getInfo}" | grep '"id":' | cut -d '"' -f4)
|
||||
address=$(echo "${ln_getInfo}" | grep '.onion' | cut -d '"' -f4)
|
||||
if [ ${#address} -eq 0 ];then
|
||||
address=$(echo "${ln_getInfo}" | grep '"ipv4"' -A 1 | tail -1 | cut -d '"' -f4)
|
||||
fi
|
||||
ln_external="${pubkey}@${address}"
|
||||
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
|
||||
if [ ${ln_tor} -eq 1 ]; then
|
||||
ln_publicColor="${color_green}"
|
||||
else
|
||||
ln_walletbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
|
||||
ln_walletbalance_wait="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.unconfirmed_balance')" 2>/dev/null
|
||||
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi
|
||||
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi
|
||||
ln_channelbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
|
||||
ln_channelbalance_pending="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.pending_open_balance')" 2>/dev/null
|
||||
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
|
||||
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
|
||||
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
|
||||
ln_channels_total="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
|
||||
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} sat ${ln_walletbalance_wait}"
|
||||
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
|
||||
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat${ln_channelbalance_pending}"
|
||||
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
|
||||
ln_dailyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.day_fee_sum')" 2>/dev/null
|
||||
ln_weeklyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.week_fee_sum')" 2>/dev/null
|
||||
ln_monthlyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.month_fee_sum')" 2>/dev/null
|
||||
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
|
||||
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
|
||||
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
|
||||
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
|
||||
ln_publicColor="${color_amber}"
|
||||
else
|
||||
ln_publicColor="${color_red}"
|
||||
fi
|
||||
fi
|
||||
alias_color="${color_grey}"
|
||||
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
|
||||
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
|
||||
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
|
||||
ln_sync=1
|
||||
else
|
||||
ln_sync=0
|
||||
fi
|
||||
ln_version=$(lightningcli_alias -V)
|
||||
if [ ${ln_sync} -eq 0 ]; then
|
||||
if [ ${#ln_getInfo} -eq 0 ]; then
|
||||
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
|
||||
else
|
||||
ln_baseInfo="${color_amber} Waiting for Chain Sync"
|
||||
fi
|
||||
else
|
||||
ln_walletbalance=0
|
||||
for i in $($lightningcli_alias \
|
||||
listfunds|jq .outputs[]|jq 'select(.status=="confirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
|
||||
ln_walletbalance=$((ln_walletbalance+i))
|
||||
done
|
||||
for i in $($lightningcli_alias \
|
||||
listfunds|jq .outputs[]|jq 'select(.status=="unconfirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
|
||||
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
|
||||
done
|
||||
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi
|
||||
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi
|
||||
ln_channelbalance=0
|
||||
for i in $($lightningcli_alias \
|
||||
listfunds|jq .channels[]|jq 'select(.state=="CHANNELD_NORMAL")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
|
||||
ln_channelbalance=$((ln_channelbalance+i))
|
||||
done
|
||||
if [ ${#ln_channelbalance} -eq 0 ];then
|
||||
ln_channelbalance=0
|
||||
fi
|
||||
for i in $($lightningcli_alias \
|
||||
listfunds|jq .channels[]|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
|
||||
ln_channelbalance_all=$((ln_channelbalance_all+i))
|
||||
done
|
||||
ln_channelbalance_pending=$((ln_channelbalance_all-ln_channelbalance))
|
||||
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
|
||||
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
|
||||
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
|
||||
ln_channels_total="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
|
||||
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} ${netprefix}sat ${ln_walletbalance_wait}"
|
||||
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
|
||||
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}"
|
||||
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
|
||||
#ln_dailyfees="$($lncli_alias feereport | jq -r '.day_fee_sum')" 2>/dev/null
|
||||
#ln_weeklyfees="$($lncli_alias feereport | jq -r '.week_fee_sum')" 2>/dev/null
|
||||
#ln_monthlyfees="$($lncli_alias feereport | jq -r '.month_fee_sum')" 2>/dev/null
|
||||
#ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
|
||||
ln_feeReport="$(lightningcli_alias -H summary | grep fees_collected)"
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [ ${LNTYPE} = "lnd" ];then
|
||||
ln_baseInfo="-"
|
||||
ln_channelInfo="\n"
|
||||
ln_external="\n"
|
||||
ln_alias="$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^alias=*" | cut -f2 -d=)"
|
||||
if [ ${#ln_alias} -eq 0 ];then
|
||||
ln_alias=${hostname}
|
||||
fi
|
||||
ln_publicColor=""
|
||||
ln_port=$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^listen=*" | cut -f2 -d':')
|
||||
if [ ${#ln_port} -eq 0 ]; then
|
||||
ln_port="9735"
|
||||
fi
|
||||
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock)
|
||||
if [ "$wallet_unlocked" -gt 0 ] ; then
|
||||
alias_color="${color_red}"
|
||||
ln_alias="Wallet Locked"
|
||||
else
|
||||
ln_getInfo=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
|
||||
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
|
||||
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
|
||||
if [ ${ln_tor} -eq 1 ]; then
|
||||
ln_publicColor="${color_green}"
|
||||
else
|
||||
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
|
||||
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
|
||||
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
|
||||
ln_publicColor="${color_amber}"
|
||||
else
|
||||
ln_publicColor="${color_red}"
|
||||
fi
|
||||
fi
|
||||
alias_color="${color_grey}"
|
||||
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
|
||||
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1)
|
||||
if [ ${ln_sync} -eq 0 ]; then
|
||||
if [ ${#ln_getInfo} -eq 0 ]; then
|
||||
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
|
||||
else
|
||||
ln_baseInfo="${color_amber} Waiting for Chain Sync"
|
||||
fi
|
||||
else
|
||||
ln_walletbalance="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
|
||||
ln_walletbalance_wait="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.unconfirmed_balance')" 2>/dev/null
|
||||
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi
|
||||
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi
|
||||
ln_channelbalance="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
|
||||
ln_channelbalance_pending="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.pending_open_balance')" 2>/dev/null
|
||||
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
|
||||
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
|
||||
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
|
||||
ln_channels_total="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
|
||||
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} ${netprefix}sat ${ln_walletbalance_wait}"
|
||||
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
|
||||
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}"
|
||||
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
|
||||
ln_dailyfees="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.day_fee_sum')" 2>/dev/null
|
||||
ln_weeklyfees="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.week_fee_sum')" 2>/dev/null
|
||||
ln_monthlyfees="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.month_fee_sum')" 2>/dev/null
|
||||
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# show JoinMarket stats in place of the LND URI only if the Yield Generator is running
|
||||
|
||||
source /home/joinmarket/joinin.conf 2>/dev/null
|
||||
if [ "${joinmarket}" = "on" ] && [ $(sudo -u joinmarket pgrep -f "python yg-privacyenhanced.py $YGwallet --wallet-password-stdin" 2>/dev/null | wc -l) -gt 2 ]; then
|
||||
JMstats=$(mktemp 2>/dev/null)
|
||||
|
@ -305,6 +419,17 @@ ${color_yellow}
|
|||
${color_yellow}${ln_publicColor}${ln_external}${color_gray}"
|
||||
fi
|
||||
|
||||
if [ $LNTYPE = "cln" ];then
|
||||
LNline="C-LIGHTNING ${color_green}${ln_version} ${ln_baseInfo}"
|
||||
elif [ $LNTYPE = "lnd" ];then
|
||||
LNline="LND ${color_green}${ln_version} ${ln_baseInfo}"
|
||||
fi
|
||||
|
||||
if [ $cpu = 0 ];then
|
||||
templine="on $(uname -m) VM%s%s"
|
||||
else
|
||||
templine="temp %s°C %s°F"
|
||||
fi
|
||||
sleep 5
|
||||
|
||||
## get uptime and current date & time
|
||||
|
@ -320,14 +445,14 @@ ${color_yellow} ${color_amber}%s ${color_green} ${ln_alias} ${upsI
|
|||
${color_yellow} ${color_gray}${network^} Fullnode + Lightning Network ${torInfo}
|
||||
${color_yellow} ,/ ${color_yellow}%s
|
||||
${color_yellow} ,'/ ${color_gray}%s
|
||||
${color_yellow} ,' / ${color_gray}%s, temp %s°C %s°F
|
||||
${color_yellow} ,' / ${color_gray}%s, ${templine}
|
||||
${color_yellow} ,' /_____, ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray}
|
||||
${color_yellow} .'____ ,' ${color_gray}SSH admin@${color_green}${local_ip}${color_gray} d${network_rx} u${network_tx}
|
||||
${color_yellow} / ,' ${color_gray}${webinterfaceInfo}
|
||||
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${color_gray}${chain}net ${networkConnectionsInfo}
|
||||
${color_yellow} /,' ${color_gray}Blocks ${blockInfo} ${color_gray}Sync ${sync_color}${sync} %s
|
||||
${color_yellow} /' ${color_gray}
|
||||
${color_yellow} ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo}
|
||||
${color_yellow} ${color_gray}${LNline}
|
||||
${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo}
|
||||
${color_yellow} ${color_gray}${ln_feeReport}
|
||||
$lastLine
|
||||
|
|
|
@ -86,6 +86,15 @@ while :
|
|||
|
||||
# get config info if already available (with state value)
|
||||
source ${infoFile}
|
||||
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
source ${configFile}
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
fi
|
||||
|
||||
if [ "${setupPhase}" != "done" ]; then
|
||||
|
||||
|
@ -98,7 +107,7 @@ while :
|
|||
|
||||
# TODO: ALSO SEPERATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
|
||||
# if LND is syncing or scanning
|
||||
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
lndSynced=$($lncli_alias getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
if [ ${lndSynced} -eq 0 ]; then
|
||||
/home/admin/80scanLND.sh
|
||||
sleep 20
|
||||
|
|
|
@ -40,6 +40,14 @@ confirmation()
|
|||
# get the local network IP to be displayed on the LCD
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
if [ ${chain} = test ];then
|
||||
netprefix="t"
|
||||
elif [ ${chain} = sig ];then
|
||||
netprefix="s"
|
||||
elif [ ${chain} = main ];then
|
||||
netprefix=""
|
||||
fi
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=19
|
||||
WIDTH=64
|
||||
|
@ -163,9 +171,28 @@ if [ "${circuitbreaker}" == "on" ]; then
|
|||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ "${testnet}" == "on" ]&&[ ${chain} != test ];then
|
||||
OPTIONS+=(TESTNET "Testnet Service Options")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ ${chain} != main ];then
|
||||
OPTIONS+=(MAINNET "Mainnet Service Options")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
# Basic Options
|
||||
OPTIONS+=(INFO "RaspiBlitz Status Screen")
|
||||
OPTIONS+=(LIGHTNING "LND Wallet Options")
|
||||
OPTIONS+=(LND "LND Wallet Options")
|
||||
|
||||
if [ "$cln" == "on" ]||[ $chain = test ]&&[ "$tcln" == "on" ]; then
|
||||
OPTIONS+=(CLN "C-lightning Wallet Options")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
OPTIONS+=(SETTINGS "Node Settings & Options")
|
||||
OPTIONS+=(SERVICES "Additional Apps & Services")
|
||||
OPTIONS+=(SYSTEM "Monitoring & Configuration")
|
||||
|
@ -226,8 +253,11 @@ case $CHOICE in
|
|||
exit 0
|
||||
fi
|
||||
;;
|
||||
LIGHTNING)
|
||||
/home/admin/99lightningMenu.sh
|
||||
LND)
|
||||
/home/admin/99lndMenu.sh
|
||||
;;
|
||||
CLN)
|
||||
/home/admin/99clnMenu.sh ${chain}net
|
||||
;;
|
||||
CONNECT)
|
||||
/home/admin/99connectMenu.sh
|
||||
|
@ -298,6 +328,12 @@ case $CHOICE in
|
|||
;;
|
||||
CIRCUIT)
|
||||
sudo /home/admin/config.scripts/bonus.circuitbreaker.sh menu
|
||||
;;
|
||||
TESTNET)
|
||||
/home/admin/00parallelChainsMenu.sh testnet
|
||||
;;
|
||||
MAINNET)
|
||||
/home/admin/00parallelChainsMenu.sh mainnet
|
||||
;;
|
||||
SUBSCRIBE)
|
||||
/home/admin/config.scripts/blitz.subscriptions.py
|
||||
|
|
191
home.admin/00parallelChainsMenu.sh
Normal file
191
home.admin/00parallelChainsMenu.sh
Normal file
|
@ -0,0 +1,191 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Usage:
|
||||
# 00parallelChainsMenu.sh <testnet|signet|mainnet> <lnd|cln>
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^testnet=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "testnet=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
if ! grep -Eq "^LNdefault=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "LNdefault=lnd" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
if [ $# -gt 0 ] && [ $1 != ${chain}net ];then
|
||||
nonDefaultChain=1
|
||||
CHAIN=$1
|
||||
else
|
||||
nonDefaultChain=0
|
||||
CHAIN=${chain}net
|
||||
fi
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 1 ]&&[ $2 != $LNdefault ];then
|
||||
nonDefaultLNtype=1
|
||||
LNTYPE=$2
|
||||
else
|
||||
nonDefaultLNtype=0
|
||||
LNTYPE=$LNdefault
|
||||
fi
|
||||
|
||||
# get the local network IP to be displayed on the LCD
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=10
|
||||
WIDTH=64
|
||||
CHOICE_HEIGHT=3
|
||||
BACKTITLE="${CHAIN} options"
|
||||
TITLE=""
|
||||
MENU="Choose one of the following options:"
|
||||
OPTIONS=()
|
||||
plus=""
|
||||
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
plus=" / TOR"
|
||||
fi
|
||||
if [ ${#dynDomain} -gt 0 ]; then
|
||||
plus="${plus} / ${dynDomain}"
|
||||
fi
|
||||
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
|
||||
|
||||
# Put Activated Apps on top
|
||||
if [ $chain = test ]&&[ "$trtlWebinterface" = "on" ]||\
|
||||
[ $chain = sig ]&& [ "$srtlWebinterface" = "on" ]||\
|
||||
[ $chain = main ]&&[ "$rtlWebinterface" = "on" ]; then
|
||||
OPTIONS+=(RTL "RTL Web Node Manager for LND ${CHAIN}")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ $chain = test ]&&[ "$tlnd" = "on" ]||\
|
||||
[ $chain = sig ]&& [ "$slnd" = "on" ]||\
|
||||
[ $chain = main ]&&[ "$lnd" = "on" ]; then
|
||||
#TODO OPTIONS+=(LND "LND options for ${CHAIN}")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ "$chain" = "test" ]&&[ "$tcrtlWebinterface" = "on" ]||\
|
||||
[ "$chain" = "sig" ]&& [ "$scrtlWebinterface" = "on" ]||\
|
||||
[ "$chain" = "main" ]&&[ "$crtlWebinterface" = "on" ]; then
|
||||
OPTIONS+=(cRTL "RTL Web Node Manager for C-lightning ${CHAIN}")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ "$chain" = "test" ]&&[ "$tcln" = "on" ]||\
|
||||
[ "$chain" = "sig" ]&& [ "$scln" = "on" ]||\
|
||||
[ "$chain" = "main" ]&&[ "$cln" = "on" ]; then
|
||||
OPTIONS+=(CLN "C-lightning options for ${CHAIN}")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
OPTIONS+=(INFO "RaspiBlitz Status Screen for ${CHAIN}")
|
||||
|
||||
if [ "$testnet" == "on" ]; then
|
||||
OPTIONS+=(SERVICES "Additional Apps & Services on ${CHAIN}")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
#TODO OPTIONS+=(SYSTEM "Monitoring & Configuration")
|
||||
#TODO OPTIONS+=(CONNECT "Connect Apps & Show Credentials")
|
||||
|
||||
if [ $nonDefaultLNtype = 1 ];then
|
||||
OPTIONS+=(SWITCHLN "Make ${LNTYPE} the default lightning wallet")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
if [ $nonDefaultChain = 1 ];then
|
||||
OPTIONS+=(MKDEFAULT "Make ${CHAIN} the default chain")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--ok-label "Select" \
|
||||
--cancel-label "Back" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
case $CHOICE in
|
||||
INFO)
|
||||
# #TODO
|
||||
# echo "Gathering Information (please wait) ..."
|
||||
# walletLocked=$(lncli getinfo 2>&1 | grep -c "Wallet is encrypted")
|
||||
# if [ ${walletLocked} -eq 0 ]; then
|
||||
# while :
|
||||
# do
|
||||
# # show the same info as on LCD screen
|
||||
# /home/admin/00infoBlitz.sh
|
||||
# # wait 6 seconds for user exiting loop
|
||||
# echo ""
|
||||
# echo -en "Screen is updating in a loop .... press 'x' now to get back to menu."
|
||||
# read -n 1 -t 6 keyPressed
|
||||
# echo -en "\rGathering information to update info ... please wait. \n"
|
||||
# # check if user wants to abort session
|
||||
# if [ "${keyPressed}" = "x" ]; then
|
||||
# echo ""
|
||||
# echo "Returning to menu ....."
|
||||
# sleep 4
|
||||
# break
|
||||
# fi
|
||||
# done
|
||||
# else
|
||||
# /home/admin/00raspiblitz.sh
|
||||
# exit 0
|
||||
# fi
|
||||
/home/admin/00infoBlitz.sh $CHAIN
|
||||
;;
|
||||
RTL)
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
|
||||
;;
|
||||
cRTL)
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu cln $CHAIN
|
||||
;;
|
||||
LND)
|
||||
/home/admin/99lndMenu.sh $CHAIN
|
||||
;;
|
||||
CLN)
|
||||
/home/admin/99clnMenu.sh $CHAIN
|
||||
;;
|
||||
SERVICES)
|
||||
if [ $CHAIN = testnet ];then
|
||||
/home/admin/00parallelTestnetServices.sh
|
||||
elif [ $CHAIN = mainnet ];then
|
||||
/home/admin/00parallelMainnetServices.sh $CHAIN
|
||||
fi
|
||||
;;
|
||||
SYSTEM)
|
||||
/home/admin/99systemMenu.sh $CHAIN
|
||||
;;
|
||||
CONNECT)
|
||||
/home/admin/99connectMenu.sh $CHAIN
|
||||
;;
|
||||
SWITCHLN)
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^LNdefault=.*/LNdefault=$LNTYPE/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# OK - Set LNdefault=$LNTYPE in /mnt/hdd/raspiblitz.conf"
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
;;
|
||||
MKDEFAULT)
|
||||
# setting value in raspi blitz config
|
||||
newchain=${CHAIN::-3}
|
||||
sudo sed -i "s/^chain=.*/chain=${newchain}/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# OK - Set chain=${newchain} in /mnt/hdd/raspiblitz.conf"
|
||||
sudo /home/admin/config.scripts/lnd.credentials.sh sync
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
esac
|
179
home.admin/00parallelMainnetServices.sh
Normal file
179
home.admin/00parallelMainnetServices.sh
Normal file
|
@ -0,0 +1,179 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get raspiblitz config
|
||||
echo "get raspiblitz config"
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
CHAIN=mainnet
|
||||
|
||||
# for testnet
|
||||
echo "services default values"
|
||||
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
|
||||
if [ ${#lnd} -eq 0 ]; then lnd="off"; fi
|
||||
if [ ${#cln} -eq 0 ]; then cln="off"; fi
|
||||
if [ ${#crtlWebinterface} -eq 0 ]; then crtlWebinterface="off"; fi
|
||||
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
|
||||
OPTIONS=()
|
||||
OPTIONS+=(l "LND on $CHAIN" ${lnd})
|
||||
OPTIONS+=(r "RTL for LND $CHAIN" ${rtlWebinterface})
|
||||
OPTIONS+=(c "C-lightning on $CHAIN" ${cln})
|
||||
OPTIONS+=(t "RTL for CLN on $CHAIN" ${crtlWebinterface})
|
||||
OPTIONS+=(s "Sparko for CLN on $CHAIN" ${sparko})
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Services ' \
|
||||
--checklist ' use spacebar to activate/de-activate ' \
|
||||
11 45 4 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
dialogcancel=$?
|
||||
echo "done dialog"
|
||||
clear
|
||||
|
||||
# check if user canceled dialog
|
||||
echo "dialogcancel(${dialogcancel})"
|
||||
if [ ${dialogcancel} -eq 1 ]; then
|
||||
echo "user canceled"
|
||||
exit 1
|
||||
elif [ ${dialogcancel} -eq 255 ]; then
|
||||
echo "ESC pressed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
needsReboot=0
|
||||
anychange=0
|
||||
|
||||
# lnd process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "l")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${lnd}" != "${choice}" ]; then
|
||||
echo "# LND on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/lnd.chain.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed LND on $CHAIN"
|
||||
else
|
||||
l1="# !!! FAIL on LND on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/lnd.chain.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# LND on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# cln process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "c")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${cln}" != "${choice}" ]; then
|
||||
echo "# CLN on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cln.install.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed CLN on $CHAIN"
|
||||
else
|
||||
l1="# !!! FAIL on CLN on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cln.install.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# CLN on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# RTL process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "r")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${rtlWebinterface}" != "${choice}" ]; then
|
||||
echo "# RTL for LND $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/bonus.rtl.sh ${choice} lnd $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
sudo systemctl start RTL
|
||||
echo "# waiting 10 secs .."
|
||||
sleep 10
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on RTL for LND $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/bonus.rtl.sh on lnd $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# RTL for LND $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# cRTL process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${crtlWebinterface}" != "${choice}" ]; then
|
||||
echo "RTL for CLN $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/bonus.rtl.sh ${choice} cln $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
sudo systemctl start cRTL
|
||||
echo "waiting 10 secs .."
|
||||
sleep 10
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
|
||||
else
|
||||
l1="!!! FAIL on RTL for CLN $CHAIN install !!!"
|
||||
l2="Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/bonus.rtl.sh on cln $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "RTL for CLN $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# sparko process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "s")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${sparko}" != "${choice}" ]; then
|
||||
echo "# Sparko on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cln.sparko.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
/home/admin/config.scripts/cln.sparko.sh menu $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on Sparko on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cln.sparko.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Sparko on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ${needsReboot} -eq 1 ]; then
|
||||
sleep 2
|
||||
dialog --pause "OK. System will reboot to activate changes." 8 58 8
|
||||
clear
|
||||
echo "rebooting .. (please wait)"
|
||||
# stop bitcoind
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
sleep 4
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
fi
|
181
home.admin/00parallelTestnetServices.sh
Normal file
181
home.admin/00parallelTestnetServices.sh
Normal file
|
@ -0,0 +1,181 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get raspiblitz config
|
||||
echo "get raspiblitz config"
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
CHAIN=testnet
|
||||
|
||||
# for testnet
|
||||
echo "services default values"
|
||||
if [ ${#trtlWebinterface} -eq 0 ]; then trtlWebinterface="off"; fi
|
||||
if [ ${#tlnd} -eq 0 ]; then tlnd="off"; fi
|
||||
if [ ${#tcrtlWebinterface} -eq 0 ]; then tcrtlWebinterface="off"; fi
|
||||
if [ ${#tcln} -eq 0 ]; then tcln="off"; fi
|
||||
if [ ${#tsparko} -eq 0 ]; then tsparko="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
|
||||
OPTIONS=()
|
||||
OPTIONS+=(l "LND on $CHAIN" ${tlnd})
|
||||
OPTIONS+=(r "RTL for LND $CHAIN" ${trtlWebinterface})
|
||||
OPTIONS+=(c "C-lightning on $CHAIN" ${tcln})
|
||||
OPTIONS+=(t "RTL for CLN on $CHAIN" ${tcrtlWebinterface})
|
||||
OPTIONS+=(s "Sparko for CLN on $CHAIN" ${tsparko})
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Services ' \
|
||||
--checklist ' use spacebar to activate/de-activate ' \
|
||||
11 45 4 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
dialogcancel=$?
|
||||
echo "done dialog"
|
||||
clear
|
||||
|
||||
# check if user canceled dialog
|
||||
echo "dialogcancel(${dialogcancel})"
|
||||
if [ ${dialogcancel} -eq 1 ]; then
|
||||
echo "user canceled"
|
||||
exit 1
|
||||
elif [ ${dialogcancel} -eq 255 ]; then
|
||||
echo "ESC pressed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
needsReboot=0
|
||||
anychange=0
|
||||
|
||||
# tlnd process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "l")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${tlnd}" != "${choice}" ]; then
|
||||
echo "# LND on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/lnd.chain.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed LND on $CHAIN"
|
||||
else
|
||||
l1="# !!! FAIL on LND on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/lnd.chain.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# LND on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# tcln process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "c")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${tcln}" != "${choice}" ]; then
|
||||
echo "# CLN on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cln.install.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed CLN on $CHAIN"
|
||||
else
|
||||
l1="# !!! FAIL on CLN on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cln.install.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# CLN on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# tRTL process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "r")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${trtlWebinterface}" != "${choice}" ]; then
|
||||
echo "# RTL for LND $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/bonus.rtl.sh ${choice} lnd $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
sudo systemctl start tRTL
|
||||
echo "# waiting 10 secs .."
|
||||
sleep 10
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on RTL for LND $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/bonus.rtl.sh on lnd $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# RTL for LND $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# ctRTL process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${tcrtlWebinterface}" != "${choice}" ]; then
|
||||
echo "RTL for CLN $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/bonus.rtl.sh ${choice} cln $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
sudo systemctl start tcRTL
|
||||
echo "waiting 10 secs .."
|
||||
sleep 10
|
||||
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
|
||||
else
|
||||
l1="!!! FAIL on RTL for CLN $CHAIN install !!!"
|
||||
l2="Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/bonus.rtl.sh on cln $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "RTL for CLN $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
# tsparko process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "s")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${tsparko}" != "${choice}" ]; then
|
||||
echo "# Sparko on $CHAIN Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cln.sparko.sh ${choice} $CHAIN
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
/home/admin/config.scripts/cln.sparko.sh menu $CHAIN
|
||||
else
|
||||
l1="# !!! FAIL on Sparko on $CHAIN install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cln.sparko.sh on $CHAIN"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Sparko on $CHAIN Setting unchanged."
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ${needsReboot} -eq 1 ]; then
|
||||
sleep 2
|
||||
dialog --pause "OK. System will reboot to activate changes." 8 58 8
|
||||
clear
|
||||
echo "rebooting .. (please wait)"
|
||||
# stop bitcoind
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
sleep 4
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
fi
|
|
@ -313,6 +313,11 @@ if [ "${state}" = "ready" ]; then
|
|||
if [ ${configExists} -eq 1 ]; then
|
||||
echo "loading config data"
|
||||
source ${configFile}
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
else
|
||||
echo "setup still in progress - setupStep(${setupStep})"
|
||||
fi
|
||||
|
@ -339,8 +344,8 @@ waitUntilChainNetworkIsReady()
|
|||
echo "can take longer if device was off or first time"
|
||||
|
||||
# check for error on network
|
||||
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
|
||||
clienterror=`cat error.tmp`
|
||||
bitcoincli_alias getblockchaininfo 1>/dev/null 2>error.tmp
|
||||
clienterror=$(cat error.tmp)
|
||||
rm error.tmp
|
||||
|
||||
# check for missing blockchain data
|
||||
|
@ -438,7 +443,7 @@ How do you want to continue?
|
|||
while :
|
||||
do
|
||||
|
||||
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
|
||||
locked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
|
||||
if [ ${locked} -gt 0 ]; then
|
||||
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
|
||||
if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 300 ]; then
|
||||
|
@ -461,7 +466,7 @@ How do you want to continue?
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
lndSynced=$($lncli_alias getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
if [ ${lndSynced} -eq 0 ]; then
|
||||
/home/admin/80scanLND.sh
|
||||
if [ $? -gt 0 ]; then
|
||||
|
|
|
@ -85,7 +85,7 @@ if [ "${displayClass}" == "lcd" ]; then
|
|||
fi
|
||||
OPTIONS+=(a 'Channel Autopilot' ${autoPilot})
|
||||
OPTIONS+=(k 'Accept Keysend' ${keysend})
|
||||
OPTIONS+=(n 'Testnet' ${chainValue})
|
||||
# OPTIONS+=(n 'Testnet' ${chainValue}) #TODO remove related code
|
||||
OPTIONS+=(c 'Circuitbreaker (LND firewall)' ${circuitbreaker})
|
||||
OPTIONS+=(u 'LND Auto-Unlock' ${autoUnlock})
|
||||
OPTIONS+=(d 'StaticChannelBackup on DropBox' ${DropboxBackup})
|
||||
|
|
|
@ -23,6 +23,8 @@ if [ ${#sphinxrelay} -eq 0 ]; then sphinxrelay="off"; fi
|
|||
if [ ${#lit} -eq 0 ]; then lit="off"; fi
|
||||
if [ ${#whitepaper} -eq 0 ]; then whitepaper="off"; fi
|
||||
if [ ${#chantools} -eq 0 ]; then chantools="off"; fi
|
||||
if [ ${#testnet} -eq 0 ]; then testnet="off"; fi
|
||||
if [ ${#cln} -eq 0 ]; then cln="off"; fi
|
||||
|
||||
# show select dialog
|
||||
echo "run dialog ..."
|
||||
|
@ -43,10 +45,12 @@ OPTIONS+=(x 'Sphinx-Relay' ${sphinxrelay})
|
|||
OPTIONS+=(y 'PyBLOCK' ${pyblock})
|
||||
OPTIONS+=(c 'ChannelTools (Fund Rescue)' ${chantools})
|
||||
OPTIONS+=(w 'Download Bitcoin Whitepaper' ${whitepaper})
|
||||
OPTIONS+=(n 'Parallel Testnet services' ${testnet})
|
||||
OPTIONS+=(c 'C-lightning' ${cln})
|
||||
|
||||
CHOICES=$(dialog --title ' Additional Services ' \
|
||||
--checklist ' use spacebar to activate/de-activate ' \
|
||||
22 45 15 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
24 45 17 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
dialogcancel=$?
|
||||
echo "done dialog"
|
||||
|
@ -432,6 +436,56 @@ else
|
|||
echo "Whitepaper setting unchanged."
|
||||
fi
|
||||
|
||||
# testnet process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "n")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${testnet}" != "${choice}" ]; then
|
||||
echo "# Testnet Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/bitcoin.chains.sh ${choice} testnet
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed Testnet"
|
||||
echo
|
||||
echo "# Press ENTER to continue ..."
|
||||
read key
|
||||
else
|
||||
l1="# !!! FAIL on Testnet install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/bitcoin.chains.sh on testnet"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# Testnet Setting unchanged."
|
||||
fi
|
||||
|
||||
# cln process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "c")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${cln}" != "${choice}" ]; then
|
||||
echo "# C-lightning Setting changed .."
|
||||
anychange=1
|
||||
/home/admin/config.scripts/cln.install.sh ${choice}
|
||||
errorOnInstall=$?
|
||||
if [ "${choice}" = "on" ]; then
|
||||
if [ ${errorOnInstall} -eq 0 ]; then
|
||||
echo "# Successfully installed C-lightning"
|
||||
echo
|
||||
echo "# Press ENTER to continue ..."
|
||||
read key
|
||||
else
|
||||
l1="# !!! FAIL on C-lightning install !!!"
|
||||
l2="# Try manual install on terminal after reboot with:"
|
||||
l3="/home/admin/config.scripts/cln.install.sh on"
|
||||
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "# C-lightning Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${anychange} -eq 0 ]; then
|
||||
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
|
||||
exit 0
|
||||
|
|
137
home.admin/99clnMenu.sh
Normal file
137
home.admin/99clnMenu.sh
Normal file
|
@ -0,0 +1,137 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get raspiblitz config
|
||||
echo "# get raspiblitz config"
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
if [ $# -gt 0 ];then
|
||||
NETWORK=$1
|
||||
else
|
||||
NETWORK=${chain}net
|
||||
fi
|
||||
|
||||
# get the local network IP to be displayed on the LCD
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=13
|
||||
WIDTH=64
|
||||
CHOICE_HEIGHT=7
|
||||
BACKTITLE="RaspiBlitz"
|
||||
TITLE="C-Lightning Options"
|
||||
MENU=""
|
||||
OPTIONS=()
|
||||
|
||||
OPTIONS+=(FUNDING "Fund your C-Lightning Wallet")
|
||||
OPTIONS+=(PEERING "Connect to a Peer")
|
||||
OPTIONS+=(CHANNEL "Open a Channel with Peer")
|
||||
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
|
||||
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
|
||||
|
||||
if [ "${chain}" = "main" ]; then
|
||||
#TODO OPTIONS+=(lnbalance "Detailed Wallet Balances")
|
||||
#TODO OPTIONS+=(lnchannels "Lightning Channel List")
|
||||
#TODO OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report")
|
||||
HEIGHT=$((HEIGHT+3))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
|
||||
fi
|
||||
|
||||
#TODO OPTIONS+=(NAME "Change Name/Alias of Node")
|
||||
|
||||
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
|
||||
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
|
||||
#TODO OPTIONS+=(CLOSEALL "Close all open Channels")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
if [ ${#LNdefault} -gt 0 ]&&[ $LNdefault = lnd ];then
|
||||
OPTIONS+=(SWITCHLN "Use C-lightning as default")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
#TODO OPTIONS+=(CASHOUT "Remove Funds from LND")
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--ok-label "Select" \
|
||||
--cancel-label "Main menu" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
case $CHOICE in
|
||||
lnbalance)
|
||||
clear
|
||||
echo "*** YOUR SATOSHI BALANCES ***"
|
||||
/home/admin/config.scripts/lnd.balance.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnchannels)
|
||||
clear
|
||||
echo "*** YOUR LIGHTNING CHANNELS ***"
|
||||
echo ""
|
||||
echo "Capacity -> total sats in the channel (their side + your side)"
|
||||
echo "Commit-Fee -> the fee that's charged if either side of the channel closes"
|
||||
echo "Balance-Local -> sats on your side of the channel (outbound liquidity)"
|
||||
echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)"
|
||||
echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel"
|
||||
echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding"
|
||||
/home/admin/config.scripts/lnd.channels.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnfwdreport)
|
||||
/home/admin/config.scripts/lnd.fwdreport.sh -menu
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
PEERING)
|
||||
/home/admin/BBconnectPeer.sh cln $NETWORK
|
||||
;;
|
||||
FUNDING)
|
||||
/home/admin/BBfundWallet.sh cln $NETWORK
|
||||
;;
|
||||
CASHOUT)
|
||||
/home/admin/BBcashoutWallet.sh
|
||||
;;
|
||||
CHANNEL)
|
||||
/home/admin/BBopenChannel.sh cln $NETWORK
|
||||
;;
|
||||
SEND)
|
||||
/home/admin/BBpayInvoice.sh cln $NETWORK
|
||||
;;
|
||||
RECEIVE)
|
||||
/home/admin/BBcreateInvoice.sh cln $NETWORK
|
||||
;;
|
||||
NAME)
|
||||
sudo /home/admin/config.scripts/lnd.setname.sh
|
||||
noreboot=$?
|
||||
if [ "${noreboot}" = "0" ]; then
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
echo "Press ENTER to Reboot."
|
||||
read key
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
CLOSEALL)
|
||||
/home/admin/BBcloseAllChannels.sh
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
SWITCHLN)
|
||||
clear
|
||||
echo
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^LNdefault=.*/LNdefault=cln/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# OK - LNdefault=cln is set in /mnt/hdd/raspiblitz.conf"
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
esac
|
|
@ -171,7 +171,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
|
|||
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\
|
||||
grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf)
|
||||
bindIP=$(grep -c "rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
|
||||
bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
|
||||
rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc)
|
||||
TorRPCaddress=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname)
|
||||
|
||||
|
@ -239,7 +239,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
|
|||
restartCore=1
|
||||
fi
|
||||
if [ $bindIP -eq 0 ]; then
|
||||
echo "rpcbind=$localIP" | sudo tee -a /mnt/hdd/${network}/${network}.conf
|
||||
echo "${chain}.rpcbind=$localIP" | sudo tee -a /mnt/hdd/${network}/${network}.conf
|
||||
restartCore=1
|
||||
fi
|
||||
if [ $restartCore = 1 ];then
|
||||
|
@ -286,7 +286,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
|
|||
restartCore=1
|
||||
fi
|
||||
if [ $bindIP -gt 0 ]; then
|
||||
sudo sed -i "/^rpcbind=$localIP/d" /mnt/hdd/${network}/${network}.conf
|
||||
sudo sed -i "/^${chain}.rpcbind=$localIP/d" /mnt/hdd/${network}/${network}.conf
|
||||
restartCore=1
|
||||
fi
|
||||
if [ $restartCore = 1 ];then
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get raspiblitz config
|
||||
echo "get raspiblitz config"
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# get the local network IP to be displayed on the LCD
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=13
|
||||
WIDTH=64
|
||||
CHOICE_HEIGHT=7
|
||||
BACKTITLE="RaspiBlitz"
|
||||
TITLE="Lightning Options"
|
||||
MENU=""
|
||||
OPTIONS=()
|
||||
|
||||
OPTIONS+=(FUNDING "Fund your LND Wallet")
|
||||
OPTIONS+=(PEERING "Connect to a Peer")
|
||||
OPTIONS+=(CHANNEL "Open a Channel with Peer")
|
||||
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
|
||||
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
|
||||
|
||||
if [ "${chain}" = "main" ]; then
|
||||
OPTIONS+=(lnbalance "Detailed Wallet Balances")
|
||||
OPTIONS+=(lnchannels "Lightning Channel List")
|
||||
OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report")
|
||||
HEIGHT=$((HEIGHT+3))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
|
||||
fi
|
||||
|
||||
OPTIONS+=(NAME "Change Name/Alias of Node")
|
||||
|
||||
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
|
||||
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
|
||||
OPTIONS+=(CLOSEALL "Close all open Channels")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
OPTIONS+=(CASHOUT "Remove Funds from LND")
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--ok-label "Select" \
|
||||
--cancel-label "Main menu" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
case $CHOICE in
|
||||
lnbalance)
|
||||
clear
|
||||
echo "*** YOUR SATOSHI BALANCES ***"
|
||||
/home/admin/config.scripts/lnd.balance.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnchannels)
|
||||
clear
|
||||
echo "*** YOUR LIGHTNING CHANNELS ***"
|
||||
echo ""
|
||||
echo "Capacity -> total sats in the channel (their side + your side)"
|
||||
echo "Commit-Fee -> the fee that's charged if either side of the channel closes"
|
||||
echo "Balance-Local -> sats on your side of the channel (outbound liquidity)"
|
||||
echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)"
|
||||
echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel"
|
||||
echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding"
|
||||
/home/admin/config.scripts/lnd.channels.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnfwdreport)
|
||||
/home/admin/config.scripts/lnd.fwdreport.sh -menu
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
PEERING)
|
||||
/home/admin/BBconnectPeer.sh
|
||||
;;
|
||||
FUNDING)
|
||||
/home/admin/BBfundWallet.sh
|
||||
;;
|
||||
CASHOUT)
|
||||
/home/admin/BBcashoutWallet.sh
|
||||
;;
|
||||
CHANNEL)
|
||||
/home/admin/BBopenChannel.sh
|
||||
;;
|
||||
SEND)
|
||||
/home/admin/BBpayInvoice.sh
|
||||
;;
|
||||
RECEIVE)
|
||||
/home/admin/BBcreateInvoice.sh
|
||||
;;
|
||||
NAME)
|
||||
sudo /home/admin/config.scripts/lnd.setname.sh
|
||||
noreboot=$?
|
||||
if [ "${noreboot}" = "0" ]; then
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
echo "Press ENTER to Reboot."
|
||||
read key
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
CLOSEALL)
|
||||
/home/admin/BBcloseAllChannels.sh
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
esac
|
131
home.admin/99lndMenu.sh
Normal file
131
home.admin/99lndMenu.sh
Normal file
|
@ -0,0 +1,131 @@
|
|||
#!/bin/bash
|
||||
|
||||
# get raspiblitz config
|
||||
echo "get raspiblitz config"
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# get the local network IP to be displayed on the LCD
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# BASIC MENU INFO
|
||||
HEIGHT=13
|
||||
WIDTH=64
|
||||
CHOICE_HEIGHT=7
|
||||
BACKTITLE="RaspiBlitz"
|
||||
TITLE="Lightning Options"
|
||||
MENU=""
|
||||
OPTIONS=()
|
||||
|
||||
OPTIONS+=(FUNDING "Fund your LND Wallet")
|
||||
OPTIONS+=(PEERING "Connect to a Peer")
|
||||
OPTIONS+=(CHANNEL "Open a Channel with Peer")
|
||||
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
|
||||
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
|
||||
|
||||
if [ "${chain}" = "main" ]; then
|
||||
OPTIONS+=(lnbalance "Detailed Wallet Balances")
|
||||
OPTIONS+=(lnchannels "Lightning Channel List")
|
||||
OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report")
|
||||
HEIGHT=$((HEIGHT+3))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
|
||||
fi
|
||||
|
||||
OPTIONS+=(NAME "Change Name/Alias of Node")
|
||||
|
||||
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
|
||||
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
|
||||
OPTIONS+=(CLOSEALL "Close all open Channels")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
OPTIONS+=(CASHOUT "Remove Funds from LND")
|
||||
if [ ${#LNdefault} -gt 0 ]&&[ $LNdefault = cln ];then
|
||||
OPTIONS+=(SWITCHLN "Use LND as default")
|
||||
HEIGHT=$((HEIGHT+1))
|
||||
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
|
||||
fi
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--ok-label "Select" \
|
||||
--cancel-label "Main menu" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
case $CHOICE in
|
||||
lnbalance)
|
||||
clear
|
||||
echo "*** YOUR SATOSHI BALANCES ***"
|
||||
/home/admin/config.scripts/lnd.balance.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnchannels)
|
||||
clear
|
||||
echo "*** YOUR LIGHTNING CHANNELS ***"
|
||||
echo ""
|
||||
echo "Capacity -> total sats in the channel (their side + your side)"
|
||||
echo "Commit-Fee -> the fee that's charged if either side of the channel closes"
|
||||
echo "Balance-Local -> sats on your side of the channel (outbound liquidity)"
|
||||
echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)"
|
||||
echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel"
|
||||
echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding"
|
||||
/home/admin/config.scripts/lnd.channels.sh ${network}
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
lnfwdreport)
|
||||
/home/admin/config.scripts/lnd.fwdreport.sh -menu
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
PEERING)
|
||||
/home/admin/BBconnectPeer.sh
|
||||
;;
|
||||
FUNDING)
|
||||
/home/admin/BBfundWallet.sh
|
||||
;;
|
||||
CASHOUT)
|
||||
/home/admin/BBcashoutWallet.sh
|
||||
;;
|
||||
CHANNEL)
|
||||
/home/admin/BBopenChannel.sh
|
||||
;;
|
||||
SEND)
|
||||
/home/admin/BBpayInvoice.sh
|
||||
;;
|
||||
RECEIVE)
|
||||
/home/admin/BBcreateInvoice.sh
|
||||
;;
|
||||
NAME)
|
||||
sudo /home/admin/config.scripts/lnd.setname.sh
|
||||
noreboot=$?
|
||||
if [ "${noreboot}" = "0" ]; then
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
echo "Press ENTER to Reboot."
|
||||
read key
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
CLOSEALL)
|
||||
/home/admin/BBcloseAllChannels.sh
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
SWITCHLN)
|
||||
clear
|
||||
echo
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^LNdefault=.*/LNdefault=lnd/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# OK - LNdefault=lnd is set in /mnt/hdd/raspiblitz.conf"
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
;;
|
||||
esac
|
|
@ -12,7 +12,13 @@ if [ ${#chain} -eq 0 ]; then
|
|||
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
|
||||
fi
|
||||
|
||||
# set ntwork map info
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# set network map info
|
||||
networkMap="https://lnmainnet.gaben.win"
|
||||
if [ "$network" = "litecoin" ]; then
|
||||
networkMap="https://lnexplorer.hcwong.me"
|
||||
|
@ -22,9 +28,14 @@ if [ "$chain" = "test" ]; then
|
|||
fi
|
||||
|
||||
# let user enter a <pubkey>@host
|
||||
|
||||
l1="Enter the node pubkey address with host information:"
|
||||
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735"
|
||||
l3="node directory -> 1ml.com"
|
||||
if [ "$chain" = "main" ]; then
|
||||
l3="node directory -> https://1ml.com"
|
||||
elif [ "$chain" = "test" ]; then
|
||||
l3="node directory -> https://1ml.com/testnet"
|
||||
fi
|
||||
dialog --title "Open a Connection to a Peer" \
|
||||
--backtitle "Lightning ( ${network} | ${chain} )" \
|
||||
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
|
||||
|
@ -38,18 +49,26 @@ if [ ${#_input} -eq 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
pubkey=$(echo $_input|cut -d@ -f1)
|
||||
address=$(echo ${_input}|cut -d@ -f2|cut -d: -f1)
|
||||
port=$(echo ${_input}|cut -d: -f2)
|
||||
# build command
|
||||
command="lncli --chain=${network} --network=${chain}net connect ${_input}"
|
||||
if [ $LNTYPE = cln ];then
|
||||
# connect id [host port]
|
||||
command="$lightningcli_alias connect $pubkey $address $port"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
command="$lncli_alias connect ${pubkey}@${address}:${port}"
|
||||
fi
|
||||
|
||||
# info output
|
||||
clear
|
||||
echo "******************************"
|
||||
echo "Connect to A Lightning Node"
|
||||
echo "******************************"
|
||||
echo ""
|
||||
echo
|
||||
echo "COMMAND LINE: "
|
||||
echo $command
|
||||
echo ""
|
||||
echo
|
||||
echo "RESULT (might have to wait for timeout):"
|
||||
|
||||
win=1
|
||||
|
@ -82,13 +101,13 @@ if [ ${#result} -eq 0 ]; then
|
|||
info="No return value. Error not known."
|
||||
|
||||
# try to get error output
|
||||
result=`cat ${_error}`
|
||||
result=$(cat "${_error}")
|
||||
echo "$result"
|
||||
|
||||
# basic cli error
|
||||
cliError=$(echo "${result}" | grep "[lncli]" -c )
|
||||
if [ ${cliError} -gt 0 ]; then
|
||||
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli."
|
||||
info="It's possible that the lightning daemon is not running, not configured correct or not connected to the cli."
|
||||
fi
|
||||
|
||||
else
|
||||
|
@ -97,8 +116,11 @@ else
|
|||
echo "$result"
|
||||
|
||||
# check if the node is now in peer list
|
||||
pubkey=$(echo $_input | cut -d '@' -f1)
|
||||
isPeer=$(lncli --chain=${network} --network=${chain}net listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
if [ $LNTYPE = cln ];then
|
||||
isPeer=$($lightningcli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
isPeer=$($lncli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
fi
|
||||
if [ ${isPeer} -eq 0 ]; then
|
||||
|
||||
# basic error message
|
||||
|
@ -114,14 +136,14 @@ else
|
|||
fi
|
||||
|
||||
# output info
|
||||
echo ""
|
||||
echo
|
||||
if [ ${win} -eq 1 ]; then
|
||||
echo "******************************"
|
||||
echo "WIN"
|
||||
echo "******************************"
|
||||
echo "${info}"
|
||||
echo ""
|
||||
echo "Whats next? --> Open a channel with that node."
|
||||
echo
|
||||
echo "What's next? --> Open a channel with that node."
|
||||
else
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "FAIL"
|
||||
|
@ -129,6 +151,6 @@ else
|
|||
echo "${info}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
|
@ -14,16 +14,22 @@ if [ ${#chain} -eq 0 ]; then
|
|||
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# Check if ready (chain in sync and channels open)
|
||||
./XXchainInSync.sh $network $chain
|
||||
./XXchainInSync.sh $network $chain $LNTYPE
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# let user enter the invoice
|
||||
l1="Enter the AMOUNT IN SATOSHI of the invoice:"
|
||||
l1="Enter the AMOUNT IN SATOSHIS to invoice:"
|
||||
l2="1 ${network} = 100 000 000 SAT"
|
||||
dialog --title "Pay thru Lightning Network" \
|
||||
dialog --title "Request payment through Lightning" \
|
||||
--inputbox "$l1\n$l2" 9 50 2>$_temp
|
||||
amount=$(cat $_temp | xargs | tr -dc '0-9')
|
||||
shred -u $_temp
|
||||
|
@ -38,23 +44,30 @@ fi
|
|||
# TODO let user enter a description
|
||||
|
||||
# build command
|
||||
command="lncli --chain=${network} --network=${chain}net addinvoice ${amount}"
|
||||
if [ $LNTYPE = cln ];then
|
||||
label=$(date +%s) # seconds since 1970-01-01 00:00:00 UTC
|
||||
# invoice msatoshi label description [expiry] [fallbacks] [preimage] [exposeprivatechannels] [cltv]
|
||||
command="$lightningcli_alias invoice ${amount}sat $label ''"
|
||||
# TODO warn about insufficient liquidity
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
command="$lncli_alias addinvoice ${amount}"
|
||||
fi
|
||||
|
||||
# info output
|
||||
clear
|
||||
echo "******************************"
|
||||
echo "Create Invoice / Payment Request"
|
||||
echo "******************************"
|
||||
echo ""
|
||||
echo
|
||||
echo "COMMAND LINE: "
|
||||
echo $command
|
||||
echo ""
|
||||
echo
|
||||
echo "RESULT:"
|
||||
sleep 2
|
||||
|
||||
# execute command
|
||||
result=$($command 2>$_error)
|
||||
error=`cat ${_error} 2>/dev/null`
|
||||
error=$(cat ${_error} 2>/dev/null)
|
||||
|
||||
#echo "result(${result})"
|
||||
#echo "error(${error})"
|
||||
|
@ -65,9 +78,12 @@ if [ ${#error} -gt 0 ]; then
|
|||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "${error}"
|
||||
else
|
||||
|
||||
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
|
||||
payReq=$(echo "$result" | grep payment_request | cut -d '"' -f4)
|
||||
if [ $LNTYPE = cln ];then
|
||||
payReq=$(echo "$result" | grep bolt11 | cut -d '"' -f4)
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
|
||||
payReq=$(echo "$result" | grep payment_request | cut -d '"' -f4)
|
||||
fi
|
||||
/home/admin/config.scripts/blitz.display.sh qr "${payReq}"
|
||||
|
||||
if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then
|
||||
|
@ -86,19 +102,27 @@ else
|
|||
echo "${payReq}"
|
||||
echo
|
||||
echo "Monitoring the Incoming Payment with:"
|
||||
echo "lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}"
|
||||
if [ $LNTYPE = cln ];then
|
||||
echo "$lightningcli_alias waitinvoice $label"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
echo "$lncli_alias lookupinvoice ${rhash}"
|
||||
fi
|
||||
echo "Press x and hold to skip to menu."
|
||||
|
||||
while :
|
||||
do
|
||||
|
||||
result=$(lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash})
|
||||
wasPayed=$(echo $result | grep -c '"settled": true')
|
||||
if [ $LNTYPE = cln ];then
|
||||
result=$($lightningcli_alias waitinvoice $label)
|
||||
wasPayed=$(echo $result | grep -c 'paid')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
result=$($lncli_alias lookupinvoice ${rhash})
|
||||
wasPayed=$(echo $result | grep -c '"settled": true')
|
||||
fi
|
||||
if [ ${wasPayed} -gt 0 ]; then
|
||||
echo
|
||||
echo $result
|
||||
echo
|
||||
echo "Returning to menu - OK Invoice payed."
|
||||
echo "OK the Invoice was paid - returning to menu."
|
||||
/home/admin/config.scripts/blitz.display.sh hide
|
||||
/home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/ok.png
|
||||
sleep 2
|
||||
|
|
|
@ -11,28 +11,55 @@ if [ ${#chain} -eq 0 ]; then
|
|||
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# PRECHECK) check if chain is in sync
|
||||
chainOutSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": false' -c)
|
||||
if [ $LNTYPE = cln ];then
|
||||
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
|
||||
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
|
||||
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
|
||||
chainOutSync=0
|
||||
else
|
||||
chainOutSync=1
|
||||
fi
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
|
||||
fi
|
||||
if [ ${chainOutSync} -eq 1 ]; then
|
||||
echo "FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
|
||||
echo ""
|
||||
echo "PRESS ENTER to return to menu"
|
||||
if [ $LNTYPE = cln ];then
|
||||
echo "# FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
|
||||
else
|
||||
echo "# FAIL PRECHECK - 'lightning-cli getinfo' blockheight is different from 'bitcoind getblockchaininfo' - wait until chain is sync "
|
||||
fi
|
||||
echo
|
||||
echo "# PRESS ENTER to return to menu"
|
||||
read key
|
||||
exit 1
|
||||
else
|
||||
echo "# OK - the chain is synced"
|
||||
fi
|
||||
|
||||
# execute command
|
||||
echo "calling lncli ... please wait"
|
||||
command="lncli --chain=${network} --network=${chain}net newaddress p2wkh"
|
||||
if [ $LNTYPE = cln ];then
|
||||
command="$lightningcli_alias newaddr bech32"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
command="$lncli_alias newaddress p2wkh"
|
||||
fi
|
||||
echo "# Calling:"
|
||||
echo "${command}"
|
||||
echo
|
||||
result=$($command)
|
||||
echo "$result"
|
||||
|
||||
# on no result
|
||||
if [ ${#result} -eq 0 ]; then
|
||||
echo "Empty result - sorry something went wrong - thats unusual."
|
||||
echo ""
|
||||
echo "PRESS ENTER to return to menu"
|
||||
echo "# Empty result - sorry something went wrong - that is unusual."
|
||||
echo
|
||||
echo "# Press ENTER to return to menu"
|
||||
read key
|
||||
exit 1
|
||||
fi
|
||||
|
@ -58,7 +85,7 @@ echo "generating QR code ... please wait"
|
|||
/home/admin/config.scripts/blitz.display.sh qr "$network:${address}"
|
||||
|
||||
# dialog with instructions while QR code is shown on LCD
|
||||
whiptail --backtitle "Fund your on chain wallet" \
|
||||
whiptail --backtitle "Fund your onchain wallet" \
|
||||
--title "Send ${coininfo}" \
|
||||
--yes-button "DONE" \
|
||||
--no-button "Console QRcode" \
|
||||
|
@ -73,6 +100,11 @@ fi
|
|||
/home/admin/config.scripts/blitz.display.sh hide
|
||||
|
||||
# follow up info
|
||||
whiptail --backtitle "Fund your on chain wallet" \
|
||||
if [ $LNTYPE = cln ];then
|
||||
string="Wait for confirmations."
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
string="Wait for confirmations. \n\nYou can use info on LCD to check if funds have arrived. \n\nIf you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'"
|
||||
fi
|
||||
whiptail --backtitle "Fund your onchain wallet" \
|
||||
--title "What's next?" \
|
||||
--msgbox "Wait for confirmations. \n\nYou can use info on LCD to check if funds have arrived. \n\nIf you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'" 0 0
|
||||
--msgbox "$string" 0 0
|
|
@ -12,38 +12,72 @@ if [ ${#chain} -eq 0 ]; then
|
|||
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
echo ""
|
||||
echo "*** Precheck ***"
|
||||
|
||||
# check if chain is in sync
|
||||
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c)
|
||||
if [ ${chainInSync} -eq 0 ]; then
|
||||
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
|
||||
echo "Wait until chain is sync with LND and try again."
|
||||
echo ""
|
||||
echo "Press ENTER to return to main menu."
|
||||
# PRECHECK) check if chain is in sync
|
||||
if [ $LNTYPE = cln ];then
|
||||
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
|
||||
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
|
||||
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
|
||||
chainOutSync=0
|
||||
else
|
||||
chainOutSync=1
|
||||
fi
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
|
||||
fi
|
||||
if [ ${chainOutSync} -eq 1 ]; then
|
||||
if [ $LNTYPE = cln ];then
|
||||
echo "# FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
|
||||
else
|
||||
echo "# FAIL PRECHECK - 'lightning-cli getinfo' blockheight is different from 'bitcoind getblockchaininfo' - wait until chain is sync "
|
||||
fi
|
||||
echo
|
||||
echo "# PRESS ENTER to return to menu"
|
||||
read key
|
||||
exit 1
|
||||
else
|
||||
echo "# OK - the chain is synced"
|
||||
fi
|
||||
|
||||
# check available funding
|
||||
confirmedBalance=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
|
||||
if [ $LNTYPE = cln ];then
|
||||
for i in $($lightningcli_alias \
|
||||
listfunds|jq .outputs[]|jq 'select(.status=="confirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
|
||||
confirmedBalance=$((confirmedBalance+i))
|
||||
done
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
confirmedBalance=$($lncli_alias walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
|
||||
fi
|
||||
|
||||
if [ ${confirmedBalance} -eq 0 ]; then
|
||||
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet."
|
||||
echo "Please fund your on-chain wallet first and wait until confirmed."
|
||||
echo ""
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check number of connected peers
|
||||
numConnectedPeers=$(lncli --chain=${network} --network=${chain}net listpeers | grep pub_key -c)
|
||||
if [ $LNTYPE = cln ];then
|
||||
numConnectedPeers=$($lightningcli_alias listpeers | grep -c '"id":')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
numConnectedPeers=$($lncli_alias listpeers | grep pub_key -c)
|
||||
fi
|
||||
|
||||
if [ ${numConnectedPeers} -eq 0 ]; then
|
||||
echo "FAIL - no peers connected on lightning network"
|
||||
echo "FAIL - no peers connected on the lightning network"
|
||||
echo "You can only open channels to peer nodes to connected to first."
|
||||
echo "Use CONNECT peer option in main menu first."
|
||||
echo ""
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
exit 1
|
||||
|
@ -51,12 +85,21 @@ fi
|
|||
|
||||
# let user pick a peer to open a channels with
|
||||
OPTIONS=()
|
||||
while IFS= read -r grepLine
|
||||
do
|
||||
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
|
||||
#echo "grepLine(${pubKey})"
|
||||
OPTIONS+=(${pubKey} "")
|
||||
done < <(lncli --chain=${network} --network=${chain}net listpeers | grep pub_key)
|
||||
if [ $LNTYPE = cln ];then
|
||||
while IFS= read -r grepLine
|
||||
do
|
||||
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
|
||||
# echo "grepLine(${pubKey})"
|
||||
OPTIONS+=(${pubKey} "")
|
||||
done < <(lightningcli_alias listpeers | grep '"id":')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
while IFS= read -r grepLine
|
||||
do
|
||||
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
|
||||
# echo "grepLine(${pubKey})"
|
||||
OPTIONS+=(${pubKey} "")
|
||||
done < <(lncli_alias listpeers | grep pub_key)
|
||||
fi
|
||||
TITLE="Open (Payment) Channel"
|
||||
MENU="\nChoose a peer you connected to, to open the channel with: \n "
|
||||
pubKey=$(dialog --clear \
|
||||
|
@ -68,11 +111,11 @@ pubKey=$(dialog --clear \
|
|||
|
||||
clear
|
||||
if [ ${#pubKey} -eq 0 ]; then
|
||||
clear
|
||||
echo
|
||||
echo "no channel selected - returning to menu ..."
|
||||
sleep 4
|
||||
exit 1
|
||||
clear
|
||||
echo
|
||||
echo "no channel selected - returning to menu ..."
|
||||
sleep 4
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# find out what is the minimum amount
|
||||
|
@ -82,15 +125,17 @@ minSat=20000
|
|||
if [ "${network}" = "bitcoin" ]; then
|
||||
minSat=50000
|
||||
fi
|
||||
_error="./.error.out"
|
||||
lncli --chain=${network} openchannel --network=${chain}net ${CHOICE} 1 0 2>$_error
|
||||
error=`cat ${_error}`
|
||||
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
|
||||
minSat=$(echo "${error}" | tr -dc '0-9')
|
||||
if [ $LNTYPE = lnd ];then
|
||||
_error="./.error.out"
|
||||
lncli_alias openchannel ${pubkey} 1 0 2>$_error
|
||||
error=$(cat ${_error})
|
||||
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
|
||||
minSat=$(echo "${error}" | tr -dc '0-9')
|
||||
fi
|
||||
fi
|
||||
|
||||
# let user enter an amount
|
||||
l1="Amount in SATOSHI to fund this channel:"
|
||||
l1="Amount in satoshis to fund this channel:"
|
||||
l2="min required : ${minSat}"
|
||||
l3="max available : ${confirmedBalance}"
|
||||
dialog --title "Funding of Channel" \
|
||||
|
@ -119,22 +164,27 @@ if [ ${#conf_target} -eq 0 ]; then
|
|||
fi
|
||||
|
||||
# build command
|
||||
command="lncli --chain=${network} --network=${chain}net openchannel --conf_target=${conf_target} ${pubKey} ${amount} 0"
|
||||
|
||||
if [ $LNTYPE = cln ];then
|
||||
# fundchannel id amount [feerate] [announce] [minconf] [utxos] [push_msat] [close_to]
|
||||
feerate=$($bitcoincli_alias estimatesmartfee $conf_target |grep feerate|awk '{print $2}'|cut -c 5-7|bc)
|
||||
command="lightningcli_alias fundchannel ${pubKey} ${amount} $feerate"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
command="lncli_alias openchannel --conf_target=${conf_target} ${pubKey} ${amount} 0"
|
||||
fi
|
||||
# info output
|
||||
clear
|
||||
echo "******************************"
|
||||
echo "Open Channel"
|
||||
echo "******************************"
|
||||
echo ""
|
||||
echo
|
||||
echo "COMMAND LINE: "
|
||||
echo $command
|
||||
echo ""
|
||||
echo
|
||||
echo "RESULT:"
|
||||
|
||||
# execute command
|
||||
result=$($command 2>$_error)
|
||||
error=`cat ${_error}`
|
||||
result=$(eval $command 2>$_error)
|
||||
error=$(cat ${_error})
|
||||
|
||||
#echo "result(${result})"
|
||||
#echo "error(${error})"
|
||||
|
@ -149,20 +199,33 @@ else
|
|||
echo "WIN"
|
||||
echo "******************************"
|
||||
echo "${result}"
|
||||
echo ""
|
||||
echo "Whats next? --> You need to wait 3 confirmations, for the channel to be ready."
|
||||
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
|
||||
echo
|
||||
echo "What's next? --> You need to wait 3 confirmations for the channel to be ready."
|
||||
if [ $LNTYPE = cln ];then
|
||||
fundingTX=$(echo "${result}" | grep 'txid' | cut -d '"' -f4)
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
|
||||
fi
|
||||
echo
|
||||
if [ "${network}" = "bitcoin" ]; then
|
||||
if [ "${chain}" = "main" ]; then
|
||||
echo "https://live.blockcypher.com/btc/tx/${fundingTX}"
|
||||
else
|
||||
echo "https://live.blockcypher.com/btc-testnet/tx/${fundingTX}"
|
||||
#echo "https://live.blockcypher.com/btc/tx/${fundingTX}"
|
||||
echo "https://mempool.space/tx/${fundingTX}"
|
||||
elif [ "${chain}" = "test" ]||[ "${chain}" = "sig" ]; then
|
||||
echo "https://mempool.space/${chain}net/tx/${fundingTX}"
|
||||
fi
|
||||
echo
|
||||
echo "In the Tor Browser:"
|
||||
if [ "${chain}" = "main" ]; then
|
||||
echo "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/tx/${fundingTX}"
|
||||
elif [ "${chain}" = "test" ]||[ "${chain}" = "sig" ]; then
|
||||
echo "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/${chain}net/tx/${fundingTX}"
|
||||
fi
|
||||
fi
|
||||
if [ "${network}" = "litecoin" ]; then
|
||||
echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
|
@ -14,8 +14,14 @@ if [ ${#chain} -eq 0 ]; then
|
|||
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# Check if ready (chain in sync and channels open)
|
||||
./XXchainInSync.sh $network $chain
|
||||
./XXchainInSync.sh $network $chain $LNTYPE
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
@ -36,7 +42,7 @@ if [ "${network}" = "bitcoin" ]; then
|
|||
if [ "${chain}" = "main" ]; then
|
||||
testSite="https://satoshis.place"
|
||||
else
|
||||
testSite="https://testnet.satoshis.place"
|
||||
testSite="https://starblocks.acinq.co/"
|
||||
fi
|
||||
elif [ "${network}" = "litecoin" ]; then
|
||||
testSite="https://millionlitecoinhomepage.net"
|
||||
|
@ -46,7 +52,7 @@ fi
|
|||
l1="Copy the LightningInvoice/PaymentRequest into here:"
|
||||
l2="Its a long string starting with '${paymentRequestStart}'"
|
||||
l3="To try it out go to: ${testSite}"
|
||||
dialog --title "Pay thru Lightning Network" \
|
||||
dialog --title "Pay through the Lightning Network" \
|
||||
--inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp
|
||||
invoice=$(cat $_temp | xargs)
|
||||
shred -u $_temp
|
||||
|
@ -61,7 +67,12 @@ fi
|
|||
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq
|
||||
|
||||
# build command
|
||||
command="lncli --chain=${network} --network=${chain}net sendpayment --force --pay_req=${invoice}"
|
||||
if [ $LNTYPE = cln ];then
|
||||
# pay bolt11 [msatoshi] [label] [riskfactor] [maxfeepercent] [retry_for] [maxdelay] [exemptfee]
|
||||
command="$lightningcli_alias pay ${invoice}"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
command="$lncli_alias sendpayment --force --pay_req=${invoice}"
|
||||
fi
|
||||
|
||||
# info output
|
||||
clear
|
||||
|
@ -70,20 +81,24 @@ echo "Pay Invoice / Payment Request"
|
|||
echo "This script is as an example how to use the lncli interface."
|
||||
echo "Its not optimized for performance or error handling."
|
||||
echo "************************************************************"
|
||||
echo ""
|
||||
echo
|
||||
echo "COMMAND LINE: "
|
||||
echo $command
|
||||
echo ""
|
||||
echo
|
||||
echo "RESULT (may wait in case of timeout):"
|
||||
|
||||
# execute command
|
||||
result=$($command 2>$_error)
|
||||
error=`cat ${_error}`
|
||||
error=$(cat ${_error})
|
||||
|
||||
#echo "result(${result})"
|
||||
#echo "error(${error})"
|
||||
|
||||
resultIsError=$(echo "${result}" | grep -c "payment_error")
|
||||
if [ $LNTYPE = cln ];then
|
||||
resultIsError=$(echo "${result}" | grep -c '"code":')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
resultIsError=$(echo "${result}" | grep -c "payment_error")
|
||||
fi
|
||||
if [ ${resultIsError} -gt 0 ]; then
|
||||
error="${result}"
|
||||
fi
|
||||
|
@ -99,8 +114,8 @@ else
|
|||
echo "******************************"
|
||||
echo "WIN"
|
||||
echo "******************************"
|
||||
echo "It worked :) - check out the service you were paying."
|
||||
echo "It worked :) - check the service you were paying."
|
||||
fi
|
||||
echo ""
|
||||
echo
|
||||
echo "Press ENTER to return to main menu."
|
||||
read key
|
||||
|
|
|
@ -7,14 +7,39 @@
|
|||
network=$1
|
||||
chain=$2
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 2 ];then
|
||||
LNTYPE=$3
|
||||
else
|
||||
LNTYPE=lnd
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# check if chain is in sync
|
||||
cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c"
|
||||
if [ $LNTYPE = cln ];then
|
||||
lncommand="lightning-cli"
|
||||
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
|
||||
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
|
||||
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
|
||||
cmdChainInSync=1
|
||||
else
|
||||
cmdChainInSync=0
|
||||
fi
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
lncommand="lncli"
|
||||
cmdChainInSync="lncli_alias getinfo | grep '"synced_to_chain": true' -c"
|
||||
fi
|
||||
chainInSync=${cmdChainInSync}
|
||||
while [ "${chainInSync}" == "0" ]; do
|
||||
dialog --title "Fail: not in sync" \
|
||||
--ok-label "Try now" \
|
||||
--cancel-label "Give up" \
|
||||
--pause "\n\n'lncli getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
|
||||
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
exit 1
|
||||
|
@ -24,13 +49,17 @@ done
|
|||
|
||||
# check number of connected peers
|
||||
echo "check for open channels"
|
||||
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c)
|
||||
if [ $LNTYPE = cln ];then
|
||||
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
|
||||
fi
|
||||
if [ ${openChannels} -eq 0 ]; then
|
||||
echo ""
|
||||
echo
|
||||
echo "!!!!!!!!!!!!!!!!!!!"
|
||||
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
|
||||
echo "!!!!!!!!!!!!!!!!!!!"
|
||||
echo ""
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# source aliases from /home/admin/_aliases.sh
|
||||
source /home/admin/_aliases.sh
|
||||
|
||||
# SHORTCUT COMMANDS you can call as user 'admin' from terminal
|
||||
|
||||
# command: raspiblitz
|
||||
|
@ -123,7 +126,24 @@ function torthistx() {
|
|||
# start the status screen in the terminal
|
||||
function status() {
|
||||
echo "Gathering data - please wait a moment..."
|
||||
sudo -u pi /home/admin/00infoLCD.sh --pause 0
|
||||
while :
|
||||
do
|
||||
# show the same info as on LCD screen
|
||||
# 00infoBlitz.sh <cln|lnd> <testnet|mainnet|signet>
|
||||
/home/admin/00infoBlitz.sh $1 $2
|
||||
# wait 6 seconds for user exiting loop
|
||||
#echo
|
||||
#echo -en "Screen is updating in a loop .... press 'x' now to get back to menu."
|
||||
read -n 1 -t 6 keyPressed
|
||||
#echo -en "\rGathering information to update info ... please wait. \n"
|
||||
# check if user wants to abort session
|
||||
if [ "${keyPressed}" = "x" ]; then
|
||||
echo
|
||||
echo "Returning to menu ....."
|
||||
sleep 4
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# command: lnbalance
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
home.admin/assets/raspiblitz-v1.7.0-2021-04-25.img.gz.torrent
Executable file
BIN
home.admin/assets/raspiblitz-v1.7.0-2021-04-25.img.gz.torrent
Executable file
Binary file not shown.
216
home.admin/config.scripts/bitcoin.chains.sh
Normal file
216
home.admin/config.scripts/bitcoin.chains.sh
Normal file
|
@ -0,0 +1,216 @@
|
|||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
||||
echo
|
||||
echo "Install or remove parallel chains for Bitcoin Core"
|
||||
echo "network.bitcoinchains.sh [on|off] [signet|testnet|mainnet]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
CHAIN=$2
|
||||
if [ ${CHAIN} = signet ]||[ ${CHAIN} = testnet ]||[ ${CHAIN} = mainnet ];then
|
||||
echo "# Installing Bitcoin Core instance on ${CHAIN}"
|
||||
else
|
||||
echo "# ${CHAIN} is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# prefix for parallel services
|
||||
if [ ${CHAIN} = testnet ];then
|
||||
prefix="t"
|
||||
bitcoinprefix=test
|
||||
zmqprefix=21 # zmqpubrawblock=21332 zmqpubrawtx=21333
|
||||
rpcprefix=1 # rpcport=18332
|
||||
elif [ ${CHAIN} = signet ];then
|
||||
prefix="s"
|
||||
bitcoinprefix=signet
|
||||
zmqprefix=23
|
||||
rpcprefix=3
|
||||
elif [ ${CHAIN} = mainnet ];then
|
||||
prefix=""
|
||||
bitcoinprefix=main
|
||||
zmqprefix=28
|
||||
rpcprefix=""
|
||||
fi
|
||||
|
||||
function removeParallelService() {
|
||||
if [ -f "/etc/systemd/system/${prefix}bitcoind.service" ];then
|
||||
if [ ${CHAIN} != mainnet ];then
|
||||
/usr/local/bin/bitcoin-cli -${CHAIN} stop
|
||||
else
|
||||
/usr/local/bin/bitcoin-cli stop
|
||||
fi
|
||||
sudo systemctl stop ${prefix}bitcoind
|
||||
sudo systemctl disable ${prefix}bitcoind
|
||||
echo "# Bitcoin Core on ${CHAIN} service is stopped and disabled"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
function installParallelService() {
|
||||
# bitcoin.conf
|
||||
if [ ! -f /home/bitcoin/.bitcoin/bitcoin.conf ];then
|
||||
# add minimal config
|
||||
randomRPCpass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8)
|
||||
echo "
|
||||
# bitcoind configuration for ${CHAIN}
|
||||
|
||||
# Connection settings
|
||||
rpcuser=raspiblitz
|
||||
rpcpassword=$randomRPCpass
|
||||
${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
|
||||
${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333
|
||||
|
||||
onlynet=onion
|
||||
proxy=127.0.0.1:9050
|
||||
|
||||
datadir=/mnt/hdd/bitcoin
|
||||
" | sudo -u bitcoin tee /home/bitcoin/.bitcoin/bitcoin.conf
|
||||
else
|
||||
echo "# /home/bitcoin/.bitcoin/bitcoin.conf is present"
|
||||
fi
|
||||
|
||||
# make sure rpcbind is correctly configured
|
||||
sudo sed -i s/^rpcbind=/main.rpcbind=/g /mnt/hdd/${network}/${network}.conf
|
||||
|
||||
# correct rpcport entry
|
||||
sudo sed -i s/^rpcport=/main.rpcport=/g /mnt/hdd/${network}/${network}.conf
|
||||
if [ $(grep -c "${bitcoinprefix}.rpcport" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
|
||||
echo "\
|
||||
${bitcoinprefix}.rpcport=${rpcprefix}8332"|\
|
||||
sudo tee -a /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
|
||||
# correct zmq entry
|
||||
sudo sed -i s/^zmqpubraw/main.zmqpubraw/g /mnt/hdd/${network}/${network}.conf
|
||||
if [ $(grep -c "${bitcoinprefix}.zmqpubrawblock" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
|
||||
echo "\
|
||||
${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
|
||||
${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333"|\
|
||||
sudo tee -a /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
|
||||
# addnode
|
||||
if [ ${bitcoinprefix} = signet ];then
|
||||
if [ $(grep -c "${bitcoinprefix}.addnode" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
|
||||
echo "\
|
||||
signet.addnode=g7fyzp4rgxlrcg73jmrwrzhjnfpsuavjvopurvfq7nrl5x2tif3gx6qd.onion:38333
|
||||
signet.addnode=s7fcvn5rblem7tiquhhr7acjdhu7wsawcph7ck44uxyd6sismumemcyd.onion:38333
|
||||
signet.addnode=6megrst422lxzsqvshkqkg6z2zhunywhyrhy3ltezaeyfspfyjdzr3qd.onion:38333
|
||||
signet.addnode=jahtu4veqnvjldtbyxjiibdrltqiiighauai7hmvknwxhptsb4xat4qd.onion:38333
|
||||
signet.addnode=4j6owtnrkgfty2ehbyuwz72k32fyos7co7jnnktxwg7rfrgnqk3obkid.onion:38333
|
||||
signet.addnode=f4kwoin7kk5a5kqpni7yqe25z66ckqu6bv37sqeluon24yne5rodzkqd.onion:38333
|
||||
signet.addnode=u2d5lofh73k275q3zm76r5bob5pjbff35goubg5hwr2xpgj365ei7cyd.onion:38333
|
||||
signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38333"|\
|
||||
sudo tee -a /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
removeParallelService
|
||||
if [ ${CHAIN} = mainnet ];then
|
||||
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
|
||||
else
|
||||
# /etc/systemd/system/${prefix}bitcoind.service
|
||||
echo "
|
||||
[Unit]
|
||||
Description=Bitcoin daemon on ${CHAIN}
|
||||
|
||||
[Service]
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
Type=forking
|
||||
PIDFile=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
|
||||
ExecStart=/usr/local/bin/bitcoind -${CHAIN} -daemon\
|
||||
-pid=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
|
||||
KillMode=process
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
# Hardening measures
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${prefix}bitcoind.service
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ${prefix}bitcoind
|
||||
echo "# OK - the bitcoin daemon on ${CHAIN} service is now enabled"
|
||||
|
||||
# add aliases
|
||||
if [ ${CHAIN} != mainnet ];then
|
||||
if [ $(alias | grep -c ${prefix}bitcoin) -eq 0 ];then
|
||||
bash -c "echo 'alias ${prefix}bitcoin-cli=\"/usr/local/bin/bitcoin-cli\
|
||||
-rpcport=${rpcprefix}8332\"' \
|
||||
>> /home/admin/_aliases.sh"
|
||||
bash -c "echo 'alias ${prefix}bitcoind=\"/usr/local/bin/bitcoind\
|
||||
-${CHAIN}\"' \
|
||||
>> /home/admin/_aliases.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" == "ready" ]; then
|
||||
echo "# OK - the ${prefix}bitcoind.service is enabled, system is ready so starting service"
|
||||
sudo systemctl start ${prefix}bitcoind
|
||||
else
|
||||
echo "# OK - the ${prefix}bitcoindservice is enabled, to start manually use:"
|
||||
echo "sudo systemctl start ${prefix}bitcoind"
|
||||
fi
|
||||
|
||||
isInstalled=$(systemctl status ${prefix}bitcoind | grep -c active)
|
||||
if [ $isInstalled -gt 0 ];then
|
||||
echo "# Installed $(bitcoind --version | grep version) ${prefix}bitcoind.service"
|
||||
echo
|
||||
echo "# Monitor the ${prefix}bitcoind with:"
|
||||
if [ ${CHAIN} = signet ]; then
|
||||
echo "sudo tail -f /mnt/hdd/bitcoin/signet/debug.log"
|
||||
elif [ ${CHAIN} = testnet ]; then
|
||||
echo "sudo tail -f /mnt/hdd/bitcoin/testnet3/debug.log"
|
||||
elif [ ${CHAIN} = mainnet ]; then
|
||||
echo "sudo tail -f /mnt/hdd/bitcoin/debug.log"
|
||||
fi
|
||||
echo
|
||||
else
|
||||
echo "# Installation failed"
|
||||
echo "# See:"
|
||||
echo "# sudo journalctl -fu ${prefix}bitcoind"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^${CHAIN}=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${CHAIN}=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
# switch on
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
installParallelService
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=on/g" /mnt/hdd/raspiblitz.conf
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# switch off
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
removeParallelService
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=off/g" /mnt/hdd/raspiblitz.conf
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "# FAIL - Unknown Parameter $1"
|
||||
echo "# may need reboot to run"
|
||||
exit 1
|
|
@ -3,6 +3,19 @@
|
|||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 0 ];then
|
||||
LNTYPE=$1
|
||||
else
|
||||
LNTYPE=lnd
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# command info
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# script to scan the state of the system after setup"
|
||||
|
@ -45,7 +58,7 @@ echo "bitcoinActive=${bitcoinRunning}"
|
|||
if [ ${bitcoinRunning} -eq 1 ]; then
|
||||
|
||||
# get blockchain info
|
||||
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/mnt/hdd/temp/.bitcoind.out 2>/mnt/hdd/temp/.bitcoind.error
|
||||
bitcoincli_alias getblockchaininfo 1>/mnt/hdd/temp/.bitcoind.out 2>/mnt/hdd/temp/.bitcoind.error
|
||||
# check if error on request
|
||||
blockchaininfo=$(cat /mnt/hdd/temp/.bitcoind.out 2>/dev/null)
|
||||
bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null)
|
||||
|
@ -127,15 +140,15 @@ startcountLightning=$(cat /home/admin/systemd.lightning.log 2>/dev/null | grep -
|
|||
echo "startcountLightning=${startcountLightning}"
|
||||
|
||||
# is LND running
|
||||
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
|
||||
lndRunning=$(systemctl status ${netprefix}lnd.service 2>/dev/null | grep -c running)
|
||||
echo "lndActive=${lndRunning}"
|
||||
|
||||
if [ ${lndRunning} -eq 1 ]; then
|
||||
|
||||
# get LND info
|
||||
lndRPCReady=1
|
||||
lndinfo=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>/mnt/hdd/temp/.lnd.error)
|
||||
|
||||
lndinfo=$($lncli_alias getinfo 2>/mnt/hdd/temp/.lnd.error)
|
||||
|
||||
# check if error on request
|
||||
lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null)
|
||||
lndErrorShort=''
|
||||
|
|
|
@ -1,23 +1,75 @@
|
|||
#!/bin/bash
|
||||
RTLVERSION="v0.10.1"
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# config script to switch the RideTheLightning WebGUI on, off or update"
|
||||
echo "# bonus.rtl.sh [on|off|update<commit>|menu|config]"
|
||||
echo "# installs the version $RTLVERSION by default"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check and load raspiblitz config
|
||||
# to know which network is running
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# config script to switch the RideTheLightning WebGUI on, off or update"
|
||||
echo
|
||||
echo "# bonus.rtl.sh [on|off|menu] <lnd|cln> <testnet|signet>"
|
||||
echo "# sets up lnd on ${chain}net by default"
|
||||
echo "# able to run intances for lnd and cln parallel"
|
||||
echo "# lnd mainnet and testnet can run parallel"
|
||||
echo "# cln can only have one network active at a time"
|
||||
echo
|
||||
echo "# bonus.rtl.sh [update<commit>|config]"
|
||||
echo "# installs the version $RTLVERSION by default"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "# Running: 'bonus.rtl.sh $*'"
|
||||
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "FAIL - missing /mnt/hdd/raspiblitz.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 1 ];then
|
||||
LNTYPE=$2
|
||||
else
|
||||
LNTYPE=lnd
|
||||
fi
|
||||
if [ ${LNTYPE} != lnd ]&&[ ${LNTYPE} != cln ];then
|
||||
echo "# ${LNTYPE} is not a supported LNTYPE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
if [ $# -gt 2 ];then
|
||||
CHAIN=$3
|
||||
else
|
||||
CHAIN=${chain}net
|
||||
fi
|
||||
if [ ${CHAIN} != testnet ]&&[ ${CHAIN} != mainnet ]&&[ ${CHAIN} != signet ];then
|
||||
echo "# ${CHAIN} is not a supported CHAIN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# prefix for parallel services
|
||||
if [ ${CHAIN} = testnet ];then
|
||||
netprefix="t"
|
||||
portprefix=1
|
||||
elif [ ${CHAIN} = signet ];then
|
||||
netprefix="s"
|
||||
portprefix=3
|
||||
elif [ ${CHAIN} = mainnet ];then
|
||||
netprefix=""
|
||||
portprefix=""
|
||||
fi
|
||||
|
||||
if [ ${LNTYPE} = cln ]; then
|
||||
RTLHTTP=${portprefix}7000
|
||||
typeprefix=c
|
||||
elif [ ${LNTYPE} = lnd ];then
|
||||
RTLHTTP=${portprefix}3000
|
||||
typeprefix=""
|
||||
fi
|
||||
|
||||
# show info menu
|
||||
if [ "$1" = "menu" ]; then
|
||||
|
||||
|
@ -29,9 +81,9 @@ if [ "$1" = "menu" ]; then
|
|||
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
|
||||
# Info with TOR
|
||||
/home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
|
||||
whiptail --title " Ride The Lightning (RTL) " --msgbox "Open in your local web browser:
|
||||
http://${localip}:3000\n
|
||||
https://${localip}:3001 with Fingerprint:
|
||||
whiptail --title "Ride The Lightning (RTL - $LNTYPE - $CHAIN)" --msgbox "Open in your local web browser:
|
||||
http://${localip}:${RTLHTTP}\n
|
||||
https://${localip}:$((RTLHTTP+1)) with Fingerprint:
|
||||
${fingerprint}\n
|
||||
Use your Password B to login.\n
|
||||
Hidden Service address for TOR Browser (QRcode on LCD):\n${toraddress}
|
||||
|
@ -39,9 +91,9 @@ Hidden Service address for TOR Browser (QRcode on LCD):\n${toraddress}
|
|||
/home/admin/config.scripts/blitz.display.sh hide
|
||||
else
|
||||
# Info without TOR
|
||||
whiptail --title " Ride The Lightning (RTL) " --msgbox "Open in your local web browser & accept self-signed cert:
|
||||
http://${localip}:3000\n
|
||||
https://${localip}:3001 with Fingerprint:
|
||||
whiptail --title "Ride The Lightning (RTL - $LNTYPE - $CHAIN)" --msgbox "Open in your local web browser & accept self-signed cert:
|
||||
http://${localip}:${RTLHTTP}\n
|
||||
https://${localip}:$((RTLHTTP+1)) with Fingerprint:
|
||||
${fingerprint}\n
|
||||
Use your Password B to login.\n
|
||||
Activate TOR to access the web interface from outside your local network.
|
||||
|
@ -52,36 +104,41 @@ Activate TOR to access the web interface from outside your local network.
|
|||
fi
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^rtlWebinterface=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "rtlWebinterface=off" >> /mnt/hdd/raspiblitz.conf
|
||||
if ! grep -Eq "^${netprefix}${typeprefix}rtlWebinterface=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${netprefix}${typeprefix}rtlWebinterface=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
# stop services
|
||||
echo "# making sure services are not running"
|
||||
sudo systemctl stop RTL 2>/dev/null
|
||||
sudo systemctl stop ${netprefix}${typeprefix}RTL 2>/dev/null
|
||||
|
||||
function configRTL() {
|
||||
SWAPSERVERPORT=8443
|
||||
if [ "$(grep -Ec "(loop=|lit=)" < /mnt/hdd/raspiblitz.conf)" -gt 0 ];then
|
||||
if [ $lit = on ];then
|
||||
echo "# Add the rtl user to the lit group"
|
||||
sudo /usr/sbin/usermod --append --groups lit rtl
|
||||
echo "# Symlink the lit-loop.macaroon"
|
||||
sudo rm -rf "/home/rtl/.loop" # delete symlink
|
||||
sudo ln -s "/home/lit/.loop/" "/home/rtl/.loop" # create symlink
|
||||
SWAPSERVERPORT=8443
|
||||
elif [ $loop = on ];then
|
||||
echo "# Add the rtl user to the loop group"
|
||||
sudo /usr/sbin/usermod --append --groups loop rtl
|
||||
echo "# Symlink the loop.macaroon"
|
||||
sudo rm -rf "/home/rtl/.loop" # delete symlink
|
||||
sudo ln -s "/home/loop/.loop/" "/home/rtl/.loop" # create symlink
|
||||
SWAPSERVERPORT=8081
|
||||
|
||||
if [ $LNTYPE = lnd ];then
|
||||
echo "# Make sure rtl is member of lndadmin"
|
||||
sudo /usr/sbin/usermod --append --groups lndadmin rtl
|
||||
SWAPSERVERPORT=8443
|
||||
if [ "$(grep -Ec "(loop=|lit=)" < /mnt/hdd/raspiblitz.conf)" -gt 0 ];then
|
||||
if [ $lit = on ];then
|
||||
echo "# Add the rtl user to the lit group"
|
||||
sudo /usr/sbin/usermod --append --groups lit rtl
|
||||
echo "# Symlink the lit-loop.macaroon"
|
||||
sudo rm -rf "/home/rtl/.loop" # delete symlink
|
||||
sudo ln -s "/home/lit/.loop/" "/home/rtl/.loop" # create symlink
|
||||
SWAPSERVERPORT=8443
|
||||
elif [ $loop = on ];then
|
||||
echo "# Add the rtl user to the loop group"
|
||||
sudo /usr/sbin/usermod --append --groups loop rtl
|
||||
echo "# Symlink the loop.macaroon"
|
||||
sudo rm -rf "/home/rtl/.loop" # delete symlink
|
||||
sudo ln -s "/home/loop/.loop/" "/home/rtl/.loop" # create symlink
|
||||
SWAPSERVERPORT=8081
|
||||
fi
|
||||
echo "# Make the loop macaroon group readable"
|
||||
sudo chmod 640 /home/rtl/.loop/mainnet/macaroons.db
|
||||
else
|
||||
echo "# No Loop or LiT is installed"
|
||||
fi
|
||||
echo "# Make the loop macaroon group readable"
|
||||
sudo chmod 640 /home/rtl/.loop/mainnet/macaroons.db
|
||||
else
|
||||
echo "# No Loop or LiT is installed"
|
||||
fi
|
||||
|
||||
# prepare RTL-Config.json file
|
||||
|
@ -96,6 +153,7 @@ function configRTL() {
|
|||
//Read data
|
||||
var data = require('/home/rtl/RTL/sample-RTL-Config.json');
|
||||
//Manipulate data
|
||||
data.port = '$RTLHTTP'
|
||||
data.nodes[0].lnNode = '$hostname'
|
||||
data.nodes[0].Authentication.macaroonPath = '/home/rtl/.lnd/data/chain/${network}/${chain}net/'
|
||||
data.nodes[0].Authentication.configPath = '/home/rtl/.lnd/lnd.conf';
|
||||
|
@ -115,87 +173,76 @@ EOF
|
|||
|
||||
# switch on
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
echo "# INSTALL RTL"
|
||||
echo "# Installing the RTL for ${LNTYPE} ${CHAIN}"
|
||||
|
||||
isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
||||
isInstalled=$(sudo ls /etc/systemd/system/${netprefix}${typeprefix}RTL.service 2>/dev/null | grep -c "${netprefix}${typeprefix}RTL.service")
|
||||
if ! [ ${isInstalled} -eq 0 ]; then
|
||||
echo "# RTL already installed."
|
||||
echo "# OK, the ${netprefix}${typeprefix}RTL.service is already installed."
|
||||
else
|
||||
# check and install NodeJS
|
||||
/home/admin/config.scripts/bonus.nodejs.sh on
|
||||
|
||||
# create rtl user
|
||||
sudo adduser --disabled-password --gecos "" rtl || exit 1
|
||||
|
||||
echo "# Make sure rtl is member of lndadmin"
|
||||
sudo /usr/sbin/usermod --append --groups lndadmin rtl
|
||||
|
||||
echo "# Make sure symlink to central app-data directory exists"
|
||||
if ! [[ -L "/home/rtl/.lnd" ]]; then
|
||||
sudo rm -rf "/home/rtl/.lnd" # not a symlink.. delete it silently
|
||||
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/rtl/.lnd" # and create symlink
|
||||
if [ $(compgen -u | grep -c rtl) -eq 0 ];then
|
||||
sudo adduser --disabled-password --gecos "" rtl || exit 1
|
||||
fi
|
||||
|
||||
# download source code and set to tag release
|
||||
echo "# Get the RTL Source Code"
|
||||
rm -rf /home/admin/RTL 2>/dev/null
|
||||
sudo -u rtl rm -rf /home/rtl/RTL 2>/dev/null
|
||||
sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL
|
||||
cd /home/rtl/RTL
|
||||
# check https://github.com/Ride-The-Lightning/RTL/releases/
|
||||
sudo -u rtl git reset --hard $RTLVERSION
|
||||
# from https://github.com/Ride-The-Lightning/RTL/commits/master
|
||||
# git checkout 917feebfa4fb583360c140e817c266649307ef72
|
||||
if [ -d "/home/rtl/RTL" ]; then
|
||||
echo "# OK - RTL code copy looks good"
|
||||
if [ -f /home/rtl/RTL/rtl.js ];then
|
||||
echo "# OK - the RTL code is already present"
|
||||
else
|
||||
echo "# FAIL - code copy did not run correctly"
|
||||
echo "# ABORT - RTL install"
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# install
|
||||
echo "# Run: npm install"
|
||||
export NG_CLI_ANALYTICS=false
|
||||
sudo -u rtl npm install --only=prod
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "# FAIL - npm install did not run correctly, aborting"
|
||||
|
||||
echo "# Make sure symlink to central app-data directory exists"
|
||||
if ! [[ -L "/home/rtl/.lnd" ]]; then
|
||||
sudo rm -rf "/home/rtl/.lnd" # not a symlink.. delete it silently
|
||||
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/rtl/.lnd" # and create symlink
|
||||
fi
|
||||
|
||||
# download source code and set to tag release
|
||||
echo "# Get the RTL Source Code"
|
||||
rm -rf /home/admin/RTL 2>/dev/null
|
||||
sudo -u rtl rm -rf /home/rtl/RTL 2>/dev/null
|
||||
sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL
|
||||
cd /home/rtl/RTL
|
||||
# check https://github.com/Ride-The-Lightning/RTL/releases/
|
||||
sudo -u rtl git reset --hard $RTLVERSION
|
||||
# from https://github.com/Ride-The-Lightning/RTL/commits/master
|
||||
# git checkout 917feebfa4fb583360c140e817c266649307ef72
|
||||
if [ -d "/home/rtl/RTL" ]; then
|
||||
echo "# OK - RTL code copy looks good"
|
||||
else
|
||||
echo "# FAIL - code copy did not run correctly"
|
||||
echo "# ABORT - RTL install"
|
||||
exit 1
|
||||
else
|
||||
echo "# OK - RTL install looks good"
|
||||
echo
|
||||
fi
|
||||
echo
|
||||
|
||||
# install
|
||||
echo "# Run: npm install"
|
||||
export NG_CLI_ANALYTICS=false
|
||||
sudo -u rtl npm install --only=prod
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "# FAIL - npm install did not run correctly, aborting"
|
||||
exit 1
|
||||
else
|
||||
echo "# OK - RTL install looks good"
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
# setup nginx symlinks
|
||||
if ! [ -f /etc/nginx/sites-available/rtl_ssl.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_ssl.conf /etc/nginx/sites-available/rtl_ssl.conf
|
||||
fi
|
||||
if ! [ -f /etc/nginx/sites-available/rtl_tor.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_tor.conf /etc/nginx/sites-available/rtl_tor.conf
|
||||
fi
|
||||
if ! [ -f /etc/nginx/sites-available/rtl_tor_ssl.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_tor_ssl.conf /etc/nginx/sites-available/rtl_tor_ssl.conf
|
||||
fi
|
||||
sudo ln -sf /etc/nginx/sites-available/rtl_ssl.conf /etc/nginx/sites-enabled/
|
||||
sudo ln -sf /etc/nginx/sites-available/rtl_tor.conf /etc/nginx/sites-enabled/
|
||||
sudo ln -sf /etc/nginx/sites-available/rtl_tor_ssl.conf /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "# Updating Firewall"
|
||||
sudo ufw allow 3000 comment 'RTL HTTP'
|
||||
sudo ufw allow 3001 comment 'RTL HTTPS'
|
||||
sudo ufw allow ${RTLHTTP} comment "${netprefix}${typeprefix}RTL HTTP"
|
||||
sudo ufw allow $((RTLHTTP+1)) comment "${netprefix}${typeprefix}RTL HTTPS"
|
||||
echo
|
||||
|
||||
if [ $LNTYPE = lnd ];then
|
||||
echo "# Install service"
|
||||
echo "# Install RTL systemd for ${network} on ${chain}"
|
||||
cat > /home/admin/RTL.service <<EOF
|
||||
# Systemd unit for RTL
|
||||
# /etc/systemd/system/RTL.service
|
||||
cat > /home/admin/${netprefix}${typeprefix}RTL.service <<EOF
|
||||
# Systemd unit for ${netprefix}${typeprefix}RTL
|
||||
# /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
|
||||
[Unit]
|
||||
Description=RTL daemon
|
||||
Description=${netprefix}${typeprefix}RTL daemon
|
||||
Wants=lnd.service
|
||||
After=lnd.service
|
||||
|
||||
|
@ -211,30 +258,94 @@ StandardError=journal
|
|||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
sudo mv /home/admin/${netprefix}${typeprefix}RTL.service /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
sudo sed -i "s|chain/bitcoin/mainnet|chain/${network}/${CHAIN}|" /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
sudo chown root:root /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
|
||||
sudo mv /home/admin/RTL.service /etc/systemd/system/RTL.service
|
||||
sudo sed -i "s|chain/bitcoin/mainnet|chain/${network}/${chain}net|" /etc/systemd/system/RTL.service
|
||||
sudo chown root:root /etc/systemd/system/RTL.service
|
||||
sudo systemctl enable RTL
|
||||
echo "OK - the RTL service is now enabled"
|
||||
elif [ $LNTYPE = cln ];then
|
||||
|
||||
# clnrest
|
||||
/home/admin/config.scripts/cln.rest.sh on ${CHAIN}
|
||||
|
||||
echo "
|
||||
# Systemd unit for ${netprefix}${typeprefix}RTL
|
||||
# /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
|
||||
[Unit]
|
||||
Description=${netprefix}${typeprefix}RTL daemon
|
||||
Wants=${netprefix}lightning.service
|
||||
After=${netprefix}lightning.service
|
||||
|
||||
[Service]
|
||||
Environment=\"PORT=$RTLHTTP\"
|
||||
Environment=\"LN_IMPLEMENTATION=CLT\"
|
||||
Environment=\"LN_SERVER_URL=https://localhost:${portprefix}6100\"
|
||||
Environment=\"CONFIG_PATH=/home/bitcoin/.lightning/${netprefix}config\"
|
||||
Environment=\"MACAROON_PATH=/home/bitcoin/c-lightning-REST/certs\"
|
||||
ExecStart=/usr/bin/node /home/rtl/RTL/rtl
|
||||
User=rtl
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "# Setup nginx symlinks"
|
||||
if ! [ -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_ssl.conf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf
|
||||
fi
|
||||
if ! [ -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_tor.conf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf
|
||||
fi
|
||||
if ! [ -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf ]; then
|
||||
sudo cp /home/admin/assets/nginx/sites-available/rtl_tor_ssl.conf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf
|
||||
fi
|
||||
|
||||
echo "# Set ports for Nginx"
|
||||
sudo sed -i "s/3000/$RTLHTTP/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf
|
||||
sudo sed -i "s/3001/$((RTLHTTP+1))/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf
|
||||
|
||||
sudo sed -i "s/3000/$RTLHTTP/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf
|
||||
sudo sed -i "s/3002/$((RTLHTTP+2))/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf
|
||||
|
||||
sudo sed -i "s/3000/$RTLHTTP/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf
|
||||
sudo sed -i "s/3003/$((RTLHTTP+3))/g" /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf
|
||||
|
||||
sudo ln -sf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf /etc/nginx/sites-enabled/
|
||||
sudo ln -sf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf /etc/nginx/sites-enabled/
|
||||
sudo ln -sf /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
configRTL
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf
|
||||
sudo sed -i "s/^${netprefix}${typeprefix}rtlWebinterface=.*/${netprefix}${typeprefix}rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# Hidden Service for RTL if Tor is active
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
# make sure to keep in sync with internet.tor.sh script
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh RTL 80 3002 443 3003
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh ${netprefix}${typeprefix}RTL 80 $((RTLHTTP+2)) 443 $((RTLHTTP+3))
|
||||
fi
|
||||
|
||||
sudo systemctl enable ${netprefix}${typeprefix}RTL
|
||||
echo "# OK - the ${netprefix}${typeprefix}RTL.service is now enabled"
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" == "ready" ]; then
|
||||
echo "# OK - the RTL.service is enabled, system is ready so starting service"
|
||||
sudo systemctl start RTL
|
||||
echo "# OK - system is ready so starting service"
|
||||
sudo systemctl start ${netprefix}${typeprefix}RTL
|
||||
echo "# Monitor with:"
|
||||
echo "sudo journalctl -f -u ${netprefix}${typeprefix}RTL"
|
||||
else
|
||||
echo "# OK - the RTL.service is enabled, to start manually use: 'sudo systemctl start RTL'"
|
||||
echo "# OK - To start manually use: 'sudo systemctl start RTL'"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
@ -243,38 +354,45 @@ fi
|
|||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=off/g" /mnt/hdd/raspiblitz.conf
|
||||
sudo sed -i "s/^${netprefix}${typeprefix}rtlWebinterface=.*/${netprefix}${typeprefix}rtlWebinterface=off/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# remove nginx symlinks
|
||||
sudo rm -f /etc/nginx/sites-enabled/rtl_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-enabled/rtl_tor.conf
|
||||
sudo rm -f /etc/nginx/sites-enabled/rtl_tor_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-available/rtl_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-available/rtl_tor.conf
|
||||
sudo rm -f /etc/nginx/sites-available/rtl_tor_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-enabled/${netprefix}${typeprefix}rtl_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-enabled/${netprefix}${typeprefix}rtl_tor.conf
|
||||
sudo rm -f /etc/nginx/sites-enabled/${netprefix}${typeprefix}rtl_tor_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_ssl.conf
|
||||
sudo rm -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor.conf
|
||||
sudo rm -f /etc/nginx/sites-available/${netprefix}${typeprefix}rtl_tor_ssl.conf
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Hidden Service if Tor is active
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh off RTL
|
||||
/home/admin/config.scripts/internet.hiddenservice.sh off ${netprefix}${typeprefix}RTL
|
||||
fi
|
||||
|
||||
isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
||||
isInstalled=$(sudo ls /etc/systemd/system/${netprefix}${typeprefix}RTL.service 2>/dev/null | grep -c "${netprefix}${typeprefix}RTL.service")
|
||||
if [ ${isInstalled} -eq 1 ]; then
|
||||
echo "# REMOVING RTL"
|
||||
sudo systemctl disable RTL
|
||||
sudo rm /etc/systemd/system/RTL.service
|
||||
# delete user and home directory
|
||||
sudo userdel -rf rtl
|
||||
echo "# OK RTL removed."
|
||||
echo "# Removing RTL for ${LNTYPE} ${CHAIN}"
|
||||
sudo systemctl disable ${netprefix}${typeprefix}RTL
|
||||
sudo rm /etc/systemd/system/${netprefix}${typeprefix}RTL.service
|
||||
if [ $LNTYPE = cln ];then
|
||||
/home/admin/config.scripts/cln.rest.sh off ${CHAIN}
|
||||
fi
|
||||
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
|
||||
echo "# Removing the binaries"
|
||||
echo "# Delete user and home directory"
|
||||
sudo userdel -rf rtl
|
||||
fi
|
||||
|
||||
echo "# OK ${netprefix}${typeprefix}RTL removed."
|
||||
else
|
||||
echo "# RTL is not installed."
|
||||
echo "# ${netprefix}${typeprefix}RTL is not installed."
|
||||
fi
|
||||
|
||||
# close ports on firewall
|
||||
sudo ufw deny 3000
|
||||
sudo ufw deny 3001
|
||||
sudo ufw deny ${RTLHTTP}
|
||||
sudo ufw deny $((RTLHTTP+1))
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
248
home.admin/config.scripts/cln.install.sh
Normal file
248
home.admin/config.scripts/cln.install.sh
Normal file
|
@ -0,0 +1,248 @@
|
|||
#!/bin/bash
|
||||
# https://lightning.readthedocs.io/
|
||||
|
||||
# https://github.com/ElementsProject/lightning/releases
|
||||
CLVERSION=v0.10.0
|
||||
|
||||
# vars
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# help
|
||||
if [ $# -eq 0 ]||[ "$1" = "-h" ]||[ "$1" = "--help" ];then
|
||||
echo
|
||||
echo "C-lightning install script"
|
||||
echo "the default version is: $CLVERSION"
|
||||
echo "setting up on ${chain}net unless otherwise specified"
|
||||
echo "mainnet / signet / testnet instances can run parallel"
|
||||
echo
|
||||
echo "usage:"
|
||||
echo "cln.install.sh on <signet|testnet>"
|
||||
echo "cln.install.sh off <signet|testnet> <purge>"
|
||||
echo "cln.install.sh [update<version>|commit|testPR<PRnumber>]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Tor
|
||||
TORGROUP="debian-tor"
|
||||
|
||||
# bitcoin mainnet / signet / testnet
|
||||
if [ "$1" = on ] || [ "$1" = off ] && [ $# -gt 1 ];then
|
||||
NETWORK=$2
|
||||
else
|
||||
if [ $chain = main ];then
|
||||
NETWORK=${network}
|
||||
else
|
||||
NETWORK=${chain}net
|
||||
fi
|
||||
fi
|
||||
|
||||
# prefix for parallel testnetwork services
|
||||
if [ $NETWORK = testnet ];then
|
||||
netprefix="t"
|
||||
portprefix=1
|
||||
elif [ $NETWORK = signet ];then
|
||||
netprefix="s"
|
||||
portprefix=3
|
||||
else
|
||||
netprefix=""
|
||||
portprefix=""
|
||||
fi
|
||||
|
||||
echo "# Running: 'cln.install.sh $*'"
|
||||
echo "# Using the settings for: ${NETWORK} "
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^${netprefix}cln=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${netprefix}cln=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = commit ]||[ "$1" = testPR ];then
|
||||
if [ ! -f /usr/local/bin/lightningd ]||[ "$1" = update ]||[ "$1" = commit ]||[ "$1" = testPR ];then
|
||||
# dependencies
|
||||
echo "# apt update"
|
||||
echo
|
||||
sudo apt-get update
|
||||
echo
|
||||
echo "# Installing dependencies"
|
||||
echo
|
||||
sudo apt-get install -y \
|
||||
autoconf automake build-essential git libtool libgmp-dev \
|
||||
libsqlite3-dev python3 python3-mako net-tools zlib1g-dev libsodium-dev \
|
||||
gettext
|
||||
|
||||
# download and compile from source
|
||||
cd /home/bitcoin || exit 1
|
||||
if [ "$1" = "update" ] || [ "$1" = "testPR" ] || [ "$1" = "commit" ]; then
|
||||
echo
|
||||
echo "# Deleting the old source code"
|
||||
echo
|
||||
sudo rm -rf lightning
|
||||
fi
|
||||
echo
|
||||
echo "# Cloning https://github.com/ElementsProject/lightning.git"
|
||||
echo
|
||||
sudo -u bitcoin git clone https://github.com/ElementsProject/lightning.git
|
||||
cd lightning || exit 1
|
||||
|
||||
if [ "$1" = "testPR" ]; then
|
||||
PRnumber=$2 || exit 1
|
||||
echo
|
||||
echo "# Using the PR:"
|
||||
echo "# https://github.com/ElementsProject/lightning/pull/$PRnumber"
|
||||
echo
|
||||
sudo -u bitcoin git fetch origin pull/$PRnumber/head:pr$PRnumber || exit 1
|
||||
sudo -u bitcoin git checkout pr$PRnumber || exit 1
|
||||
echo "# Building with EXPERIMENTAL_FEATURES enabled"
|
||||
sudo -u bitcoin ./configure --enable-experimental-features
|
||||
elif [ "$1" = "commit" ]; then
|
||||
echo
|
||||
echo "# Updating to the latest commit in:"
|
||||
echo "# https://github.com/ElementsProject/lightning"
|
||||
echo
|
||||
echo "# Building with EXPERIMENTAL_FEATURES enabled"
|
||||
sudo -u bitcoin ./configure --enable-experimental-features
|
||||
else
|
||||
if [ "$1" = "update" ]; then
|
||||
CLVERSION=$2
|
||||
echo "# Updating to the version $CLVERSION"
|
||||
fi
|
||||
sudo -u bitcoin git reset --hard $CLVERSION
|
||||
sudo -u bitcoin ./configure
|
||||
fi
|
||||
|
||||
currentCLversion=$(cd /home/bitcoin/lightning 2>/dev/null; \
|
||||
git describe --tags 2>/dev/null)
|
||||
sudo -u bitcoin ./configure
|
||||
echo
|
||||
echo "# Building from source C-lightning $currentCLversion"
|
||||
echo
|
||||
sudo -u bitcoin make
|
||||
echo
|
||||
echo "# Built C-lightning $currentCLversion"
|
||||
echo
|
||||
echo "# Install to /usr/local/bin/"
|
||||
echo
|
||||
sudo make install || exit 1
|
||||
# clean up
|
||||
# cd .. && rm -rf lightning
|
||||
else
|
||||
installedVersion=$(sudo -u bitcoin /usr/local/bin/lightningd --version)
|
||||
echo "# C-lightning ${installedVersion} is already installed"
|
||||
fi
|
||||
|
||||
# config
|
||||
echo "# Make sure bitcoin is in the ${TORGROUP} group"
|
||||
sudo usermod -a -G ${TORGROUP} bitcoin
|
||||
|
||||
echo "# Store the lightning data in /mnt/hdd/app-data/.lightning"
|
||||
echo "# Symlink to /home/bitcoin/"
|
||||
sudo rm -rf /home/bitcoin/.lightning # not a symlink, delete
|
||||
sudo mkdir -p /mnt/hdd/app-data/.lightning
|
||||
sudo ln -s /mnt/hdd/app-data/.lightning /home/bitcoin/
|
||||
echo "# Create /home/bitcoin/.lightning/${netprefix}config"
|
||||
if [ ! -f /home/bitcoin/.lightning/${netprefix}config ];then
|
||||
echo "
|
||||
# lightningd configuration for $NETWORK
|
||||
|
||||
network=$NETWORK
|
||||
announce-addr=127.0.0.1:${portprefix}9736
|
||||
log-file=cl.log
|
||||
log-level=debug
|
||||
|
||||
# Tor settings
|
||||
proxy=127.0.0.1:9050
|
||||
bind-addr=127.0.0.1:${portprefix}9736
|
||||
addr=statictor:127.0.0.1:9051
|
||||
always-use-proxy=true
|
||||
" | sudo tee /home/bitcoin/.lightning/${netprefix}config
|
||||
else
|
||||
echo "# The file /home/bitcoin/.lightning/${netprefix}config is already present"
|
||||
#TODO look for pluging configs and clear or install
|
||||
fi
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/app-data/.lightning
|
||||
sudo chown -R bitcoin:bitcoin /home/bitcoin/
|
||||
|
||||
# systemd service
|
||||
sudo systemctl stop ${netprefix}lightningd
|
||||
sudo systemctl disable ${netprefix}lightningd
|
||||
echo "# Create /etc/systemd/system/${netprefix}lightningd.service"
|
||||
echo "
|
||||
[Unit]
|
||||
Description=c-lightning daemon on $NETWORK
|
||||
|
||||
[Service]
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/lightningd\
|
||||
--conf=\"/home/bitcoin/.lightning/${netprefix}config\"
|
||||
KillMode=process
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
# Hardening measures
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${netprefix}lightningd.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ${netprefix}lightningd
|
||||
echo "# Enabled the ${netprefix}lightningd.service"
|
||||
if [ "${state}" == "ready" ]; then
|
||||
sudo systemctl start ${netprefix}lightningd
|
||||
echo "# Started the ${netprefix}lightningd.service"
|
||||
fi
|
||||
echo
|
||||
echo "# Adding aliases"
|
||||
echo "\
|
||||
alias ${netprefix}lightning-cli=\"sudo -u bitcoin /usr/local/bin/lightning-cli\
|
||||
--conf=/home/bitcoin/.lightning/${netprefix}config\"
|
||||
alias ${netprefix}cl=\"sudo -u bitcoin /usr/local/bin/lightning-cli\
|
||||
--conf=/home/bitcoin/.lightning/${netprefix}config\"
|
||||
" | sudo tee -a /home/admin/_aliases.sh
|
||||
|
||||
echo
|
||||
echo "# The installed C-lightning version is: $(sudo -u bitcoin /usr/local/bin/lightningd --version)"
|
||||
echo
|
||||
echo "# To activate the aliases reopen the terminal or use:"
|
||||
echo "source ~/_aliases.sh"
|
||||
echo "# Monitor the ${netprefix}lightningd with:"
|
||||
echo "sudo journalctl -fu ${netprefix}lightningd"
|
||||
echo "sudo systemctl status ${netprefix}lightningd"
|
||||
echo "# logs:"
|
||||
echo "sudo tail -f /home/bitcoin/.lightning/${NETWORK}/cl.log"
|
||||
echo "# for the command line options use"
|
||||
echo "${netprefix}lightning-cli help"
|
||||
echo
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}cln=.*/${netprefix}cln=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "off" ];then
|
||||
echo "# Removing the ${netprefix}lightningd.service"
|
||||
sudo systemctl disable ${netprefix}lightningd
|
||||
sudo systemctl stop ${netprefix}lightningd
|
||||
echo "# Removing the aliases"
|
||||
sudo sed -i "/${netprefix}lightning-cli/d" /home/admin/_aliases.sh
|
||||
sudo sed -i "/${netprefix}cl/d" /home/admin/_aliases.sh
|
||||
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
|
||||
echo "# Removing the binaries"
|
||||
sudo rm -f /usr/local/bin/lightningd
|
||||
sudo rm -f /usr/local/bin/lightning-cli
|
||||
fi
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}cln=.*/${netprefix}cln=off/g" /mnt/hdd/raspiblitz.conf
|
||||
fi
|
115
home.admin/config.scripts/cln.rest.sh
Normal file
115
home.admin/config.scripts/cln.rest.sh
Normal file
|
@ -0,0 +1,115 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://github.com/Ride-The-Lightning/c-lightning-REST/releases/
|
||||
CLRESTVERSION="v0.4.4"
|
||||
|
||||
# help
|
||||
if [ $# -eq 0 ]||[ "$1" = "-h" ]||[ "$1" = "--help" ];then
|
||||
echo
|
||||
echo "C-lightning-REST install script"
|
||||
echo "the default version is: $CLRESTVERSION"
|
||||
echo "setting up on ${chain}net unless otherwise specified"
|
||||
echo "mainnet / signet / testnet instances cannot run parallel"
|
||||
echo
|
||||
echo "usage:"
|
||||
echo "cln.rest.sh on <signet|testnet>"
|
||||
echo "cln.rest.sh off"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# bitcoin mainnet / signet / testnet
|
||||
if [ "$1" = on ] || [ "$1" = off ] && [ $# -gt 1 ];then
|
||||
if [ $2 = main ]||[ $2 = mainnet ]||[ $2 = bitcoin ];then
|
||||
NETWORK=bitcoin
|
||||
else
|
||||
NETWORK=$2
|
||||
fi
|
||||
else
|
||||
if [ $chain = main ];then
|
||||
NETWORK=bitcoin
|
||||
else
|
||||
NETWORK=${chain}net
|
||||
fi
|
||||
fi
|
||||
|
||||
# prefix for parallel testnetwork services
|
||||
if [ $NETWORK = testnet ];then
|
||||
prefix="t"
|
||||
portprefix=1
|
||||
elif [ $NETWORK = signet ];then
|
||||
prefix="s"
|
||||
portprefix=3
|
||||
elif [ $NETWORK = bitcoin ];then
|
||||
prefix=""
|
||||
portprefix=""
|
||||
else
|
||||
echo "$NETWORK is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "# Running 'cln.rest.sh $*'"
|
||||
|
||||
if [ $1 = on ];then
|
||||
echo "# Setting up c-lightning-REST for $NETWORK"
|
||||
|
||||
sudo systemctl stop clnrest
|
||||
sudo systemctl disable clnrest
|
||||
|
||||
cd /home/bitcoin || exit 1
|
||||
sudo -u bitcoin git clone https://github.com/saubyk/c-lightning-REST
|
||||
cd c-lightning-REST || exit 1
|
||||
sudo -u bitcoin git reset --hard $CLRESTVERSION
|
||||
sudo -u bitcoin npm install
|
||||
sudo -u bitcoin cp sample-cl-rest-config.json cl-rest-config.json
|
||||
sudo -u bitcoin sed -i "s/3001/${portprefix}6100/g" cl-rest-config.json
|
||||
|
||||
# symlink to /home/bitcoin/.lightning/lightning-rpc from the chosen network directory
|
||||
sudo rm /home/bitcoin/.lightning/lightning-rpc # delete old symlink
|
||||
sudo ln -s /home/bitcoin/.lightning/${NETWORK}/lightning-rpc /home/bitcoin/.lightning/
|
||||
|
||||
echo "
|
||||
# systemd unit for c-lightning-REST for ${NETWORK}
|
||||
#/etc/systemd/system/clnrest.service
|
||||
[Unit]
|
||||
Description=c-lightning-REST daemon for $NETWORK
|
||||
Wants=${prefix}lightningd.service
|
||||
After=${prefix}lightningd.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/node /home/bitcoin/c-lightning-REST/cl-rest.js
|
||||
User=bitcoin
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
|
||||
# Hardening measures
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/clnrest.service
|
||||
|
||||
sudo systemctl enable clnrest
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" == "ready" ]; then
|
||||
echo "# OK - the clnrest.service is enabled, system is ready so starting service"
|
||||
sudo systemctl start clnrest
|
||||
else
|
||||
echo "# OK - the clnrest.service is enabled, to start manually use: 'sudo systemctl start clnrest'"
|
||||
fi
|
||||
echo
|
||||
echo "# Monitor with:"
|
||||
echo "sudo journalctl -f -u clnrest"
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ $1 = off ];then
|
||||
echo "# Removing c-lightning-REST for $NETWORK"
|
||||
sudo systemctl stop clnrest
|
||||
sudo systemctl disable clnrest
|
||||
sudo rm -rf /home/bitcoin/c-lightning-REST
|
||||
fi
|
129
home.admin/config.scripts/cln.sparko.sh
Normal file
129
home.admin/config.scripts/cln.sparko.sh
Normal file
|
@ -0,0 +1,129 @@
|
|||
#!/bin/bash
|
||||
|
||||
# explanation on paths https://github.com/ElementsProject/lightning/issues/4223
|
||||
# built-in path dir: /usr/local/libexec/c-lightning/plugins/
|
||||
|
||||
SPARKOVERSION="v2.7"
|
||||
|
||||
# command info
|
||||
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
||||
echo
|
||||
echo "Install, remove, connect or get info about the Sparko plugin for C-lightning"
|
||||
echo "version: $SPARKOVERSION"
|
||||
echo "Usage:"
|
||||
echo "cln.sparko.sh [on|off|menu|connect] [testnet|mainnet|signet]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
CHAIN=$2
|
||||
|
||||
# prefix for parallel services
|
||||
if [ ${CHAIN} = testnet ];then
|
||||
netprefix="t"
|
||||
clnetwork="testnet"
|
||||
portprefix=1
|
||||
elif [ ${CHAIN} = signet ];then
|
||||
netprefix="s"
|
||||
clnetwork="signet"
|
||||
portprefix=3
|
||||
elif [ ${CHAIN} = mainnet ];then
|
||||
netprefix=""
|
||||
clnetwork="bitcoin"
|
||||
portprefix=""
|
||||
fi
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^${netprefix}sparko=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${netprefix}sparko=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
if [ $1 = on ];then
|
||||
echo "# Detect CPU architecture ..."
|
||||
isARM=$(uname -m | grep -c 'arm')
|
||||
isAARCH64=$(uname -m | grep -c 'aarch64')
|
||||
isX86_64=$(uname -m | grep -c 'x86_64')
|
||||
|
||||
if [ ${isARM} -eq 1 ] ; then
|
||||
DISTRO="linux-arm"
|
||||
elif [ ${isAARCH64} -eq 1 ] ; then
|
||||
DISTRO="linux_arm"
|
||||
elif [ ${isX86_64} -eq 1 ] ; then
|
||||
DISTRO="linux_amd64"
|
||||
fi
|
||||
|
||||
# download binary
|
||||
sudo wget https://github.com/fiatjaf/sparko/releases/download/${SPARKOVERSION}/sparko_${DISTRO}\
|
||||
-O /usr/local/libexec/c-lightning/plugins/sparko
|
||||
# make executable
|
||||
sudo chmod +x /usr/local/libexec/c-lightning/plugins/sparko
|
||||
|
||||
echo "# Editing /home/bitcoin/.lightning/${netprefix}config"
|
||||
echo "# See: https://github.com/fiatjaf/sparko#how-to-use"
|
||||
PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-)
|
||||
masterkeythatcandoeverything=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20)
|
||||
secretaccesskeythatcanreadstuff=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20)
|
||||
verysecretkeythatcanpayinvoices=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20)
|
||||
keythatcanlistentoallevents=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c20)
|
||||
echo "
|
||||
sparko-host=0.0.0.0
|
||||
sparko-port=${portprefix}9000
|
||||
#sparko-tls-path=
|
||||
sparko-login=blitz:$PASSWORD_B
|
||||
sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}: getinfo, listchannels, listnodes; ${verysecretkeythatcanpayinvoices}: pay; ${keythatcanlistentoallevents}: stream
|
||||
" | sudo tee -a /home/bitcoin/.lightning/${netprefix}config
|
||||
|
||||
#TODO self signed cert https://github.com/fiatjaf/sparko#how-to-use
|
||||
|
||||
echo "# Editing /etc/systemd/system/${netprefix}lightningd.service"
|
||||
sudo sed -i "s#^ExecStart=.*#ExecStart=/usr/local/bin/lightningd\
|
||||
--conf=/home/bitcoin/.lightning/${netprefix}config\
|
||||
--plugin=/usr/local/libexec/c-lightning/plugins/sparko#g"\
|
||||
/etc/systemd/system/${netprefix}lightningd.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" == "ready" ]; then
|
||||
sudo systemctl restart ${netprefix}lightningd
|
||||
fi
|
||||
|
||||
echo "# Allowing port ${portprefix}9000 through the firewall"
|
||||
sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko"
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
sleep 5
|
||||
sudo cat /home/bitcoin/.lightning/${clnetwork}/cl.log | grep sparko
|
||||
netstat -tulpn | grep "${portprefix}9000"
|
||||
|
||||
echo "# Sparko was installed"
|
||||
echo "# Monitor with:"
|
||||
echo "sudo tail -n 100 -f /home/bitcoin/.lightning/${clnetwork}/cl.log"
|
||||
fi
|
||||
|
||||
if [ $1 = off ];then
|
||||
echo "# Editing /home/bitcoin/.lightning/${netprefix}config"
|
||||
sudo sed -i "/^sparko/d" /home/bitcoin/.lightning/${netprefix}config
|
||||
|
||||
echo "# Editing /etc/systemd/system/${netprefix}lightningd.service"
|
||||
sudo sed -i "s#^ExecStart=*#ExecStart=/usr/local/bin/lightningd\
|
||||
--conf=/home/bitcoin/.lightning/${netprefix}config#"\
|
||||
/etc/systemd/system/${netprefix}lightningd.service
|
||||
sudo systemctl daemon-reload
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" == "ready" ]; then
|
||||
sudo systemctl restart ${netprefix}lightningd
|
||||
fi
|
||||
echo "# Deny port ${portprefix}9000 through the firewall"
|
||||
sudo ufw deny "${portprefix}9000"
|
||||
# purge
|
||||
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
|
||||
echo "# Delete plugin"
|
||||
sudo rm /usr/local/libexec/c-lightning/plugins/${netprefix}sparko
|
||||
fi
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "# Sparko was uninstalled"
|
||||
fi
|
208
home.admin/config.scripts/lnd.chain.sh
Normal file
208
home.admin/config.scripts/lnd.chain.sh
Normal file
|
@ -0,0 +1,208 @@
|
|||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
|
||||
echo
|
||||
echo "Install or remove LND services on parallel chains"
|
||||
echo "lnd.chain.sh [on|off] [testnet|mainnet]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
CHAIN=$2
|
||||
if [ ${CHAIN} = testnet ]||[ ${CHAIN} = mainnet ];then
|
||||
echo "# Configuring the LND instance on ${CHAIN}"
|
||||
elif [ ${CHAIN} = signet ]; then
|
||||
echo "# Signet is not yet supported in LND"
|
||||
echo "# see https://github.com/lightningnetwork/lnd/issues/5018"
|
||||
exit 1
|
||||
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
|
||||
|
||||
function removeParallelService() {
|
||||
if [ -f "/etc/systemd/system/${netprefix}bitcoind.service" ];then
|
||||
sudo -u bitcoin /usr/local/bin/lncli\
|
||||
--rpcserver localhost:1${rpcportmod}009 stop
|
||||
sudo systemctl stop ${netprefix}lnd
|
||||
sudo systemctl disable ${netprefix}lnd
|
||||
echo "# ${netprefix}lnd.service on ${CHAIN} is stopped and disabled"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
# add default value to raspi config if needed
|
||||
if ! grep -Eq "^${netprefix}lnd=" /mnt/hdd/raspiblitz.conf; then
|
||||
echo "${netprefix}lnd=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
|
||||
# switch on
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
|
||||
RPCUSER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-)
|
||||
RPCPSW=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
|
||||
|
||||
echo "# Check mainnet lnd.conf"
|
||||
# it does not pick up main.zmqpubraw entries from bitcoin.conf, need to set manually
|
||||
if [ $(grep -c zmqpubrawblock /mnt/hdd/lnd/lnd.conf) -eq 0 ];then
|
||||
echo "
|
||||
[bitcoind]
|
||||
bitcoind.rpcuser=$RPCUSER
|
||||
bitcoind.rpcpass=$RPCPSW
|
||||
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
|
||||
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
|
||||
" | sudo tee -a /mnt/hdd/lnd/lnd.conf
|
||||
fi
|
||||
|
||||
echo "# Create /home/bitcoin/.lnd/${netprefix}lnd.conf"
|
||||
if [ ! -f /home/bitcoin/.lnd/${netprefix}lnd.conf ];then
|
||||
echo "
|
||||
# LND configuration
|
||||
bitcoin.${CHAIN}=1
|
||||
|
||||
[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
|
||||
accept-keysend=true
|
||||
nat=false
|
||||
debuglevel=debug
|
||||
gc-canceled-invoices-on-startup=true
|
||||
gc-canceled-invoices-on-the-fly=true
|
||||
ignore-historical-gossip-filters=1
|
||||
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
|
||||
bitcoin.node=bitcoind
|
||||
|
||||
[bitcoind]
|
||||
bitcoind.rpcuser=$RPCUSER
|
||||
bitcoind.rpcpass=$RPCPSW
|
||||
bitcoind.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
|
||||
bitcoind.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333
|
||||
|
||||
[Watchtower]
|
||||
watchtower.active=1
|
||||
watchtower.listen=0.0.0.0:${portprefix}9111
|
||||
|
||||
[Wtclient]
|
||||
wtclient.active=1
|
||||
|
||||
[Tor]
|
||||
tor.active=true
|
||||
tor.streamisolation=true
|
||||
tor.v3=true
|
||||
tor.privatekeypath=/mnt/hdd/lnd/${netprefix}v3_onion_private_key
|
||||
" | sudo -u bitcoin tee /home/bitcoin/.lnd/${netprefix}lnd.conf
|
||||
else
|
||||
echo "# The file /home/bitcoin/.lnd/${netprefix}lnd.conf is already present"
|
||||
fi
|
||||
|
||||
# systemd service
|
||||
removeParallelService
|
||||
echo "# Create /etc/systemd/system/.lnd.service"
|
||||
echo "
|
||||
[Unit]
|
||||
Description=LND on $NETWORK
|
||||
|
||||
[Service]
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/lnd\
|
||||
--configfile=/home/bitcoin/.lnd/${netprefix}lnd.conf
|
||||
KillMode=process
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
# Hardening measures
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${netprefix}lnd.service
|
||||
sudo systemctl enable ${netprefix}lnd
|
||||
echo "# Enabled the ${netprefix}lnd.service"
|
||||
if [ "${state}" == "ready" ]; then
|
||||
sudo systemctl start ${netprefix}lnd
|
||||
echo "# Started the ${netprefix}lnd.service"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "# Adding aliases"
|
||||
echo "\
|
||||
alias ${netprefix}lncli=\"sudo -u bitcoin /usr/local/bin/lncli\
|
||||
-n=${CHAIN} --rpcserver localhost:1${rpcportmod}009\"\
|
||||
" | sudo tee -a /home/admin/_aliases.sh
|
||||
|
||||
echo
|
||||
echo "# The installed LND version is: $(sudo -u bitcoin /usr/local/bin/lnd --version)"
|
||||
echo
|
||||
echo "# To activate the aliases reopen the terminal or use:"
|
||||
echo "source ~/_aliases.sh"
|
||||
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
|
||||
sudo sed -i "s/^${netprefix}lnd=.*/${netprefix}lnd=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# switch off
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
removeParallelService
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^${netprefix}lnd=.*/${netprefix}lnd=off/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "# FAIL - Unknown Parameter $1"
|
||||
echo "# may need reboot to run"
|
||||
exit 1
|
|
@ -87,25 +87,25 @@ if [ "$1" == "basic-setup" ]; then
|
|||
echo "err='lnd.conf: blockchain network in lnd.conf (${lndNetwork}) is different from raspiblitz.conf (${network})'"
|
||||
fi
|
||||
|
||||
# get chain from config (TESTNET / MAINNET)
|
||||
lndChain=""
|
||||
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g')
|
||||
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g')
|
||||
if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then
|
||||
echo "err='lnd.conf: mainnet and testnet are set active at the same time'"
|
||||
elif [ "${mainnet}" == "1" ]; then
|
||||
lndChain="main"
|
||||
elif [ "${testnet}" == "1" ]; then
|
||||
lndChain="test"
|
||||
else
|
||||
echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'"
|
||||
fi
|
||||
echo "chain='${lndChain}'"
|
||||
|
||||
# check if chain is same the raspiblitz config
|
||||
if [ "${chain}" != "${lndChain}" ]; then
|
||||
echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'"
|
||||
fi
|
||||
# # get chain from config (TESTNET / MAINNET)
|
||||
# lndChain=""
|
||||
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g')
|
||||
# source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g')
|
||||
# if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then
|
||||
# echo "err='lnd.conf: mainnet and testnet are set active at the same time'"
|
||||
# elif [ "${mainnet}" == "1" ]; then
|
||||
# lndChain="main"
|
||||
# elif [ "${testnet}" == "1" ]; then
|
||||
# lndChain="test"
|
||||
# else
|
||||
# echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'"
|
||||
# fi
|
||||
# echo "chain='${lndChain}'"
|
||||
#
|
||||
# # check if chain is same the raspiblitz config
|
||||
# if [ "${chain}" != "${lndChain}" ]; then
|
||||
# echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'"
|
||||
# fi
|
||||
|
||||
# check for admin macaroon exist (on HDD)
|
||||
adminMacaroonExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon')
|
||||
|
|
|
@ -10,13 +10,19 @@ fi
|
|||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
# 1. parameter
|
||||
passwordC="$1"
|
||||
|
||||
# check if wallet is already unlocked
|
||||
echo "# checking LND wallet ... (can take some time)"
|
||||
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
|
||||
macaroonsMissing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c "unable to read macaroon")
|
||||
walletLocked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
|
||||
macaroonsMissing=$($lncli_alias getinfo 2>&1 | grep -c "unable to read macaroon")
|
||||
if [ ${walletLocked} -eq 0 ] && [ ${macaroonsMissing} -eq 0 ]; then
|
||||
echo "# OK LND wallet was already unlocked"
|
||||
exit 0
|
||||
|
@ -91,7 +97,7 @@ while [ ${fallback} -eq 0 ]
|
|||
# UNKNOWN RESULT
|
||||
|
||||
# check if wallet was unlocked anyway
|
||||
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
|
||||
walletLocked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
|
||||
if [ "${walletUnlocked}" = "0" ]; then
|
||||
echo "# OK LND wallet unlocked"
|
||||
exit 0
|
||||
|
@ -120,12 +126,12 @@ do
|
|||
# do CLI unlock
|
||||
echo
|
||||
echo "############################"
|
||||
echo "Calling: lncli unlock"
|
||||
echo "Calling: ${netprefix}lncli unlock"
|
||||
echo "Please re-enter Password C:"
|
||||
lncli --chain=${network} --network=${chain}net unlock --recovery_window=1000
|
||||
lncli_alias unlock --recovery_window=1000
|
||||
|
||||
# test unlock
|
||||
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>&1 | grep -c unlock)
|
||||
walletLocked=$($lncli_alias getinfo 2>&1 | grep -c unlock)
|
||||
if [ ${walletLocked} -eq 0 ]; then
|
||||
echo "# --> OK LND wallet unlocked"
|
||||
else
|
||||
|
|
68
home.admin/config.scripts/network.aliases.sh
Normal file
68
home.admin/config.scripts/network.aliases.sh
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Usage:
|
||||
# source <(/home/admin/config.scripts/network.aliases.sh <lnd|cln> <mainnet|testnet|signet>
|
||||
# shopt -s expand_aliases
|
||||
# alias bitcoincli_alias="$bitcoincli_alias"
|
||||
# alias lncli_alias="$lncli_alias"
|
||||
# alias lightningcli_alias="$lightningcli_alias"
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
if [ $1 = getvars ];then
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 1 ];then
|
||||
LNTYPE=$2
|
||||
else
|
||||
if [ ${#LNdefault} -gt 0 ];then
|
||||
LNTYPE=${LNdefault}
|
||||
else
|
||||
LNTYPE=lnd
|
||||
fi
|
||||
fi
|
||||
echo "LNTYPE=${LNTYPE}"
|
||||
if [ $LNTYPE = cln ];then
|
||||
echo "typeprefix=c"
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
echo "typeprefix=''"
|
||||
fi
|
||||
|
||||
# CHAIN is signet | testnet | mainnet
|
||||
if [ $# -gt 2 ];then
|
||||
CHAIN=$3
|
||||
chain=${CHAIN::-3}
|
||||
else
|
||||
CHAIN=${chain}net
|
||||
fi
|
||||
echo "CHAIN=${chain}net"
|
||||
echo "chain=${chain}"
|
||||
if [ ${chain} = "test" ];then
|
||||
netprefix="t"
|
||||
echo "netprefix=t"
|
||||
L1rpcportmod=1
|
||||
L2rpcportmod=1
|
||||
echo "portprefix=1"
|
||||
elif [ ${chain} = "sig" ];then
|
||||
netprefix="s"
|
||||
echo "netprefix=s"
|
||||
L1rpcportmod=3
|
||||
L2rpcportmod=3
|
||||
echo "portprefix=3"
|
||||
elif [ ${chain} = "main" ];then
|
||||
netprefix=""
|
||||
echo "netprefix=''"
|
||||
L1rpcportmod=""
|
||||
L2rpcportmod=0
|
||||
echo "portprefix=''"
|
||||
fi
|
||||
|
||||
#TODO ALL
|
||||
# instead of all
|
||||
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net
|
||||
echo "lncli_alias=\"sudo -u bitcoin /usr/local/bin/lncli -n=${chain}net --rpcserver localhost:1${L2rpcportmod}009\""
|
||||
# sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network}
|
||||
echo "bitcoincli_alias=\"/usr/local/bin/${network}-cli -datadir=/home/bitcoin/.${network} -rpcport=${L1rpcportmod}8332\""
|
||||
echo "lightningcli_alias=\"sudo -u bitcoin /usr/local/bin/lightning-cli --conf=/home/bitcoin/.lightning/${netprefix}config\""
|
||||
fi
|
||||
|
||||
#TODO
|
||||
#change all /lnd.conf to /${netprefix}lnd.conf
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "monitor and troubleshot the bitcoin network"
|
||||
echo "monitor and troubleshoot the bitcoin network"
|
||||
echo "network.monitor.sh peer-status"
|
||||
echo "network.monitor.sh peer-kickstart [ipv4|ipv6|tor|auto]"
|
||||
echo "network.monitor.sh peer-disconnectall"
|
||||
|
@ -12,6 +12,12 @@ fi
|
|||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
|
||||
###################
|
||||
# STATUS
|
||||
###################
|
||||
|
@ -19,7 +25,7 @@ if [ "$1" = "peer-status" ]; then
|
|||
echo "#network.monitor.sh peer-status"
|
||||
|
||||
# number of peers connected
|
||||
peerNum=$(${network}-cli getnetworkinfo | grep "connections\"" | tr -cd '[[:digit:]]')
|
||||
peerNum=$($bitcoincli_alias getnetworkinfo | grep "connections\"" | tr -cd '[[:digit:]]')
|
||||
echo "peers=${peerNum}"
|
||||
|
||||
exit 0
|
||||
|
@ -111,7 +117,7 @@ if [ "$1" = "peer-kickstart" ]; then
|
|||
echo "newpeer='${nodeAddress}"
|
||||
|
||||
# kick start node with
|
||||
sudo -u admin ${network}-cli addnode "${nodeAddress}" "onetry" 1>/dev/null
|
||||
bitcoincli_alias addnode "${nodeAddress}" "onetry" 1>/dev/null
|
||||
echo "exitcode=$?"
|
||||
|
||||
exit 0
|
||||
|
@ -131,15 +137,15 @@ if [ "$1" = "peer-disconnectall" ]; then
|
|||
fi
|
||||
|
||||
# get all peer id and disconnect them
|
||||
sudo -u admin ${network}-cli getpeerinfo | grep '"addr": "' | while read line
|
||||
bitcoincli_alias getpeerinfo | grep '"addr": "' | while read line
|
||||
do
|
||||
peerID=$(echo $line | cut -d '"' -f4)
|
||||
echo "# disconnecting peer with ID: ${peerID}"
|
||||
sudo -u admin ${network}-cli disconnectnode ${peerID}
|
||||
bitcoincli_alias disconnectnode ${peerID}
|
||||
done
|
||||
|
||||
echo "#### FINAL PEER INFO FORM BITCOIND"
|
||||
sudo -u admin ${network}-cli getpeerinfo
|
||||
echo "#### FINAL PEER INFO FROM BITCOIND"
|
||||
bitcoincli_alias getpeerinfo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue