refactor lcd/qr scripts

This commit is contained in:
rootzoll 2020-01-25 00:04:02 +01:00
parent 92f14b1de3
commit 89bbd9f7fb
11 changed files with 29 additions and 79 deletions

View file

@ -24,8 +24,14 @@ fi
echo "Run dialog ..."
echo "Installing the QR code generator (qrencode)"
./XXaptInstall.sh qrencode
./XXaptInstall.sh fbi
# Make sure needed packages are installed
if [ $(sudo dpkg-query -l | grep "ii fbi" | wc -l) = 0 ]; then
sudo apt-get install fbi -y > /dev/null
fi
if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then
sudo apt-get install qrencode -y > /dev/null
fi
# BASIC MENU INFO
HEIGHT=14

View file

@ -117,7 +117,7 @@ case $CHOICE in
/home/admin/config.scripts/blitz.lcd.sh qr-console ${appstoreLink}
fi
/home/admin/config.scripts/blitz.lcd.sh hide
/home/admin/config.scripts/bonus.lndconnect.sh REST
/home/admin/config.scripts/bonus.lndconnect.sh RPC
exit 1;
;;
ZAP_ANDROID)

View file

@ -31,10 +31,10 @@ if [ ${#sshtunnel} -gt 0 ]; then
fi
# write qr code data to text file
echo -e "${host}:${port},\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon),\n$(openssl x509 -sha256 -fingerprint -in ./.lnd/tls.cert -noout)" > qr.txt
qrcodedata=$("${host}:${port},\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon),\n$(openssl x509 -sha256 -fingerprint -in ./.lnd/tls.cert -noout)")
# display qr code on LCD
./XXdisplayQRlcd.sh
/home/admin/config.scripts/blitz.lcd.sh qr "${qrcodedata}"
# show pairing info
clear
@ -49,11 +49,11 @@ whiptail --backtitle "Connecting Shango Mobile Wallet" \
--no-button "show QR code" \
--yesno "${msg}" 20 70
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
/home/admin/config.scripts/blitz.lcd.sh qr-console "${qrcodedata}"
fi
# clean up
./XXdisplayQRlcd_hide.sh
/home/admin/config.scripts/blitz.lcd.sh hide
shred qr.png 2> /dev/null
rm -f qr.png 2> /dev/null
shred qr.txt 2> /dev/null

View file

@ -42,8 +42,9 @@ echo "Press ENTER to continue, CTRL+C to cancel."
echo ""
read key
./XXdisplayQRlcd_hide.sh
/home/admin/config.scripts/blitz.lcd.sh hide
cd /home/admin
# write QR code to image
if [ $1 == zeus ]; then
lndconnect --host=$(sudo cat /mnt/hdd/tor/lnd_REST/hostname) --port=8080 --image
@ -51,7 +52,7 @@ elif [ $1 == zap ]; then
lndconnect --host=$(sudo cat /mnt/hdd/tor/lnd_REST/hostname) --port=8080 --nocert --image
fi
# display qr code image on LCD
./XXdisplayLCD.sh lndconnect-qr.png
/home/admin/config.scripts/blitz.lcd.sh image /home/admin/lndconnect-qr.png
# show pairing info dialog
msg=""
msg="You should now see the pairing QR code on the RaspiBlitz LCD.\n\n${msg}When you start the App choose to connect to your own node.\n(DIY / Remote-Node / lndconnect)\n\nClick on the 'Scan QR' button. Scan the QR on the LCD and <continue> or <show QR code> to see it in this window."
@ -71,7 +72,7 @@ if [ $? -eq 1 ]; then
fi
# clean up
./XXdisplayQRlcd_hide.sh
/home/admin/config.scripts/blitz.lcd.sh hide
shred lndconnect-qr.png 2> /dev/null
rm -f lndconnect-qr.png 2> /dev/null
shred qr.txt 2> /dev/null

View file

@ -61,23 +61,21 @@ if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
# echo "******************************"
# echo "WIN"
# echo "******************************"
# echo "${result}"
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4)
echo -e "${payReq}" > qr.txt
./XXdisplayQRlcd.sh
/home/admin/config.scripts/blitz.lcd.sh qr "${payReq}"
if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then
sudo apt-get install qrencode -y > /dev/null
fi
echo
echo "********************"
echo "Here is your invoice"
echo "********************"
echo
./XXaptInstall.sh qrencode
qrencode -t ANSI256 < /home/admin/qr.txt
qrencode -t ANSI256 "${payReq}"
echo
echo "Give this Invoice/PaymentRequest to someone to pay it:"
echo
@ -97,8 +95,8 @@ else
echo $result
echo
echo "Returning to menu - OK Invoice payed."
/home/admin/XXdisplayQRlcd_hide.sh
/home/admin/XXdisplayLCD.sh /home/admin/raspiblitz/pictures/ok.png
/home/admin/config.scripts/blitz.lcd.sh hide
/home/admin/config.scripts/blitz.lcd.sh image /home/admin/raspiblitz/pictures/ok.png
sleep 2
break
fi
@ -117,8 +115,6 @@ else
done
/home/admin/XXdisplayQRlcd_hide.sh
shred qr.txt
rm -f qr.txt
/home/admin/config.scripts/blitz.lcd.sh hide
fi

View file

@ -55,8 +55,7 @@ if [ "$chain" = "test" ]; then
fi
echo "generating QR code ... please wait"
echo -e "$network:${address}" > qr.txt
/home/admin/XXdisplayQRlcd.sh
/home/admin/config.scripts/blitz.lcd.sh qr "$network:${address}"
# dialog with instructions while QR code is shown on LCD
whiptail --backtitle "Fund your on chain wallet" \
@ -67,13 +66,11 @@ whiptail --backtitle "Fund your on chain wallet" \
# display QR code
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
/home/admin/config.scripts/blitz.lcd.sh qr-console "$network:${address}"
fi
# clean up
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
/home/admin/config.scripts/blitz.lcd.sh hide
# follow up info
whiptail --backtitle "Fund your on chain wallet" \

View file

@ -1,4 +0,0 @@
# Installs package if not yet installed
if [ $(sudo dpkg-query -l | grep "ii $1" | wc -l) = 0 ]; then
sudo apt-get install $1 -y > /dev/null
fi

View file

@ -1,8 +0,0 @@
#!/bin/bash
# Display an image on the LCD
# make sure fbi is installed
./XXaptInstall.sh fbi
sudo fbi -a -T 1 -d /dev/fb1 --noverbose $1 2> /dev/null

View file

@ -1,24 +0,0 @@
#!/bin/bash
# Display a QR code for the string in qr.txt
# make sure qrcode-encode and fbi are installed
#clear
#echo "*** Setup ***"
echo 50 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100
./XXaptInstall.sh qrencode
echo 90 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100
./XXaptInstall.sh fbi
whiptail --title "Get ready" --backtitle "QR-Code in Terminal Window" \
--msgbox "Make this terminal window as large as possible - fullscreen would be best. \n\nThe QR-Code might be too large for your display. In that case, shrink the letters by pressing the keys Ctrl and Minus (or Cmd and Minus if you are on a Mac) \n\nPRESS ENTER when you are ready to see the QR-code." 20 60
clear
qrencode -t ANSI256 < /home/admin/qr.txt
shred /home/admin/qr.txt
rm -f /home/admin/qr.txt
echo "(To shrink QR code: macOS press CMD- / LINUX press CTRL-) Press ENTER when finished."
read key
clear

View file

@ -1,10 +0,0 @@
#!/bin/bash
# Display a QR code for the string in qr.txt
# make sure qrcode-encode and fbi are installed
./XXaptInstall.sh qrencode
./XXaptInstall.sh fbi
qrencode -l L -o /home/admin/qr.png < /home/admin/qr.txt > /dev/null
sudo fbi -a -T 1 -d /dev/fb1 --noverbose /home/admin/qr.png 2> /dev/null

View file

@ -1,4 +0,0 @@
#!/bin/bash
sudo killall -3 fbi
shred /home/admin/qr.png 2> /dev/null
rm -f /home/admin/qr.png 2> /dev/null