raspiblitz/home.admin/BBfundWallet.sh

78 lines
2.5 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
2019-04-04 03:07:01 +02:00
clear
2018-12-05 15:27:44 +01:00
# load raspiblitz config data (with backup from old config)
2019-02-02 23:49:04 +01:00
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
2018-12-05 15:27:44 +01:00
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
2018-12-05 15:27:44 +01:00
if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi
2018-08-08 17:36:04 +02:00
# PRECHECK) check if chain is in sync
2019-03-08 14:16:43 +01:00
chainOutSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": false' -c)
if [ ${chainOutSync} -eq 1 ]; then
2019-04-04 03:07:01 +02:00
echo "FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
2019-04-04 03:29:04 +02:00
echo ""
echo "PRESS ENTER to return to menu"
read key
2019-04-04 03:07:01 +02:00
exit 1
2018-08-08 17:36:04 +02:00
fi
# execute command
2019-04-04 03:07:01 +02:00
echo "calling lncli ... please wait"
command="lncli --chain=${network} --network=${chain}net newaddress p2wkh"
2019-04-04 03:07:01 +02:00
echo "${command}"
result=$($command)
echo "$result"
# on no result
if [ ${#result} -eq 0 ]; then
2019-04-04 03:07:01 +02:00
echo "Empty result - sorry something went wrong - thats unusual."
echo ""
2019-04-04 03:29:04 +02:00
echo "PRESS ENTER to return to menu"
read key
exit 1
fi
2019-04-04 03:07:01 +02:00
# parse address from result
address=$( echo "$result" | grep "address" | cut -d '"' -f4)
# prepare coin info
2019-04-04 03:07:01 +02:00
coininfo="Bitcoin"
if [ "$network" = "litecoin" ]; then
2019-04-04 03:07:01 +02:00
coininfo="Litecoin"
fi
if [ "$chain" = "test" ]; then
coininfo="TESTNET Bitcoin"
fi
2020-02-17 13:32:33 +01:00
msg="Send ${coininfo} to address --> ${address}\n\nScan the QR code on the LCD with your mobile wallet or copy paste the address.\nThe wallet you sending from needs to support bech32 addresses.\nThis screen will not update - press DONE when send."
if [ "$chain" = "test" ]; then
msg="${msg} \n\n Get some testnet coins from https://testnet-faucet.mempool.co"
fi
2019-04-04 03:07:01 +02:00
echo "generating QR code ... please wait"
2020-01-25 00:04:02 +01:00
/home/admin/config.scripts/blitz.lcd.sh qr "$network:${address}"
2019-04-04 03:07:01 +02:00
# dialog with instructions while QR code is shown on LCD
whiptail --backtitle "Fund your on chain wallet" \
--title "Send ${coininfo}" \
2019-04-04 03:07:01 +02:00
--yes-button "DONE" \
2020-04-05 10:33:17 +02:00
--no-button "Console QRcode" \
2019-04-04 03:07:01 +02:00
--yesno "${msg}" 0 0
2019-04-04 03:07:01 +02:00
# display QR code
if [ $? -eq 1 ]; then
2020-01-25 00:04:02 +01:00
/home/admin/config.scripts/blitz.lcd.sh qr-console "$network:${address}"
fi
2019-04-04 03:07:01 +02:00
# clean up
2020-01-25 00:04:02 +01:00
/home/admin/config.scripts/blitz.lcd.sh hide
2019-04-04 03:07:01 +02:00
# follow up info
whiptail --backtitle "Fund your on chain wallet" \
--title "What's next?" \
2019-04-04 03:29:04 +02:00
--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