mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-19 12:10:33 +02:00
use lncli_alias and bitcoincli_alias everywhere
This commit is contained in:
@@ -18,19 +18,9 @@ if [ $# -gt 0 ];then
|
||||
CHAIN=$1
|
||||
chain=${CHAIN::-3}
|
||||
fi
|
||||
if [ ${chain} = test ];then
|
||||
L1rpcportmod=1
|
||||
L2rpcportmod=1
|
||||
elif [ ${chain} = sig ];then
|
||||
L1rpcportmod=3
|
||||
L2rpcportmod=3
|
||||
elif [ ${chain} = main ];then
|
||||
L1rpcportmod=""
|
||||
L2rpcportmod=0
|
||||
fi
|
||||
shopt -s expand_aliases
|
||||
alias lncli_alias="sudo -u bitcoin /usr/local/bin/lncli -n=${chain}net --rpcserver localhost:1${L2rpcportmod}009"
|
||||
alias bitcoincli_alias="/usr/local/bin/${network}-cli -rpcport=${L1rpcportmod}8332"
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars lnd ${chain}net
|
||||
getLNaliases
|
||||
|
||||
## get HDD/SSD info
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
@@ -80,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"
|
||||
|
||||
@@ -110,12 +99,12 @@ btc_path=$(command -v bitcoin-cli)
|
||||
blockInfo="-"
|
||||
if [ -n "${btc_path}" ]; then
|
||||
btc_title=$network
|
||||
blockchaininfo="$(bitcoincli_alias -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="$(bitcoincli_alias -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}"
|
||||
@@ -142,13 +131,13 @@ if [ -n "${btc_path}" ]; then
|
||||
fi
|
||||
|
||||
# get last known block
|
||||
last_block="$(bitcoincli_alias -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="$(bitcoincli_alias -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"
|
||||
@@ -156,7 +145,7 @@ if [ -n "${btc_path}" ]; then
|
||||
fi
|
||||
|
||||
# get IP address & port
|
||||
networkInfo=$(bitcoincli_alias -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')"
|
||||
@@ -180,9 +169,9 @@ public_addr_pre="Public "
|
||||
public_addr="??"
|
||||
torInfo=""
|
||||
# Version
|
||||
networkVersion=$(bitcoincli_alias -datadir=${bitcoin_dir} -version 2>/dev/null | cut -d ' ' -f6)
|
||||
networkVersion=$($bitcoincli_alias -version 2>/dev/null | cut -d ' ' -f6)
|
||||
# TOR or IP
|
||||
networkInfo=$(bitcoincli_alias -datadir=${bitcoin_dir} getnetworkinfo)
|
||||
networkInfo=$($bitcoincli_alias getnetworkinfo)
|
||||
networkConnections=$(echo ${networkInfo} | jq -r '.connections')
|
||||
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections"
|
||||
|
||||
@@ -256,7 +245,7 @@ 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_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
|
||||
@@ -280,23 +269,23 @@ 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
|
||||
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
|
||||
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_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} 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="$(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_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
|
||||
|
@@ -110,6 +110,9 @@ while :
|
||||
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
source ${configFile}
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars lnd ${chain}net
|
||||
getLNaliases
|
||||
fi
|
||||
|
||||
# reboot info
|
||||
@@ -294,7 +297,7 @@ while :
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
@@ -154,6 +154,9 @@ if [ "${state}" = "ready" ]; then
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
echo "loading config data"
|
||||
source ${configFile}
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars lnd ${chain}net
|
||||
getLNaliases
|
||||
else
|
||||
echo "setup still in progress - setupStep(${setupStep})"
|
||||
fi
|
||||
@@ -180,8 +183,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
|
||||
@@ -279,7 +282,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
|
||||
@@ -302,7 +305,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
|
||||
|
@@ -115,9 +115,9 @@ else
|
||||
|
||||
# check if the node is now in peer list
|
||||
if [ $LNTYPE = cln ];then
|
||||
isPeer=$(lightningcli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
isPeer=$($lightningcli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
isPeer=$(lncli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
isPeer=$($lncli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||
fi
|
||||
if [ ${isPeer} -eq 0 ]; then
|
||||
|
||||
|
@@ -17,15 +17,15 @@ getLNaliases
|
||||
|
||||
# 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)
|
||||
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)
|
||||
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
|
||||
fi
|
||||
if [ ${chainOutSync} -eq 1 ]; then
|
||||
if [ $LNTYPE = cln ];then
|
||||
|
@@ -21,15 +21,15 @@ echo "*** Precheck ***"
|
||||
|
||||
# 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)
|
||||
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)
|
||||
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
|
||||
fi
|
||||
if [ ${chainOutSync} -eq 1 ]; then
|
||||
if [ $LNTYPE = cln ];then
|
||||
@@ -47,11 +47,11 @@ fi
|
||||
|
||||
# check available funding
|
||||
if [ $LNTYPE = cln ];then
|
||||
for i in $(lightningcli_alias listfunds | jq .outputs | grep value | awk '{print $2}' | cut -d, -f1);do
|
||||
for i in $($lightningcli_alias listfunds | jq .outputs | 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)
|
||||
confirmedBalance=$($lncli_alias walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
|
||||
fi
|
||||
|
||||
if [ ${confirmedBalance} -eq 0 ]; then
|
||||
@@ -65,9 +65,9 @@ fi
|
||||
|
||||
# check number of connected peers
|
||||
if [ $LNTYPE = cln ];then
|
||||
numConnectedPeers=$(lightningcli_alias listpeers | grep -c '"id":')
|
||||
numConnectedPeers=$($lightningcli_alias listpeers | grep -c '"id":')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
numConnectedPeers=$(lncli_alias listpeers | grep pub_key -c)
|
||||
numConnectedPeers=$($lncli_alias listpeers | grep pub_key -c)
|
||||
fi
|
||||
|
||||
if [ ${numConnectedPeers} -eq 0 ]; then
|
||||
@@ -163,7 +163,7 @@ fi
|
||||
# build command
|
||||
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)
|
||||
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"
|
||||
|
@@ -21,8 +21,8 @@ getLNaliases
|
||||
# check if chain is in sync
|
||||
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)
|
||||
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
|
||||
@@ -48,9 +48,9 @@ done
|
||||
# check number of connected peers
|
||||
echo "check for open channels"
|
||||
if [ $LNTYPE = cln ];then
|
||||
openChannels=$(lightningcli_alias listpeers | grep -c '"CHANNELD_NORMAL:Funding transaction locked. Channel announced."')
|
||||
openChannels=$($lightningcli_alias listpeers | grep -c '"CHANNELD_NORMAL:Funding transaction locked. Channel announced."')
|
||||
elif [ $LNTYPE = lnd ];then
|
||||
openChannels=$(lncli_alias listchannels 2>/dev/null | grep chan_id -c)
|
||||
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
|
||||
fi
|
||||
if [ ${openChannels} -eq 0 ]; then
|
||||
echo
|
||||
|
@@ -32,8 +32,12 @@ function getLNvars {
|
||||
|
||||
# getLNaliases <vars set by getLNvars>
|
||||
function getLNaliases {
|
||||
#TODO ALL
|
||||
# instead of all
|
||||
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net
|
||||
lncli_alias="sudo -u bitcoin /usr/local/bin/lncli -n=${chain}net --rpcserver localhost:1${L2rpcportmod}009"
|
||||
bitcoincli_alias="/usr/local/bin/${network}-cli -rpcport=${L1rpcportmod}8332"
|
||||
# sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network}
|
||||
bitcoincli_alias="/usr/local/bin/${network}-cli -datadir=/home/bitcoin/.${network} -rpcport=${L1rpcportmod}8332"
|
||||
lightningcli_alias="sudo -u bitcoin /usr/local/bin/lightning-cli --conf=/home/bitcoin/.lightning/${netprefix}config"
|
||||
shopt -s expand_aliases
|
||||
alias lncli_alias="$lncli_alias"
|
||||
|
@@ -3,6 +3,17 @@
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 0 ];then
|
||||
LNTYPE=$1
|
||||
else
|
||||
LNTYPE=lnd
|
||||
fi
|
||||
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars $LNTYPE ${chain}net
|
||||
getLNaliases
|
||||
|
||||
# command info
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# script to scan the state of the system after setup"
|
||||
@@ -45,7 +56,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)
|
||||
@@ -120,15 +131,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=''
|
||||
|
@@ -10,13 +10,17 @@ fi
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars lnd ${chain}net
|
||||
getLNaliases
|
||||
|
||||
# 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 +95,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 +124,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
|
||||
|
@@ -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,10 @@ fi
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
source /home/admin/config.scripts/_functions.lightning.sh
|
||||
getLNvars lnd ${chain}net
|
||||
getLNaliases
|
||||
|
||||
###################
|
||||
# STATUS
|
||||
###################
|
||||
@@ -19,7 +23,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 +115,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 +135,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
|
||||
|
||||
|
Reference in New Issue
Block a user