diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index da69057..83e1a15 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -6,7 +6,8 @@ source /home/admin/_version.info # set colors color_red='\033[0;31m' color_green='\033[0;32m' -color_yellow='\033[0;33m' +color_amber='\033[0;33m' +color_yellow='\033[1;93m' color_gray='\033[0;37m' color_purple='\033[0;35m' @@ -174,19 +175,11 @@ else if [ $public_check = "0" ]; then public="" # only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure - public_color="${color_yellow}" + public_color="${color_amber}" else public="" public_color="${color_red}" fi - if [ ${#public_addr} -gt 25 ]; then - # if a IPv6 address dont show peers to save space - networkConnectionsInfo="" - fi - if [ ${#public_addr} -gt 35 ]; then - # if a LONG IPv6 address dont show "Public" in front to save space - public_addr_pre="" - fi # DynDNS if [ ${#dynDomain} -gt 0 ]; then @@ -196,14 +189,22 @@ else if [ "${ipOfDynDNS}:${public_port}" != "${public_addr}" ]; then public_color="${color_red}" else - public_color="${color_yellow}" + public_color="${color_amber}" fi # replace IP display with dynDNS public_addr_pre="DynDNS " - networkConnectionsInfo="" public_addr="${dynDomain}" + fi + if [ ${#public_addr} -gt 25 ]; then + # if a IPv6 address dont show peers to save space + networkConnectionsInfo="" + fi + + if [ ${#public_addr} -gt 35 ]; then + # if a LONG IPv6 address dont show "Public" in front to save space + public_addr_pre="" fi fi @@ -230,7 +231,7 @@ else public_check=$(nc -z -w6 ${public_ip} 9735 2>/dev/null; echo $?) if [ $public_check = "0" ]; then # only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure - ln_publicColor="${color_yellow}" + ln_publicColor="${color_amber}" else ln_publicColor="${color_red}" fi @@ -269,20 +270,20 @@ printf " ${color_yellow} ${color_yellow} ${color_yellow} -${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias} +${color_yellow} ${color_amber}%s ${color_green} ${ln_alias} ${color_yellow} ${color_gray}${network} Fullnode + Lightning Network ${torInfo} -${color_yellow} ,/ ${color_yellow}%s -${color_yellow} ,'/ ${color_gray}%s, CPU %s°C -${color_yellow} ,' / ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} Free HDD ${color_hdd}%s -${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray} ▼${network_rx} ▲${network_tx} -${color_yellow} .'____ ,' ${color_gray}${webinterfaceInfo} -${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s) -${color_yellow} / ,' ${color_gray}${public_addr_pre}${public_color}${public_addr} ${public}${networkConnectionsInfo} -${color_yellow} /,' ${color_gray} -${color_yellow} /' ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo} +${color_yellow} / ${color_amber}%s +${color_yellow} // ${color_gray}%s, CPU %s°C +${color_yellow} / / ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} Free HDD ${color_hdd}%s +${color_yellow} / /______ ${color_gray}ssh admin@${color_green}${local_ip}${color_gray} ▼${network_rx} ▲${network_tx} +${color_yellow} /_____ / ${color_gray}${webinterfaceInfo} +${color_yellow} / / ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s) +${color_yellow} / / ${color_gray}${public_addr_pre}${public_color}${public_addr} ${public}${networkConnectionsInfo} +${color_yellow} // ${color_gray} +${color_yellow} / ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo} ${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo} ${color_yellow} -${color_yellow}${ln_publicColor}${ln_external} +${color_gray}${ln_publicColor}${ln_external} " \ "RaspiBlitz v${codeVersion}" \ diff --git a/home.admin/97addMobileWallet.sh b/home.admin/97addMobileWallet.sh old mode 100644 new mode 100755 index 39dfd89..9d5528f --- a/home.admin/97addMobileWallet.sh +++ b/home.admin/97addMobileWallet.sh @@ -6,9 +6,9 @@ source /mnt/hdd/raspiblitz.conf # check if dynamic domain is set if [ ${#dynDomain} -eq 0 ]; then - dialog --title " Just Local Network? " --yesno "If you want to connect with your RaspiBlitz -also from outside your local network you need to -activate 'Services' -> 'DynamicDNS' FIRST. + whiptail --title " Just Local Network? " --yesno "If you want to connect with your RaspiBlitz +also from outside your local network you need to +activate 'Services' -> 'DynamicDNS' FIRST. For more details see chapter in GitHub README 'Public Domain with DynamicDNS' @@ -25,17 +25,56 @@ fi # Basic Options OPTIONS=(ZAP "Zap Wallet (iOS)" \ - SHANGO "Shango Wallet (iOS/Android)" \ - ZEUS "Zeus Wallet (iOS/Android)") + ZEUS "Zeus Wallet (iOS/Android)" + SHANGO_IOS "Shango Wallet for iOS" + SHANGO_ANDROID "Shango Wallet for Android" + ) -CHOICE=$(dialog --clear --title "Choose Mobile Wallet" --menu "" 10 40 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) +CHOICE=$(whiptail --clear --title "Choose Mobile Wallet" --menu "" 15 50 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + +./XXdisplayQRlcd_hide.sh clear case $CHOICE in CLOSE) exit 1; ;; - SHANGO) + SHANGO_IOS) + echo "https://testflight.apple.com/join/WwCjFnS8" > qr.txt + ./XXdisplayLCD.sh /home/admin/assets/install_shango.jpg + + whiptail --title "Install Testflight and Shango on your iOS device" \ + --yes-button "show link as QR" \ + --no-button "continue" \ + --yesno "At the moment this app is in public beta testing:\n\nhttps://testflight.apple.com/join/WwCjFnS8" 20 60 + + if [ $? -eq 0 ]; then + /home/admin/XXdisplayQR.sh + fi + + shred qr.txt + rm -f qr.txt + /home/admin/XXdisplayQRlcd_hide.sh + + ./97addMobileWalletShango.sh + exit 1; + ;; + SHANGO_ANDROID) + echo "https://play.google.com/apps/testing/com.shango" > qr.txt + ./XXdisplayQRlcd.sh + whiptail --title "Install Shango on your Android Phone" \ + --yes-button "show link as QR" \ + --no-button "continue" \ + --yesno "At the moment this app is in public beta testing:\n\nhttps://play.google.com/apps/testing/com.shango \n\nDo you want to see a QR code with an Playstore link?" 20 60 + + if [ $? -eq 0 ]; then + /home/admin/XXdisplayQR.sh + fi + + shred qr.txt + rm -f qr.txt + /home/admin/XXdisplayQRlcd_hide.sh + ./97addMobileWalletShango.sh exit 1; ;; @@ -47,4 +86,4 @@ case $CHOICE in ./97addMobileWalletZeus.sh exit 1; ;; -esac \ No newline at end of file +esac diff --git a/home.admin/97addMobileWalletShango.sh b/home.admin/97addMobileWalletShango.sh old mode 100644 new mode 100755 index 2d85f70..743113e --- a/home.admin/97addMobileWalletShango.sh +++ b/home.admin/97addMobileWalletShango.sh @@ -4,10 +4,7 @@ source /home/admin/raspiblitz.info source /mnt/hdd/raspiblitz.conf -# make sure qrcode-encoder in installed clear -echo "*** Setup ***" -sudo apt-get install qrencode -y # get local IP myip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') @@ -17,39 +14,33 @@ if [ ${#dynDomain} -gt 0 ]; then myip="${dynDomain}" fi -clear -echo "******************************" -echo "Connect Shango Mobile Wallet" -echo "******************************" -echo "" -echo "GETTING THE APP" -echo "At the moment this app is in public beta testing:" -echo "iOS: Read https://testflight.apple.com/join/WwCjFnS8 (open on device)" -echo "Android: https://play.google.com/apps/testing/com.shango (open on device)" -echo "" -echo "*** STEP 1 ***" +#echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && cat ./.lnd/tls.cert >>qr.txt +echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt + +./XXdisplayQRlcd.sh + +msg="" if [ ${#dynDomain} -eq 0 ]; then - echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." + msg="Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." fi -echo "On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED'" -echo "(Or in the App go to --> 'Settings' > 'Connect to your LND Server')" -echo "There you see three 3 form fields to fill out. Skip those and go right to the buttons below." -echo "" -echo "Click on the 'Scan QR' button" -echo "Make the this terminal as big as possible - fullscreen would be best." -echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app." -read key +msg="${msg}On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED' \n\n (Or in the App go to --> 'Settings' > 'Connect to your LND Server') \n\nThere you see three 3 form fields to fill out. Skip those and go right to the buttons below.\n\nClick on the 'Scan QR' button. Scan the QR on the LCD and or to see it in this window." -clear -echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***" -#echo -e "${myip}:10009,\n$(xxd -p -c2000 ~/.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSIUTF8 < qr.txt -echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSI256 < qr.txt -echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished." -read key +whiptail --backtitle "Connecting Shango Mobile Wallet" \ + --title "Setup Shango Step 1" \ + --yes-button "show QR" \ + --no-button "continue" \ + --yesno "${msg}" 20 65 + +if [ $? -eq 0 ]; then + /home/admin/XXdisplayQR.sh +fi shred qr.txt +rm -f qr.txt -clear -echo "Now press 'Connect' within the Shango Wallet." -echo "If its not working - check issues on GitHub:" -echo "https://github.com/neogeno/shango-lightning-wallet/issues" -echo "" \ No newline at end of file +whiptail --backtitle "Connecting Shango Mobile Wallet" \ + --title "Press Connect on Shango" \ + --msgbox "Now press 'Connect' within the Shango Wallet.\n\nIf its not working - check issues on GitHub:\n\nhttps://github.com/neogeno/shango-lightning-wallet/issues" 15 65 + +./XXdisplayQRlcd_hide.sh +shred qr.png 2> /dev/null +rm -f qr.png diff --git a/home.admin/BBcreateInvoice.sh b/home.admin/BBcreateInvoice.sh index 1f8fef8..e7e712d 100755 --- a/home.admin/BBcreateInvoice.sh +++ b/home.admin/BBcreateInvoice.sh @@ -13,29 +13,9 @@ if [ ${#chain} -eq 0 ]; then chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi -echo "" -echo "*** Precheck ***" - -# check if chain is in sync -chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c) -if [ ${chainInSync} -eq 0 ]; then - echo "!!!!!!!!!!!!!!!!!!!" - echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" - echo "Wait until chain is sync with LND and try again." - echo "!!!!!!!!!!!!!!!!!!!" - echo "" - exit 1 -fi - -# check number of connected peers -echo "check for open channels" -openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) -if [ ${openChannels} -eq 0 ]; then - echo "" - echo "!!!!!!!!!!!!!!!!!!!" - echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." - echo "!!!!!!!!!!!!!!!!!!!" - echo "" +# Check if ready (chain in sync and channels open) +./XXchainInSync.sh $network $chain +if [ $? != 0 ]; then exit 1 fi @@ -51,6 +31,8 @@ if [ ${#amount} -eq 0 ]; then exit 1 fi +# TODO let user enter a description + # build command command="lncli --chain=${network} --network=${chain}net addinvoice ${amount}" @@ -79,20 +61,48 @@ if [ ${#error} -gt 0 ]; then echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "${error}" else - echo "******************************" - echo "WIN" - echo "******************************" - echo "${result}" - echo "" +# 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 + + echo + echo "********************" + echo "Here is your invoice" + echo "********************" + echo echo "Give this Invoice/PaymentRequest to someone to pay it:" - echo "" - echo ${payReq} - echo "" - echo "You can use 'lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}' to check the payment. " + echo + echo "${payReq}" + echo + echo "Do you want to see the invoice QR-code in this terminal? (Y/N)" - # TODO: Offer to go into monitor for incommin payment loop. + read -n1 key + if [ "$key" = "y" ]; then + /home/admin/XXdisplayQR.sh + fi + shred qr.txt + rm -f qr.txt + + clear + echo "************" + echo "What's next?" + echo "************" + echo + echo "You can use" + echo + echo "lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}" + echo + echo "to check the payment." + + /home/admin/XXdisplayQRlcd_hide.sh + # TODO: Offer to go into monitor for incommin payment loop. + # Or simply start the loop and show success status when payment occured fi -echo "" \ No newline at end of file diff --git a/home.admin/BBfundWallet.sh b/home.admin/BBfundWallet.sh index 4e995f3..edb6461 100755 --- a/home.admin/BBfundWallet.sh +++ b/home.admin/BBfundWallet.sh @@ -56,15 +56,29 @@ if [ "$chain" = "test" ]; then coininfo="TESTNET Bitcoin" fi -# output info -echo "" -echo "******************************" -echo "TODO" -echo "******************************" -echo "Send ${coininfo} to address --> ${address}" +msg="Send ${coininfo} to address --> ${address}\n\nScan the QR code on the LCD with your mobile wallet or copy paste the address." if [ "$chain" = "test" ]; then - echo "get some testnet coins from https://testnet-faucet.mempool.co" + msg="${msg} \n\n Get some testnet coins from https://testnet-faucet.mempool.co" fi -echo "Whats next? --> Wait for confirmations. You can use info on LCD to check if funds have arrived." -echo "If you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'" -echo "" + +echo -e "$network:${address}" > qr.txt +/home/admin/XXdisplayQRlcd.sh + +whiptail --backtitle "Fund your on chain wallet" \ + --title "Send ${coininfo}" \ + --yes-button "show QR" \ + --no-button "continue" \ + --yesno "${msg} \n\n Do you want to see the QR-code for ${coininfo}:${address} in this window?" 0 0 + +if [ $? -eq 0 ]; then + /home/admin/XXdisplayQR.sh +fi + +shred qr.txt +rm -f qr.txt + +whiptail --backtitle "Fund your on chain wallet" \ + --title "What's next?" \ + --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 + +/home/admin/XXdisplayQRlcd_hide.sh diff --git a/home.admin/BBpayInvoice.sh b/home.admin/BBpayInvoice.sh index 83b5c36..fc07598 100755 --- a/home.admin/BBpayInvoice.sh +++ b/home.admin/BBpayInvoice.sh @@ -12,32 +12,10 @@ if [ ${#chain} -eq 0 ]; then chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi -echo "" -echo "*** Precheck ***" -echo "please wait a moment ..." - -# check if chain is in sync -chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c) -if [ ${chainInSync} -eq 0 ]; then - echo "!!!!!!!!!!!!!!!!!!!" - echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" - echo "Wait until chain is sync with LND and try again." - echo "!!!!!!!!!!!!!!!!!!!" - echo "" - exit 1 -fi - - -# check number of connected peers -echo "check for open channels" -openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) -if [ ${openChannels} -eq 0 ]; then - echo "" - echo "!!!!!!!!!!!!!!!!!!!" - echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." - echo "!!!!!!!!!!!!!!!!!!!" - echo "" - exit 1 +# Check if ready (chain in sync and channels open) +./XXchainInSync.sh $network $chain +if [ $? != 0 ]; then + exit 1 fi paymentRequestStart="???" @@ -118,4 +96,4 @@ else echo "******************************" echo "It worked :) - check out the service you were paying." fi -echo "" \ No newline at end of file +echo "" diff --git a/home.admin/XXaptInstall.sh b/home.admin/XXaptInstall.sh new file mode 100755 index 0000000..2adc88d --- /dev/null +++ b/home.admin/XXaptInstall.sh @@ -0,0 +1,4 @@ +# 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 diff --git a/home.admin/XXchainInSync.sh b/home.admin/XXchainInSync.sh new file mode 100755 index 0000000..00df330 --- /dev/null +++ b/home.admin/XXchainInSync.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Check if lnd is synced to chain and channels are open +# If it isn't, wait until it is +# exits with 1 if it isn't. + +network=$1 +chain=$2 + +# check if chain is in sync +cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c" +chainInSync=${cmdChainInSync} +while [ $chainInSync -eq 0 ]; do + dialog --title "Fail: not in sync" \ + --ok-label "Try now" \ + --cancel-label "Give up" \ + --pause "\n\n'lncli getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5 + + if [ $? -gt 0 ]; then + exit 1 + fi + chainInSync=${cmdChainInSync} +done + +# check number of connected peers +echo "check for open channels" +openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) +if [ ${openChannels} -eq 0 ]; then + echo "" + echo "!!!!!!!!!!!!!!!!!!!" + echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." + echo "!!!!!!!!!!!!!!!!!!!" + echo "" + exit 1 +fi + +exit 0 diff --git a/home.admin/XXdisplayLCD.sh b/home.admin/XXdisplayLCD.sh new file mode 100755 index 0000000..868c07a --- /dev/null +++ b/home.admin/XXdisplayLCD.sh @@ -0,0 +1,8 @@ +#!/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 diff --git a/home.admin/XXdisplayQR.sh b/home.admin/XXdisplayQR.sh new file mode 100755 index 0000000..f7d6cb0 --- /dev/null +++ b/home.admin/XXdisplayQR.sh @@ -0,0 +1,24 @@ +#!/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 diff --git a/home.admin/XXdisplayQRlcd.sh b/home.admin/XXdisplayQRlcd.sh new file mode 100755 index 0000000..1aa7ad2 --- /dev/null +++ b/home.admin/XXdisplayQRlcd.sh @@ -0,0 +1,10 @@ +#!/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 diff --git a/home.admin/XXdisplayQRlcd_hide.sh b/home.admin/XXdisplayQRlcd_hide.sh new file mode 100755 index 0000000..98a6782 --- /dev/null +++ b/home.admin/XXdisplayQRlcd_hide.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sudo killall -3 fbi +shred /home/admin/qr.png 2> /dev/null +rm -f /home/admin/qr.png 2> /dev/null diff --git a/home.admin/assets/install_shango.jpg b/home.admin/assets/install_shango.jpg new file mode 100644 index 0000000..c83e8e8 Binary files /dev/null and b/home.admin/assets/install_shango.jpg differ