Browse Source

Add option to display QR-code for funding #334

dev
Christian Rotzoll 6 years ago
parent
commit
6326a6d209
  1. 49
      home.admin/00infoBlitz.sh
  2. 55
      home.admin/97addMobileWallet.sh
  3. 59
      home.admin/97addMobileWalletShango.sh
  4. 78
      home.admin/BBcreateInvoice.sh
  5. 34
      home.admin/BBfundWallet.sh
  6. 32
      home.admin/BBpayInvoice.sh
  7. 4
      home.admin/XXaptInstall.sh
  8. 37
      home.admin/XXchainInSync.sh
  9. 8
      home.admin/XXdisplayLCD.sh
  10. 24
      home.admin/XXdisplayQR.sh
  11. 10
      home.admin/XXdisplayQRlcd.sh
  12. 4
      home.admin/XXdisplayQRlcd_hide.sh
  13. BIN
      home.admin/assets/install_shango.jpg

49
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}" \

55
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
esac

59
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 <continue> or <show QR> 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 ""
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

78
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 ""

34
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

32
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 ""
echo ""

4
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

37
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

8
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

24
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

10
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

4
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

BIN
home.admin/assets/install_shango.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Loading…
Cancel
Save