mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-18 19:50:35 +02:00
CASHOUT: use aliases for lnd
This commit is contained in:
@@ -10,15 +10,24 @@ source /mnt/hdd/raspiblitz.conf
|
|||||||
if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
|
if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
|
||||||
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
|
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
|
||||||
if [ ${#chain} -eq 0 ]; then
|
if [ ${#chain} -eq 0 ]; then
|
||||||
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
|
chain=$($bitcoincli_alias getblockchaininfo | jq -r '.chain')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
|
||||||
|
|
||||||
# check if user has money in lightning channels - info about close all
|
# check if user has money in lightning channels - info about close all
|
||||||
openChannels=$(lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
|
if [ $LNTYPE = cln ];then
|
||||||
|
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
|
||||||
|
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
|
||||||
|
cln_num_inactive_channels="$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')" 2>/dev/null
|
||||||
|
openChannels=$((ln_channels_online+cln_num_inactive_channels))
|
||||||
|
elif [ $LNTYPE = lnd ];then
|
||||||
|
openChannels=$($lncli_alias listchannels 2>/dev/null | jq '.[] | length')
|
||||||
|
fi
|
||||||
if [ ${#openChannels} -eq 0 ]; then
|
if [ ${#openChannels} -eq 0 ]; then
|
||||||
clear
|
clear
|
||||||
echo "*** IMPORTANT **********************************"
|
echo "*** IMPORTANT **********************************"
|
||||||
echo "It looks like LND is not responding."
|
echo "It looks like $LNTYPE is not responding."
|
||||||
echo "Still starting up, is locked or is not running?"
|
echo "Still starting up, is locked or is not running?"
|
||||||
echo "Try later, try reboot or run command: debug"
|
echo "Try later, try reboot or run command: debug"
|
||||||
echo "************************************************"
|
echo "************************************************"
|
||||||
@@ -36,7 +45,17 @@ if [ ${openChannels} -gt 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check if money is waiting to get confirmed
|
# check if money is waiting to get confirmed
|
||||||
unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
|
if [ $LNTYPE = cln ];then
|
||||||
|
ln_walletbalance_wait=0
|
||||||
|
cln_listfunds=$($lightningcli_alias listfunds 2>/dev/null)
|
||||||
|
for i in $(echo "$cln_listfunds" \
|
||||||
|
|jq .outputs[]|jq 'select(.status=="unconfirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
|
||||||
|
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
|
||||||
|
done
|
||||||
|
unconfirmed=$ln_walletbalance_wait
|
||||||
|
elif [ $LNTYPE = lnd ];then
|
||||||
|
unconfirmed=$($lncli_alias walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
|
||||||
|
fi
|
||||||
if [ ${unconfirmed} -gt 0 ]; then
|
if [ ${unconfirmed} -gt 0 ]; then
|
||||||
whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for (some of) your funds.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58
|
whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for (some of) your funds.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
@@ -70,22 +89,28 @@ echo "Sweep all possible Funds"
|
|||||||
echo "******************************"
|
echo "******************************"
|
||||||
|
|
||||||
# execute command
|
# execute command
|
||||||
command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=36"
|
if [ ${LNTYPE} = "cln" ];then
|
||||||
|
# TODO no easy way to sweep funds
|
||||||
|
# withdraw destination satoshi [feerate] [minconf] [utxos]
|
||||||
|
command="NOT IMPLEMENTED YET"
|
||||||
|
elif [ ${LNTYPE} = "lnd" ];then
|
||||||
|
command="$lncli_alias sendcoins --sweepall --addr=${address} --conf_target=36"
|
||||||
|
fi
|
||||||
echo "$command"
|
echo "$command"
|
||||||
result=$($command 2>$_error)
|
result=$($command 2>$_error)
|
||||||
error=`cat ${_error}`
|
error=$(cat ${_error})
|
||||||
echo ""
|
echo
|
||||||
if [ ${#error} -gt 0 ]; then
|
if [ ${#error} -gt 0 ]; then
|
||||||
echo "FAIL: $error"
|
echo "FAIL: $error"
|
||||||
echo ""
|
echo
|
||||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
echo "FAIL --> Was not able to send transaction (see error above)"
|
echo "FAIL --> Was not able to send transaction (see error above)"
|
||||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
else
|
else
|
||||||
echo "Result: $result"
|
echo "Result: $result"
|
||||||
echo ""
|
echo
|
||||||
echo "********************************************************************"
|
echo "********************************************************************"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo
|
||||||
echo "Press ENTER to return to main menu."
|
echo "Press ENTER to return to main menu."
|
||||||
read key
|
read key
|
Reference in New Issue
Block a user