Browse Source

cashout scripts

#146
rootzoll 6 years ago
parent
commit
acf3e441bd
  1. 9
      home.admin/00mainMenu.sh
  2. 73
      home.admin/BBchashoutWallet.sh

9
home.admin/00mainMenu.sh

@ -68,7 +68,8 @@ else
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your Wallet" \
FUNDING "Fund your on-chain Wallet" \
CASHOUT "Remove Funds from on-chain Wallet" \
CONNECT "Connect to a Peer" \
CHANNEL "Open a Channel with Peer" \
SEND "Pay an Invoice/PaymentRequest" \
@ -160,6 +161,12 @@ case $CHOICE in
read key
./00mainMenu.sh
;;
CASHOUT)
./BBcashoutWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
CHANNEL)
./BBopenChannel.sh
echo "Press ENTER to return to main menu."

73
home.admin/BBchashoutWallet.sh

@ -0,0 +1,73 @@
#!/bin/bash
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
# get available amount in on-chain wallet
maxAmount=$(lncli walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
# TODO: pre-check if channels are open or are still in closing
# and let user know not all funds are available yet (just info Dialoge)
# TODO: pre-check user hast more than 0 sat in on-chain wallet to send
# let user enter the amount
l1="Enter the amount of funds you want to send/remove:"
l2="You have max available: ${maxAmount} sat"
l3="If you enter nothing, all funds available will be send."
dialog --title "Remove Funds from RaspiBlitz" \
--inputbox "$l1\n$l2\n$l3" 10 40 2>$_temp
amount=$(cat $_temp | xargs)
shred $_temp
if [ ${#amount} -eq 0 ]; then
amount=${maxAmount}
fi
# TODO: check if amount is in valid range
# let user enter the address
l1="Enter the on-chain address to send funds to:"
l2="You will send: ${amount} sat to that address"
dialog --title "Where to send funds?" \
--inputbox "$l1" 8 60 2>$_temp
address=$(cat $_temp | xargs)
shred $_temp
if [ ${#address} -eq 0 ]; then
echo "FAIL - not a valid address (${address})"
exit 1
fi
# TODO: check address is valid for network and chain
command="lncli sendcoins ${address} ${amount}"
clear
echo "******************************"
echo "Send on-chain funds"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# execute command
if [ ${#command} -gt 0 ]; then
result=$($command)
fi
# on no result
if [ ${#result} -eq 0 ]; then
echo "Sorry something went wrong - thats unusual."
echo ""
exit 1
fi
# when result is available
echo "$result"
# TODO: check if all cashed out (0 funds + 0 channels) -> let user knwo its safe to update/reset RaspiBlitz
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or info on LCD to check if funds have arrived."
echo ""
Loading…
Cancel
Save