Browse Source

Merge pull request #1 from rootzoll/master

merge upstream
#146
piezzo 6 years ago
committed by GitHub
parent
commit
d96213bd57
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 88
      README.md
  2. 363
      build.sdcard/raspbianStretchDesktop.sh
  3. 171
      home.admin/00infoBlitz.sh
  4. 94
      home.admin/00infoLCD.sh
  5. 168
      home.admin/00mainMenu.sh
  6. 168
      home.admin/10setupBlitz.sh
  7. 33
      home.admin/20initDialog.sh
  8. 29
      home.admin/30initHDD.sh
  9. 20
      home.admin/40addHDD.sh
  10. 30
      home.admin/50copyHDD.sh
  11. 246
      home.admin/50downloadHDD.sh
  12. 40
      home.admin/50syncHDD.sh
  13. 68
      home.admin/50torrentHDD.sh
  14. 46
      home.admin/60finishHDD.sh
  15. 188
      home.admin/70initLND.sh
  16. 68
      home.admin/80scanLND.sh
  17. 50
      home.admin/90finishSetup.sh
  18. 13
      home.admin/91addBonus.sh
  19. 125
      home.admin/95switchMainTest.sh
  20. 219
      home.admin/96addTorService.sh
  21. 57
      home.admin/96removeTorService.sh
  22. 52
      home.admin/97addMobileWalletShango.sh
  23. 14
      home.admin/AAunlockLND.sh
  24. 77
      home.admin/BBcashoutWallet.sh
  25. 36
      home.admin/BBcloseAllChannels.sh
  26. 122
      home.admin/BBconnectPeer.sh
  27. 91
      home.admin/BBcreateInvoice.sh
  28. 63
      home.admin/BBfundWallet.sh
  29. 136
      home.admin/BBopenChannel.sh
  30. 106
      home.admin/BBpayInvoice.sh
  31. 27
      home.admin/XXcleanHDD.sh
  32. 171
      home.admin/XXscreenMonitor.sh
  33. 17
      home.admin/XXupdateScripts.sh
  34. 12
      home.admin/assets/bitcoin.conf
  35. 23
      home.admin/assets/bitcoind.service
  36. 20
      home.admin/assets/getpublicip.service
  37. 16
      home.admin/assets/getpublicip.sh
  38. 29
      home.admin/assets/litecoin.conf
  39. 20
      home.admin/assets/litecoind.service
  40. 31
      home.admin/assets/lnd.bitcoin.conf
  41. 22
      home.admin/assets/lnd.conf
  42. 27
      home.admin/assets/lnd.litecoin.conf
  43. 27
      home.admin/assets/lnd.service
  44. 32
      home.admin/assets/lnd.tor.service
  45. 4
      home.admin/assets/raspiblitz-bitcoin-2018-07-16.torrent
  46. 801
      home.admin/assets/raspiblitz-litecoin-2018-07-29.torrent
  47. BIN
      pictures/bonus-lnbalance.png
  48. BIN
      pictures/bonus-lnchannels.png
  49. BIN
      pictures/shango1.png
  50. BIN
      pictures/ssh0-welcome.png
  51. BIN
      pictures/ssh0-welcome2.png
  52. BIN
      pictures/ssh5-blockchain.png
  53. BIN
      pictures/ssh5-blockchain2.png
  54. BIN
      pictures/ssh9e-mainmenu.png
  55. BIN
      pictures/ssh9e-mainmenu1.png
  56. BIN
      pictures/ssh9e-mainmenu2.png
  57. BIN
      pictures/tor1.png
  58. 12
      shoppinglist_fr.md
  59. 9
      shoppinglist_uk.md
  60. 4
      shoppinglist_usa.md

88
README.md

@ -1,9 +1,11 @@
[ [Hardware](#hardware-needed-amazon-shopping-list) ] -- [ [Setup](setup-your-raspiblitz) ] -- [ [Documentation](#documentation) ] -- [ [Education](#educatiuonal-tutorials) ] -- [ [Development](#further-development-of-raspiblitz) ]
[ [Hardware](#hardware-needed-amazon-shopping-list) ] -- [ [Setup](#boot-your-raspiblitz) ] -- [ [Documentation](#documentation) ] -- [ [Education](#educational-tutorials) ] -- [ [Development](#further-development-of-raspiblitz) ]
-----
# RaspiBlitz
Fastest and cheapest way to get your own Lightning Node running - on a RaspberryPi with a nice LCD.
`Latest Version with lnd 0.5-betaRC1 and experimental TOR integration.`
![RaspiBlitz](pictures/raspiblitz.jpg)
*This tutorial is based on the RaspiBolt project - you can find in detail here: https://github.com/Stadicus/guides/blob/master/raspibolt The RaspiBlitz serves as a shortcut through this setup process with some changes and an additional LCD display so that you can quickly experiment with a Lightning node and start working on your LApps on a hacking event (or at home). This shortcut is fine for testnet usage and maybe trying some small things on mainnet. But if you choose to go full reckless afterwards … please consider taking the time and work thru the original RaspiBolt project. Don’t trust us, verify.*
@ -11,9 +13,9 @@ Fastest and cheapest way to get your own Lightning Node running - on a Raspberry
## Table of Contents
* [ [Hardware](#hardware-needed-amazon-shopping-list) ] Shopping Lists and Putting all together
* [ [Setup](#setup-your-raspiblitz) ] Init and Setup your RaspiBlitz Lightning Node
* [ [Setup](#boot-your-raspiblitz) ] Init and Setup your RaspiBlitz Lightning Node
* [ [Documentation](#documentation) ] Features and Usecases
* [ [Education](#educatiuonal-tutorials) ] Tutorials with the RaspiBlitz to learn about Lightning
* [ [Education](#educational-tutorials) ] Tutorials with the RaspiBlitz to learn about Lightning
* [ [Development](#further-development-of-raspiblitz) ] Lets work together on the RaspiBlitz
## Hardware Needed (Amazon Shopping List)
@ -22,7 +24,7 @@ Fastest and cheapest way to get your own Lightning Node running - on a Raspberry
* RaspBerry Pi 3 (31,99 EUR) https://www.amazon.de/dp/B01CD5VC92
* Micro SD-Card 16GB (7,11 EUR) https://www.amazon.de/dp/B0162YQEIE
* Power (9,29 EUR) https://www.amazon.de/dp/B01E75SB2C
* Power >=3A (9,29 EUR) https://www.amazon.de/dp/B01E75SB2C
* 1TB Hard Drive (49,99 EUR) https://www.amazon.de/dp/B00KWHJY7Q
* Case (9,36 EUR) https://www.amazon.de/dp/B0173GQF8Y
* LCD-Display (19,58 EUR) https://www.amazon.de/dp/B01JRUH0CY
@ -30,7 +32,7 @@ Fastest and cheapest way to get your own Lightning Node running - on a Raspberry
**Total Price: 127,31 EUR** (thats under 150 USD)
Amazon shopping lists for different countries:
[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ]
[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ] [ [FR](shoppinglist_fr.md) ]
You can even pay your RaspiBlitz Amazon Shopping with Bitcoin & Lightning thru [Bitrefill](https://blog.bitrefill.com/its-here-buy-amazon-vouchers-with-bitcoin-on-bitrefill-bb2a4449724a).
@ -59,7 +61,7 @@ If you are at an event, ask for a ready-2-go set or if you have your own hardwar
You got all the hardware of the shopping list above and you have no further assistance. Then you need to prepare your SD-Card yourself .. this scenario is still experimental, feedback needed and can take some time.
1. Download SD-Card image:
http://wiki.fulmo.org/downloads/raspiblitz-2018-07-25.img.gz
http://wiki.fulmo.org/downloads/raspiblitz-2018-08-28.img.gz (or [build your own](#build-the-sd-card-image))
2. Write the SD-Card image to your SD Card - if you need details, see here:
https://www.raspberrypi.org/documentation/installation/installing-images/README.md
@ -93,9 +95,9 @@ So open up a [terminal](https://www.youtube.com/watch?v=5XgBd6rjuDQ) and connect
#### Init
Automatically after login per SSH as admin to the RaspiBlitz, the user sees this welcome menu:
Automatically after login per SSH as admin to the RaspiBlitz, the user can choose if the RaspiBlitz should combine Bitcoin or Litecoin with Lightning:
![SSH0](pictures/ssh0-welcome.png)
![SSH0](pictures/ssh0-welcome2.png)
Setting Up the Raspi is the only option at this point, so we go with OK.
@ -141,15 +143,13 @@ After this the setup process needs some time and the user will see a lot of cons
The following screen is just shown, if the HDD was not prepared with a copy of the Bitcoin blockchain (as part of a ready-2-go set). The following options are offered to get a copy:
![SSH5](pictures/ssh5-blockchain.png)
![SSH5](pictures/ssh5-blockchain2.png)
The third option "SYNC" should just be use as a fallback. So normally you have the following two options:
The option "SYNC" should just be use as a fallback. So normally you have the following two options:
#### Download the Blockchain
This is the recommended way for users that are making the setup at home without any further assistance but can take quite some time.
*Background: The download is done thru bittorrent. So just it should be possible to stop/shutdown the Raspi and continue later - just in case.*
This is the recommended way for users that are making the setup at home without any further assistance but can take quite some time. You can choose to download over TORRENT or FTP-DOWNLOAD. Choose the FTP is the torrent if not working for you. To stop torrent and choose another option use CTRL+z and then start './10setupBlitz.sh' from terminal.
#### Copy the Blockchain
@ -203,7 +203,11 @@ After SSH back in as admin the main menu shows the unlock option:
Once the wallet is unlocked the setup is finally over and the main menu shows the option and features of the RaspiBlitz:
![SSH9e](pictures/ssh9e-mainmenu.png)
![SSH9e1](pictures/ssh9e-mainmenu1.png)
And if you scroll down .. you see even more feature options:
![SSH9e2](pictures/ssh9e-mainmenu2.png)
*Background: The script `00mainMenu.sh` is now the place to offer further features und extend the possibilities of the RaspiBlitz. Feel free to come up with ideas. Check out the developer section at the end of this page.*
@ -221,7 +225,23 @@ Already integrated features of the RaspiBlitz are/willbe listed as part of the m
#### Detailed Balances and Channel Info
TODO: Add photo
<img src="pictures/bonus-lnbalance.png" alt="bonus-lnbalance" width="600">
<img src="pictures/bonus-lnchannels.png" alt="bonus-lnchannels" width="600">
#### TOR Integration (experimental)
You can use the Switch to TOR option from the main menu to make the node reachable thru TOR. This way you can get thru a NAT without needed to open/forward ports on your router. Bitcoin and LND will have a seperate onion-address displayed on LCD and the Status Info Screen option in menu.
![tor1](pictures/tor1.png)
The TOR integration is experimental and at the moment there is no way to switch off TOR again.
#### Connect to Mobile Wallet
There is now the option to connect and control your LND node with the mobile app called "Shango" - choose option in the main menu.
![shango1](pictures/shango1.png)
## Educational Tutorials
@ -229,6 +249,44 @@ TODO: Add photo
A good way to start for now is to get some Testnet coins, connect to other peers and make your first transactions. You find tutorials for this at the original RaspiBolt guide: https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#get-some-testnet-bitcoin
## Build the SD Card Image
A ready to use SD card image of the RaspiBlitz for your RaspberryPi is provided as download by us to get everbody started quickly. But if you want to build that image yourself - here is a quick guide:
* Get a fresh Rasbian RASPBIAN STRETCH WITH DESKTOP card image: [DOWNLOAD](https://www.raspberrypi.org/downloads/raspbian/)
* Write image to a SD card: [TUTORIAL](https://www.raspberrypi.org/documentation/installation/installing-images/README.md)
* Add a file called `ssh` to the root of the SD card when mounted to enable SSH login
* Start card in Raspi and login per SSH with `ssh pi@[IP-OF-YOUR-RASPI]` password is `raspberry`
Now you are ready to start the SD card build script - copy the following command into your terminal and execute:
`wget https://raw.githubusercontent.com/rootzoll/raspiblitz/master/build.sdcard/raspbianStretchDesktop.sh && sudo bash raspbianStretchDesktop.sh`
As you can see from the URL you find the build script in this Git repo under `build.sdcard/raspbianStretchDesktop.sh`- there you can check what gets installed and configured in detail. Feel free to post improvements as pull requests.
The whole build process takes a while. And the end the LCD drives get installed and a reboot is needed. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use root: `ssh root@[IP-OF-YOUR-RASPI]` and simply shutdown with `sudo shutdown now`. Once you see the LCD going white and the actovity LED of the pi starts going dark. You can unplug power and remove the SD card. You have now build your own RaspiBlitz sd card image.
*Note: If you plan to use your self build sd card as a MASTER copy to backup image and distribute it. Use a smaller 8GB card for that. This way its ensured that it will fit on every 16 GB card recommended for RaspiBlitz later on.*
## Update to a new SD Card Release
At the beginning of this README you can find the newest SD card we provide. Or you can build the newest SD card image yourself like in the chapter above. The SD card image is used to setup a fresh install of the RaspiBlitz. So what to do if you already have an older version running and you want to upgrade?
Until we reach version 1.0 the update process will be a bit rough .. so what you do is:
* close all open lightning channels you have (`lncli --force closeallchannels`)
* wait until all closing transactions are done
* move all on-chain funds to a wallet outsie raspiblitz (`lncli --conf_target 3 sendcoins [ADDRESS]`)
* run the script `./XXcleanHDD.sh` in admin home directory (Blockchain will stay on HDD)
* shutdown RaspiBlitz (`sudo shutdown now`)
* flash SD card with new image
* Redo a fresh setup of RaspiBlitz
* Move your funds back in
* Re-Open your channels
We know that this is not optimal yet. But until version 1.0 we will change too much stuff to garantue any other save update mechanism. Also by redoing all the setup you help out on testing the lastest setup process.
From the upcomming version 1.0 onwards the goal is to make it easier to keep up with the lastest RaspiBlitz updates.
## Further Development of RaspiBlitz
The RaspiBlitz was developed on the basis of the RaspiBolt Guide to run LND on a RaspberryPi: https://github.com/Stadicus/guides/blob/master/raspibolt - the idea was to prepare as much as possible and have it on a SD-card ready to startup quickly. The configuration should be automated by scripts combined with some very basic user interaction thru the terminal for adminstration. The LCD should provide basic information, so that the health and state of the RaspiBlitz could be monitored with ease. The LCD has also basic touch support and could be used for direct and fast daily interactions.

363
build.sdcard/raspbianStretchDesktop.sh

@ -0,0 +1,363 @@
#!/bin/bash
#########################################################################
# Build your SD card image based on:
# RASPBIAN STRETCH WITH DESKTOP (2018-06-27)
# https://www.raspberrypi.org/downloads/raspbian/
# SHA256: 8636ab9fdd8f58a8ec7dde33b83747696d31711d17ef68267dbbcd6cfb968c24
##########################################################################
# setup fresh SD card with image above - login per SSH and run this script:
##########################################################################
echo ""
echo "***************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v0.9 *"
echo "***************************************"
echo ""
echo ""
echo "*** RASPI CONFIG ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config
# set new default passwort for pi and root user
echo "root:raspiblitz" | sudo chpasswd
echo "pi:raspiblitz" | sudo chpasswd
# set Raspi to boot up automatically with user pi (for the LCD)
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632
sudo raspi-config nonint do_boot_behaviour B2
sudo bash -c "echo '[Service]' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
sudo bash -c "echo 'ExecStart=' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
# do memory split (16MB)
sudo raspi-config nonint do_memory_split 16
# set to wait until network is available on boot (0 seems to yes)
sudo raspi-config nonint do_boot_wait 0
# autodetect and set your timezone
pip install -U tzupdate
sleep 2
sudo tzupdate
echo ""
echo "*** SOFTWARE UPDATE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#software-update
# installs like on RaspiBolt
sudo apt-get update
sudo apt-get upgrade -f -y --allow-change-held-packages
sudo apt-get install -y htop git curl bash-completion jq dphys-swapfile
# extra: remove some big packages not needed
sudo apt-get remove -y --purge libreoffice*
sudo apt-get clean
sudo apt-get -y autoremove
echo ""
echo "*** ADDING MAIN USER admin ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin
# using the default password 'raspiblitz'
sudo adduser --disabled-password --gecos "" admin
echo "admin:raspiblitz" | sudo chpasswd
sudo adduser admin sudo
sudo chsh admin -s /bin/bash
# configure sudo for usage without password entry
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
echo "*** ADDING SERVICE USER bitcoin"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
# create user and set default password for user
sudo adduser --disabled-password --gecos "" bitcoin
echo "bitcoin:raspiblitz" | sudo chpasswd
echo ""
echo "*** SWAP FILE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#moving-the-swap-file
# but just deactivating and deleting old (will be created alter when user adds HDD)
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
echo ""
echo "*** HARDENING ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#hardening-your-pi
# fail2ban (no config required)
sudo apt-get install -y fail2ban
echo ""
echo "*** INCREASE OPEN FILE LIMIT ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#increase-your-open-files-limit
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf"
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
echo ""
echo "*** BITCOIN ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md#installation
# set version (change if update is available)
bitcoinVersion="0.16.2"
laanwjPGP="01EA5486DE18A882D4C2684590C8019E36C2E964"
# prepare directories
sudo -u admin mkdir /home/admin/download
cd /home/admin/download
# download resources
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz
if [ ! -f "./bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz" ]
then
echo "!!! FAIL !!! Download BITCOIN BINARY not success."
exit 1
fi
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc
if [ ! -f "./SHA256SUMS.asc" ]
then
echo "!!! FAIL !!! Download SHA256SUMS.asc not success."
exit 1
fi
sudo -u admin wget https://bitcoin.org/laanwj-releases.asc
if [ ! -f "./laanwj-releases.asc" ]
then
echo "!!! FAIL !!! Download laanwj-releases.asc not success."
exit 1
fi
# test checksum
checksum=$(sha256sum --check SHA256SUMS.asc --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c)
if [ ${checksum} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Bitcoin download checksum not OK"
exit 1
fi
# check gpg finger print
fingerprint=$(gpg ./laanwj-releases.asc 2>/dev/null | grep "${laanwjPGP}" -c)
if [ ${fingerprint} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Bitcoin download PGP author not OK"
exit 1
fi
gpg --import ./laanwj-releases.asc
verifyResult=$(gpg --verify SHA256SUMS.asc 2>&1)
goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
echo "goodSignature(${goodSignature})"
correctKey=$(echo ${verifyResult} | grep "using RSA key ${laanwjPGP: -16}" -c)
echo "correctKey(${correctKey})"
if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})"
exit 1
fi
# install
sudo -u admin tar -xvf bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${bitcoinVersion}/bin/*
sleep 3
installed=$(sudo -u admin bitcoind --version | grep "${bitcoinVersion}" -c)
if [ ${installed} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})"
exit 1
fi
echo ""
echo "*** LITECOIN ***"
# based on https://medium.com/@jason.hcwong/litecoin-lightning-with-raspberry-pi-3-c3b931a82347
# set version (change if update is available)
litecoinVersion="0.16.0"
cd /home/admin/download
sudo -u admin wget https://download.litecoin.org/litecoin-${litecoinVersion}/linux/litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz
sudo -u admin tar -xvf litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin litecoin-${litecoinVersion}/bin/*
installed=$(sudo -u admin litecoind --version | grep "${litecoinVersion}" -c)
if [ ${installed} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Was not able to install litecoind version(${litecoinVersion})"
exit 1
fi
echo ""
echo "*** LND ***"
## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd
#lndVersion="0.5-beta-rc1"
#olaoluwaPGP="65317176B6857F98834EDBE8964EA263DD637C21"
#
# get LND resources
#cd /home/admin/download
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/lnd-linux-arm-v${lndVersion}.tar.gz
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt.sig
#sudo -u admin wget https://keybase.io/roasbeef/pgp_keys.asc
## test checksum
#checksum=$(sha256sum --check manifest-v${lndVersion}.txt --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c)
#if [ ${checksum} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND download checksum not OK"
# exit 1
#fi
## check gpg finger print
#fingerprint=$(gpg ./pgp_keys.asc 2>/dev/null | grep "${olaoluwaPGP}" -c)
#if [ ${fingerprint} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND download author PGP not OK"
# exit 1
#fi
#gpg --import ./pgp_keys.asc
#sleep 2
#verifyResult=$(gpg --verify manifest-v${lndVersion}.txt.sig manifest-v${lndVersion}.txt 2>&1)
#goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
#echo "goodSignature(${goodSignature})"
#correctKey=$(echo ${verifyResult} | grep "using RSA key ${olaoluwaPGP: -16}" -c)
#echo "correctKey(${correctKey})"
#if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})"
# exit 1
#fi
## install
#sudo -u admin tar -xzf lnd-linux-arm-v${lndVersion}.tar.gz
#sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-arm-v${lndVersion}/*
#sleep 3
#installed=$(sudo -u admin lnd --version | grep "${lndVersion}" -c)
#if [ ${installed} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> Was not able to install LND version(${lndVersion})"
# exit 1
#fi
##### Build from Source
# To quickly catch up get latest patches if needed
repo="github.com/lightningnetwork/lnd"
commit="a1f549754b61c1ba84466f0226997687127f7fc0"
# BUILDING LND FROM SOURCE
echo "*** Installing Go ***"
wget https://storage.googleapis.com/golang/go1.10.linux-armv6l.tar.gz
if [ ! -f "./go1.10.linux-armv6l.tar.gz" ]
then
echo "!!! FAIL !!! Download not success."
exit 1
fi
sudo tar -C /usr/local -xzf go1.10.linux-armv6l.tar.gz
sudo rm *.gz
sudo mkdir /usr/local/gocode
sudo chmod 777 /usr/local/gocode
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/usr/local/gocode
export PATH=$PATH:$GOPATH/bin
echo "*** Build LND from Source ***"
go get -d $repo
# make sure to always have the same code (commit) to build
# TODO: To update lnd -> change to latest commit
cd $GOPATH/src/$repo
sudo git checkout $commit
make && make install
sudo chmod 555 /usr/local/gocode/bin/lncli
sudo chmod 555 /usr/local/gocode/bin/lnd
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/admin/.bashrc"
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/pi/.bashrc"
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/bitcoin/.bashrc"
lndVersionCheck=$(lncli --version)
echo "LND VERSION: ${lndVersionCheck}"
if [ ${#lndVersionCheck} -eq 0 ]; then
echo "FAIL - Something went wrong with building LND from source."
echo "Sometimes it may just be a connection issue. Reset to fresh Rasbian and try again?"
exit 1
fi
echo ""
echo "** Link to /usr/local/bin ***"
sudo ln -s /usr/local/gocode/bin/lncli /usr/local/bin/lncli
sudo ln -s /usr/local/gocode/bin/lnd /usr/local/bin/lnd
echo ""
echo "*** RASPIBLITZ EXTRAS ***"
# for setup schell scripts
sudo apt-get -y install dialog bc
# enable copy of blockchain from 2nd HDD formatted with exFAT
sudo apt-get -y install exfat-fuse
# for blockchain torrent download
sudo apt-get -y install transmission-cli
# for background downloading
sudo apt-get -y install screen
# optimization for torrent download
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf"
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
# *** SHELL SCRIPTS AND ASSETS
# move files from gitclone
cd /home/admin/
sudo -u admin git clone https://github.com/rootzoll/raspiblitz.git
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.sh /home/admin
sudo -u admin chmod +x *.sh
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
# bash aoutstart for admin
sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc"
sudo bash -c "echo './00mainMenu.sh' >> /home/admin/.bashrc"
# bash aoutstart for pi
# run as exec to dont allow easy physical access by keyboard
# see https://github.com/rootzoll/raspiblitz/issues/54
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc'
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc'
# create /home/pi/setup.sh - which will get executed after reboot by autologin pi user
cat > /home/pi/setup.sh <<EOF
# make LCD screen rotation correct
sudo sed --in-place -i "57s/.*/dtoverlay=tft35a:rotate=270/" /boot/config.txt
EOF
sudo chmod +x /home/pi/setup.sh
# *** RASPIBLITZ IMAGE READY ***
echo ""
echo "**********************************************"
echo "ALMOST READY"
echo "**********************************************"
echo ""
echo "Your SD Card Image for RaspiBlitz is almost ready."
echo "Last step is to install LCD drivers. This will reboot your Pi when done."
echo ""
echo "Maybe take the chance and look thru the output above if you can spot any errror."
echo ""
echo "After final reboot - your SD Card Image is ready."
echo "Press ENTER to install LCD and reboot ..."
read key
# give Raspi a default hostname (optional)
sudo raspi-config nonint do_hostname "RaspiBlitz"
# *** RASPIBLITZ / LCD (at last - because makes a reboot) ***
# based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip
cd /home/admin/
sudo apt-mark hold raspberrypi-bootloader
git clone https://github.com/goodtft/LCD-show.git
sudo chmod -R 755 LCD-show
sudo chown -R admin:admin LCD-show
cd LCD-show/
sudo ./LCD35-show

171
home.admin/00infoBlitz.sh

@ -1,9 +1,4 @@
#!/bin/sh
# RaspiBolt LND Mainnet: systemd unit for getpublicip.sh script
# /etc/systemd/system/20-raspibolt-welcome.sh
# make executable and copy script to /etc/update-motd.d/
# root must be able to execute bitcoin-cli and lncli
# set colors
color_red='\033[0;31m'
@ -11,12 +6,23 @@ color_green='\033[0;32m'
color_yellow='\033[0;33m'
color_gray='\033[0;37m'
# load network
network=`sudo cat /home/admin/.network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# set datadir
bitcoin_dir="/home/bitcoin/.bitcoin"
bitcoin_dir="/home/bitcoin/.${network}"
lnd_dir="/home/bitcoin/.lnd"
lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net"
# get uptime & load
load=$(w | grep "load average:" | cut -c11-)
load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
# get CPU temp
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
@ -55,19 +61,19 @@ network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[
network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
# Bitcoin blockchain
btc_path=$(command -v bitcoin-cli)
btc_path=$(command -v ${network}-cli)
if [ -n ${btc_path} ]; then
btc_title="Bitcoin"
chain="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.chain')"
if [ -n $chain ]; then
btc_title=$network
blockchaininfo="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo)"
if [ ${#blockchaininfo} -gt 0 ]; then
btc_title="${btc_title} (${chain}net)"
# get sync status
block_chain="$(bitcoin-cli -datadir=${bitcoin_dir} getblockcount)"
block_verified="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.blocks')"
block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')"
block_diff=$(expr ${block_chain} - ${block_verified})
progress="$(bitcoin-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.verificationprogress')"
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
if [ ${block_diff} -eq 0 ]; then # fully synced
@ -89,13 +95,13 @@ if [ -n ${btc_path} ]; then
fi
# get last known block
last_block="$(bitcoin-cli -datadir=${bitcoin_dir} getblockcount)"
last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
if [ ! -z "${last_block}" ]; then
btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
fi
# get mem pool transactions
mempool="$(bitcoin-cli -datadir=${bitcoin_dir} getmempoolinfo | jq -r '.size')"
mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo | jq -r '.size')"
else
btc_line2="${color_red}NOT RUNNING\t\t"
@ -104,74 +110,115 @@ fi
# get IP address & port
local_ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
public_ip=$(curl -s http://v4v6.ipv6-test.com/api/myip.php)
public_port=$(cat ${bitcoin_dir}/bitcoin.conf 2>/dev/null | grep port= | awk -F"=" '{print $2}')
public_ip=$(curl -s http://v4.ipv6-test.com/api/myip.php)
public_port=$(cat ${bitcoin_dir}/${network}.conf 2>/dev/null | grep port= | awk -F"=" '{print $2}')
if [ "${public_port}" = "" ]; then
if [ $chain = "test" ]; then
public_port=18333
if [ "${network}" = "litecoin" ]; then
if [ "${chain}" = "test" ]; then
public_port=19333
else
public_port=9333
fi
else
public_port=8333
if [ "${chain}" = "test" ]; then
public_port=18333
else
public_port=8333
fi
fi
fi
public_check=$(curl -s https://bitnodes.earn.com/api/v1/nodes/me-${public_port}/ | jq .success)
if [ $public_check = "true" ]; then
public="Yes"
# CHAIN NETWORK
public_addr="??"
torInfo=""
# Version
networkVersion=$(${network}-cli -datadir=${bitcoin_dir} -version | cut -d ' ' -f6)
# TOR or IP
onionAddress=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo | grep '"address"' | cut -d '"' -f4)
if [ ${#onionAddress} -gt 0 ]; then
# TOR address
public_addr="${onionAddress}:${public_port}"
public=""
public_color="${color_green}"
torInfo="+ TOR"
else
public="Not reachable"
public_color="${color_red}"
# IP address
public_addr="${public_ip}:${public_port}"
public_check=$(timeout 2s nc -z ${public_ip} ${public_port}; echo $?)
if [ $public_check = "0" ]; then
public="Yes"
public_color="${color_green}"
else
public="Not reachable"
public_color="${color_red}"
fi
fi
public_addr="${public_ip}:${public_port}"
# get LND info
/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>&1 | grep "Please unlock" >/dev/null
wallet_unlocked=$?
if [ "$wallet_unlocked" -eq 0 ] ; then
#IP
# LIGHTNING NETWORK
ln_baseInfo="-"
ln_channelInfo="\n"
ln_external=""
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ "$wallet_unlocked" -gt 0 ] ; then
alias_color="${color_red}"
ln_alias="Wallet Locked"
else
ln_getInfo=$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
alias_color="${color_grey}"
ln_alias="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.alias')" 2>/dev/null
ln_walletbalance="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
ln_channelbalance="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
fi
ln_channels_online="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_external="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.uris[0]' | tr "@" " " | awk '{ print $2 }')" 2>/dev/null
ln_external_ip="$(echo $ln_external | tr ":" " " | awk '{ print $1 }' )" 2>/dev/null
if [ "$ln_external_ip" = "$public_ip" ]; then
external_color="${color_grey}"
else
external_color="${color_red}"
ln_alias=$(echo "${ln_getInfo}" | grep "alias" | cut -d '"' -f4)
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
if [ ${ln_sync} -eq 0 ]; then
if [ ${#ln_getInfo} -eq 0 ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
else
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "(height" | tail -n1 | awk '{print $10} {print $11} {print $12}' | tr -dc '0-9')
total=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.blocks')
ln_baseInfo="${color_red} waiting for chain sync"
if [ ${#item} -gt 0 ]; then
ln_channelInfo="scanning ${item}/${total}"
fi
fi
else
ln_walletbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
ln_channelbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} sat"
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat"
fi
fi
printf "
sleep 5
printf "
${color_yellow}
${color_yellow}
${color_yellow}
${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias}
${color_yellow} ${color_gray}Bitcoin Fullnode + Lightning Network
${color_yellow} ${color_yellow}%s
${color_yellow} ,/ ${color_yellow}
${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}
${color_yellow} .'____ ,' ${color_gray}Local ${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}
${color_yellow} / ,' ${color_gray}
${color_yellow} /,' ${color_gray}Bitcoin ${color_green}v0.16.1 ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} /' ${color_gray}LND ${color_green}v0.4.2 ${color_gray}wallet ${ln_walletbalance} sat
${color_yellow} ${color_gray}${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat
${color_yellow} ${ln_external}
${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} .'____ ,' ${color_gray}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}
${color_yellow} /,' ${color_gray}
${color_yellow} /' ${color_gray}LND ${color_green}v0.5-beta ${ln_baseInfo}
${color_yellow} ${color_gray}${ln_channelInfo}
${color_yellow}
${color_yellow}${ln_external}
" \
"RaspiBlitz v0.3" \
"RaspiBlitz v0.9" \
"-------------------------------------------" \
"${load##up*, }" "${temp}" \
"load average:${load##up*, }" "${temp}" \
"${hdd}" "${sync_percentage}"
echo "$(tput -T xterm sgr0)"
if [ ${#onionAddress} -eq 0 ]; then
# one extra space line at the end if nodeaddress is not TOR
echo ""
fi

94
home.admin/00infoLCD.sh

@ -1,22 +1,40 @@
#!/bin/sh
if [ "$USER" = "pi" ]; then
# check for after setup script
afterSetupScriptExists=$(ls /home/pi/setup.sh 2>/dev/null | grep -c setup.sh)
if [ ${afterSetupScriptExists} -eq 1 ]; then
echo "*** SETUP SCRIPT DETECTED ***"
sudo cat /home/pi/setup.sh
sudo /home/pi/setup.sh
sudo rm /home/pi/setup.sh
echo "DONE wait 6 secs ... one more reboot needed ... "
sudo shutdown -r now
fi
# load network
network=`sudo cat /home/admin/.network 2>/dev/null`
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# check if bitcoin service is configured
bitcoinInstalled=$(sudo -u bitcoin ls /mnt/hdd/bitcoin/ | grep -c bitcoin.conf)
bitcoinInstalled=$(sudo -u bitcoin ls /mnt/hdd/${network}/ 2>/dev/null | grep -c ${network}.conf)
if [ ${bitcoinInstalled} -eq 1 ]; then
# wait enough secs to let bitcoind init
dialog --pause " Waiting for Bitcoin to startup and init ..." 8 58 130
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 130
fi
# show updating status in loop
chain=""
while :
do
# refresh network
network=`sudo cat /home/admin/.network 2>/dev/null`
# get the setup state
setupStepExists=$(sudo -u admin ls -la /home/admin/.setup | grep -c .setup)
setupStepExists=$(sudo -u admin ls -la /home/admin/.setup 2>/dev/null | grep -c .setup)
if [ ${setupStepExists} -eq 1 ]; then
setupStep=$(sudo -u admin cat /home/admin/.setup)
else
@ -25,36 +43,51 @@ if [ "$USER" = "pi" ]; then
if [ ${setupStep} -eq 0 ]; then
# setup process has not started yet
# setup process has not started yet
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use password: raspiblitz\n"
boxwidth=$((${#localip} + 20))
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
boxwidth=$((${#localip} + 20))
sleep 3
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${setupStep} -lt 65 ]; then
# setup process has not started yet
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use your password A\n"
boxwidth=$((${#localip} + 20))
sleep 3
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${setupStep} -lt 100 ]; then
# setup process init is done and not finished
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false)
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
# setup process init is done and not finished
if [ ${#chain} -eq 0 ];then
# get chain if not available before
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
fi
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -gt 0 ]; then
if [ ${locked} -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 20))
boxwidth=$((${#localip} + 22))
dialog --backtitle "RaspiBlitz - Action Required" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${lndSyncing} -gt 0 ]; then
elif [ ${lndSynced} -eq 0 ]; then
# special case: LND is syncing
/home/admin/80scanLND.sh
sleep 5
sleep 20
else
@ -63,34 +96,35 @@ if [ "$USER" = "pi" ]; then
l2="ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 20))
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 10
sleep 3
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 10
fi
else
# RaspiBlitz is full Setup
# RaspiBlitz is full Setup
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 20))
boxwidth=$((${#localip} + 22))
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
else
# no special case - show status display
/home/admin/00infoBlitz.sh
sleep 5
sleep 5
else
fi
# no special case - show status display
/home/admin/00infoBlitz.sh
sleep 5
fi
fi
done

168
home.admin/00mainMenu.sh

@ -1,14 +1,29 @@
#!/bin/bash
## default menu settings
HEIGHT=11
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=4
CHOICE_HEIGHT=6
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
## get basic info (its OK if not set yet)
# get name
name=`sudo cat /home/admin/.hostname`
# get network
network=`sudo cat /home/admin/.network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
## get actual setup state
setupState=0;
if [ -f "/home/admin/.setup" ]; then
@ -19,17 +34,25 @@ if [ ${setupState} -eq 0 ]; then
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nYou need to setup and init Bitcoin and Lightning services: \n "
OPTIONS+=(1 "Start the Setup of your RaspiBlitz")
HEIGHT=10
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
elif [ ${setupState} -lt 100 ]; then
# make sure to have a init pause aufter fresh boot
uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}')
waittimesecs=$(expr 150 - $uptimesecs)
if [ ${waittimesecs} -gt 0 ]; then
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 ${waittimesecs}
fi
# continue setup
BACKTITLE="RaspiBlitz - Setup"
BACKTITLE="${name} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nContinue setup and init of Bitcoin and Lightning services: \n "
OPTIONS+=(1 "Continue Setup of your RaspiBlitz")
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
else
@ -38,25 +61,56 @@ else
uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}')
waittimesecs=$(expr 150 - $uptimesecs)
if [ ${waittimesecs} -gt 0 ]; then
dialog --pause " Waiting for Bitcoin to startup and init ..." 8 58 ${waittimesecs}
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 ${waittimesecs}
fi
# MAIN MENU AFTER SETUP
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
BACKTITLE="${name} / ${network} / ${chain}"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
# LOCK SCREEN
MENU="!!! YOUR WALLET IS LOCKED !!!"
OPTIONS+=(X "Unlock your Lightning Wallet with 'lncli unlock'")
OPTIONS+=(U "Unlock your Lightning Wallet with 'lncli unlock'")
else
# REGULAR MENU
switchOption="to MAINNET"
if [ "${chain}" = "main" ]; then
switchOption="back to TESTNET"
fi
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List")
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" \
RECEIVE "Create Invoice/PaymentRequest" \
lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List" \
MOBILE "Connect Mobile Wallet")
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
if [ "${network}" = "bitcoin" ]; then
OPTIONS+=(SWITCH "Switch ${switchOption}")
fi
torInstalled=$(sudo ls /mnt/hdd/tor/lnd9735/hostname 2>/dev/null | grep 'hostname' -c)
if [ ${torInstalled} -eq 0 ]; then
OPTIONS+=(TOR "Make reachable thru TOR")
else
OPTIONS+=(NYX "Monitor TOR")
fi
# final Options
OPTIONS+=(X "Console / Terminal")
fi
@ -75,7 +129,17 @@ case $CHOICE in
CLOSE)
exit 1;
;;
1) # SETUP
BITCOIN)
echo "bitcoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
LITECOIN)
echo "litecoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
CONTINUE)
./10setupBlitz.sh
exit 1;
;;
@ -91,14 +155,82 @@ case $CHOICE in
read key
./00mainMenu.sh
;;
NYX)
sudo nyx
./00mainMenu.sh
;;
lnchannels)
lnchannels
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
X) # unlock
CONNECT)
./BBconnectPeer.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
FUNDING)
./BBfundWallet.sh
echo "Press ENTER to return to main menu."
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."
read key
./00mainMenu.sh
;;
SEND)
./BBpayInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
RECEIVE)
./BBcreateInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
CLOSEALL)
./BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
SWITCH)
sudo ./95switchMainTest.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
MOBILE)
sudo ./97addMobileWalletShango.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
TOR)
sudo ./96addTorService.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
X)
lncli -h
echo "SUCH WOW come back with ./00mainMenu.sh"
;;
U) # unlock
./AAunlockLND.sh
./00mainMenu.sh
;;
esac
esac

168
home.admin/10setupBlitz.sh

@ -1,78 +1,177 @@
#!/bin/sh
echo ""
# load network
network=`cat .network`
# check chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# get setup progress
setupStep=$(sudo -u admin cat /home/admin/.setup)
if [ ${#setupStep} -eq 0 ];then
setupStep=0
fi
# if setup if ready --> REBOOT
if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})"
sleep 3
./90finishSetup.sh
exit 0
fi
# CHECK WHAT IS ALREADY WORKING
# check list from top down - so ./10setupBlitz.sh
# and re-enters the setup process at the correct spot
# in case it got interrupted
# check if lightning is running
lndRunning=$(systemctl status lnd.service | grep -c running)
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 1 ]; then
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false)
echo "LND is running ..."
sleep 1
# check if LND is locked
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
locked=0
# only when a wallet exists - it can be locked
if [ ${walletExists} -eq 1 ];then
echo "lnd wallet exists ... checking if locked"
sleep 2
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
fi
if [ ${locked} -gt 0 ]; then
# LND wallet is locked
./unlockLND.sh
./AAunlockLND.sh
./10setupBlitz.sh
elif [ ${lndSyncing} -gt 0 ]; then
exit 0
fi
# check if blockchain still syncing (during sync sometimes CLI returns with error at this point)
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainSyncing=1
if [ ${#chainInfo} -gt 0 ];then
chainSyncing=$(echo "${chainInfo}" | grep "true" -c)
fi
if [ ${chainSyncing} -eq 1 ]; then
echo "Sync Chain ..."
sleep 3
./70initLND.sh
else
./90finishSetup.sh
exit 0
fi
exit 1
# check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo | grep "synced_to_chain")
lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c)
fi
if [ ${lndSyncing} -eq 1 ]; then
echo "Sync LND ..."
sleep 3
./70initLND.sh
exit 0
fi
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup
echo "FINSIH ... "
sleep 3
./90finishSetup.sh
exit 0
fi
# check if bitcoin is running
bitcoinRunning=$(systemctl status bitcoind.service | grep -c running)
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
# double check
bitcoinRunning=$(${network}-cli getblockchaininfo | grep "initialblockdownload" -c)
fi
if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - Bitcoind is running"
echo "OK - ${network}d is running"
echo "Next step run Lightning"
./70initLND.sh
exit 1
fi
# check if HDD is mounted
mountOK=$(df | grep -c /mnt/hdd)
mountOK=$( df | grep -c /mnt/hdd )
if [ ${mountOK} -eq 1 ]; then
# if there are signs of blockchain data
if [ -d "/mnt/hdd/bitcoin" ]; then
echo "UNKOWN STATE"
# are there any signs of blockchain data
if [ -d "/mnt/hdd/${network}" ]; then
echo "UNKOWN STATE - there is blockain data folder, but blockchaind is not running"
echo "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Maybe try --> ./60finishHDD.sh"
echo "If you want start fresh --> sudo rm -r /mnt/hdd/${network}"
echo "Or something with the config is not correct."
exit 1
fi
# check if there is a download to continue
downloadProgressExists=$(sudo ls /home/admin/.Download.out 2>/dev/null | grep ".Download.out" -c)
if [ ${downloadProgressExists} -eq 1 ]; then
echo "found download in progress .."
./50downloadHDD.sh
exit 1
fi
# HDD is empty - ask how to get Blockchain
_temp="./download/dialog.$$"
dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \
--menu "You need a copy of the Blockchan - you have 3 options:" 13 75 4 \
1 "DOWNLOAD --> TESTNET + MAINNET thru torrent (RECOMMENDED 8h)" \
2 "COPY --> TESTNET + MAINNET from another HDD (TRICKY 3h)" \
3 "SYNC --> JUST TESTNET thru Bitoin Network (FALLBACK)" 2>$_temp
opt=${?}
#Bitcoin
if [ ${network} = "bitcoin" ]; then
echo "Bitcoin Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \
--menu "You need a copy of the Bitcoin Blockchain - you have 3 options:" 13 75 4 \
T "TORRENT --> TESTNET + MAINNET thru Torrent (DEFAULT)" \
D "DOWNLOAD --> TESTNET + MAINNET per FTP (FALLBACK)" \
C "COPY --> TESTNET + MAINNET from another HDD (TRICKY+FAST)" \
S "SYNC --> JUST TESTNET thru Bitoin Network (FALLBACK+SLOW)" 2>&1 >/dev/tty)
# Litecoin
elif [ ${network} = "litecoin" ]; then
echo "Litecoin Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title "Getting the Blockchain" \
--menu "You need a copy of the Litecoin Blockchain - you have 3 options:" 13 75 4 \
T "TORRENT --> MAINNET thru Torrent (DEFAULT)" \
D "DOWNLOAD --> MAINNET per FTP (FALLBACK)" \
C "COPY --> MAINNET from another HDD (TRICKY+FAST)" \
S "SYNC --> MAINNET thru Litecoin Network (FALLBACK+SLOW)" 2>&1 >/dev/tty)
# error
else
echo "FAIL Unkown network(${network})"
exit 1
fi
# set SetupState
echo "50" > /home/admin/.setup
clear
if [ $opt != 0 ]; then rm $_temp; exit; fi
menuitem=`cat $_temp`
rm $_temp
case $menuitem in
3)
T)
./50torrentHDD.sh
;;
C)
./50copyHDD.sh
;;
S)
./50syncHDD.sh
;;
1)
D)
./50downloadHDD.sh
;;
2)
./50copyHDD.sh
;;
esac
exit 1
fi
# the HDD is not mounted --> very early stage of setup
# if the script is called for the first time
@ -89,9 +188,8 @@ if [ ! -f "home/admin/.setup" ]; then
echo "*** Update System ***"
sudo apt-mark hold raspberrypi-bootloader
sudo apt-get update
sudo apt-get upgrade -f -y --force-yes
sudo apt-get upgrade -f -y --allow-change-held-packages
echo "OK - System is now up to date"
fi
# the HDD is already ext4 formated and called blockchain

33
home.admin/20initDialog.sh

@ -1,6 +1,9 @@
#!/bin/sh
_temp="./download/dialog.$$"
# load network
network=`cat .network`
# welcome and ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
@ -8,23 +11,23 @@ while [ ${#result} -eq 0 ]
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup" --inputbox "$l1$l2" 11 52 2>$_temp
result=`cat $_temp`
result=$( cat $_temp | tr -d [:space:] )
shred $_temp
done
# set lightning alias
sed -i "7s/.*/alias=$result/" ./assests/lnd.conf
sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
# store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system
echo $result >> /home/admin/.hostname
echo $result > /home/admin/.hostname
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords.
Referenced as password A, B, C and D.
A) Master User Password
B) Bitcoin RPC Password
B) Blockchain RPC Password
C) LND Wallet Password
D) LND Seed Password
@ -37,7 +40,7 @@ dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# get user input
result=`cat $_temp`
result=$( cat $_temp | tr -d [:space:] )
shred $_temp
# check input (check for more later)
@ -64,14 +67,26 @@ while [ ${#result} -lt 8 ]
do
dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Enter your RPC Password B (min 8 chars):" 9 52 2>$_temp
result=`cat $_temp`
result=$( cat $_temp | tr -d [:space:] )
shred $_temp
done
# set Bitcoin RPC Password (for admin bitcoin-cli & template for user bitcoin bitcoind)
sed -i "14s/.*/rpcpassword=$result/" ./assets/bitcoin.conf
sed -i "6s/.*/rpcpassword=$result/" ./.bitcoin/bitcoin.conf
# set Blockchain RPC Password (for admin cli & template for user bitcoin)
sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf
sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf
# success info dialog
dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52
clear
# init get publicip service
getpublicipExists=$(sudo ls /usr/local/bin/getpublicip.sh 2>/dev/null | grep "getpublicip.sh" -c)
if [ ${getpublicipExists} -eq 0 ]; then
echo "*** Installing getPublic ip script and service *** "
sudo cp ./assets/getpublicip.sh /usr/local/bin/getpublicip.sh
sudo chmod +x /usr/local/bin/getpublicip.sh
sudo cp ./assets/getpublicip.service /etc/systemd/system/getpublicip.service
sudo systemctl enable getpublicip
sudo systemctl start getpublicip
echo ""
fi

29
home.admin/30initHDD.sh

@ -2,9 +2,32 @@
echo ""
echo "*** Checking if HDD is connected ***"
sleep 5
device="sda1"
existsHDD=$(lsblk | grep -c sda1)
if [ ${existsHDD} -eq 1 ]; then
echo "OK - HDD found as sda1"
echo "OK - HDD found at sda1"
# check if there is s sda2
existsHDD2=$(lsblk | grep -c sda2)
if [ ${existsHDD2} -eq 1 ]; then
echo "OK - HDD found at sda2 ... determine which is bigger"
# get both with size
size1=$(lsblk -o NAME,SIZE -b | grep "sda1" | awk '{ print substr( $0, 12, length($0)-2 ) }' | xargs)
echo "sda1(${size1})"
size2=$(lsblk -o NAME,SIZE -b | grep "sda2" | awk '{ print substr( $0, 12, length($0)-2 ) }' | xargs)
echo "sda2(${size2})"
# chosse to run with the bigger one
if [ ${size2} -gt ${size1} ]; then
echo "sda2 is BIGGER - run with this one"
device="sda2"
else
echo "sda1 is BIGGER - run with this one"
fi
fi
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
echo "FAIL - HDD is mounted"
@ -12,10 +35,10 @@ if [ ${existsHDD} -eq 1 ]; then
else
echo ""
echo "*** Formatting the HDD ***"
echo "WARNING ALL DATA ON HDD WILL GET DELETED"
echo "WARNING ALL DATA ON HDD WILL GET DELETED - CAN TAKE SOME TIME"
echo "Wait until you get a OK or FAIL"
sleep 4
sudo mkfs.ext4 /dev/sda1 -F -L BLOCKCHAIN
sudo mkfs.ext4 /dev/${device} -F -L BLOCKCHAIN
echo "format ext4 done - wait 6 secs"
sleep 6
formatExt4OK=$(lsblk -o UUID,NAME,FSTYPE,SIZE,LABEL,MODEL | grep BLOCKCHAIN | grep -c ext4)

20
home.admin/40addHDD.sh

@ -1,10 +1,14 @@
#!/bin/sh
echo ""
# load network
network=`cat .network`
echo "*** Adding HDD to the System ***"
sleep 5
existsHDD=$(lsblk | grep -c sda1)
if [ ${existsHDD} -eq 1 ]; then
echo "OK - HDD found as sda1"
existsHDD=$(lsblk | grep -c sda)
if [ ${existsHDD} -gt 0 ]; then
echo "OK - HDD found as sda"
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
echo "FAIL - HDD is already mounted"
@ -38,13 +42,15 @@ if [ ${existsHDD} -eq 1 ]; then
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
echo "OK - HDD is mounted"
echo ""
echo ""
# set SetupState
echo "40" > /home/admin/.setup
echo "*** Analysing HDD Content ***"
if [ -d "/mnt/hdd/bitcoin" ]; then
if [ -d "/mnt/hdd/${network}" ]; then
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null
sudo chown -R bitcoin:bitcoin /mnt/hdd/litecoin 2>/dev/null
echo "Looks like the HDD is prepared with the Blockchain."
echo "Continuing with finishing the system setup ..."
./60finishHDD.sh
@ -63,6 +69,6 @@ if [ ${existsHDD} -eq 1 ]; then
fi
fi
else
echo "FAIL - no HDD as device sda1 found"
echo "check if HDD is properly connected and has enough power - then try again"
echo "FAIL - no HDD as device sda found"
echo "check if HDD is properly connected and has enough power - then try again with reboot"
fi

30
home.admin/50copyHDD.sh

@ -1,4 +1,8 @@
#!/bin/sh
# load network
network=`cat .network`
echo ""
echo "*** Check 1st HDD ***"
sleep 4
@ -19,7 +23,7 @@ echo "Like this one: https://www.amazon.de/dp/B00ZJBIHVY"
echo "If you see on LCD a error on connecting the 2nd HDD do a restart."
echo ""
echo "You can use the HDD of another RaspiBlitz for this."
echo "The 2nd HDD needs to be formated Ext4/exFAT and the folder 'bitcoin' is in root of HDD."
echo "The 2nd HDD needs to be formated Ext4/exFAT and the folder '${network}' is in root of HDD."
echo ""
echo "**********************************"
echo "--> Please connect now the 2nd HDD"
@ -72,18 +76,18 @@ echo ""
echo "*** Copy Blockchain ***"
sudo rsync --append --info=progress2 -a /mnt/genesis/bitcoin /mnt/hdd/
echo "cleaning up - ok if files do not exists"
sudo rm /mnt/hdd/bitcoin/bitcoin.conf
sudo rm /mnt/hdd/bitcoin/bitcoin.pid
sudo rm /mnt/hdd/bitcoin/banlist.dat
sudo rm /mnt/hdd/bitcoin/debug.log
sudo rm /mnt/hdd/bitcoin/fee_estimates.dat
sudo rm /mnt/hdd/bitcoin/mempool.dat
sudo rm /mnt/hdd/bitcoin/peers.dat
sudo rm /mnt/hdd/bitcoin/testnet3/banlist.dat
sudo rm /mnt/hdd/bitcoin/testnet3/debug.log
sudo rm /mnt/hdd/bitcoin/testnet3/fee_estimates.dat
sudo rm /mnt/hdd/bitcoin/testnet3/mempool.dat
sudo rm /mnt/hdd/bitcoin/testnet3/peers.dat
sudo rm /mnt/hdd/${network}/${network}.conf
sudo rm /mnt/hdd/${network}/${network}.pid
sudo rm /mnt/hdd/${network}/banlist.dat
sudo rm /mnt/hdd/${network}/debug.log
sudo rm /mnt/hdd/${network}/fee_estimates.dat
sudo rm /mnt/hdd/${network}/mempool.dat
sudo rm /mnt/hdd/${network}/peers.dat
sudo rm /mnt/hdd/${network}/testnet3/banlist.dat
sudo rm /mnt/hdd/${network}/testnet3/debug.log
sudo rm /mnt/hdd/${network}/testnet3/fee_estimates.dat
sudo rm /mnt/hdd/${network}/testnet3/mempool.dat
sudo rm /mnt/hdd/${network}/testnet3/peers.dat
sudo umount -l /mnt/genesis
echo "OK - Copy done :)"
echo ""

246
home.admin/50downloadHDD.sh

@ -1,90 +1,174 @@
#!/bin/sh
#!/bin/bash
echo ""
# name of torrentfile = name of directory in torrent
torrent="raspiblitz-hdd-2018-07-16"
# size of a valid download (run on seed directory 'du -s ./[TORRENTDIRECTORY]')
torrentsize=462470200
# *** BITCOIN ***
bitcoinList="" # url to list with other sources
bitcoinUrl="ftp://anonymous:anonymous@91.83.237.185:21/raspiblitz-bitcoin-2018-07-16"
bitcoinSize=231000000 # 231235816-tolerance
echo ""
echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
# HDD is mounted
if [ -d "/mnt/hdd/bitcoin" ]; then
# HDD has already content
echo "It seems that HDD has already content. Try to continue with ./finishHDD.sh"
else
# HDD is empty - download HDD content
echo "OK - HDD is ready."
echo ""
downloading=1
retry=0
while [ $downloading -eq 1 ]
do
echo "*** Downloading HDD ***"
tmpfile=$(mktemp)
chmod a+x $tmpfile
echo "killall transmission-cli" > $tmpfile
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile
# *** LITECOIN ***
litecoinList="" # url to list with other sources
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29"
litecoinSize=19180000 # 19184960-tolerance
# load network
network=`cat .network`
# settings based on network
list=$bitcoinList
url=$bitcoinUrl
size=$bitcoinSize
if [ "$network" = "litecoin" ]; then
list=$litecoinList
url=$litecoinUrl
size=$litecoinSize
fi
# screen background monitoring settings
name="Download"
targetDir="/mnt/hdd/download/"
targetSize=$size
maxTimeoutLoops=100000
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}"
# starting session if needed
echo "checking if ${name} has a running screen session"
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
echo "isRunning(${isRunning})"
if [ ${isRunning} -eq 0 ]; then
echo "Starting screen session"
sudo mkdir ${targetDir} 2>/dev/null
screen -S ${name} -dm ${command}
else
echo "Continue screen session"
fi
sleep 3
# monitor session
screenDump="... started ..."
actualSize=0
timeout=1
timeoutInfo="-"
while :
do
# check if session is still running
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
if [ ${isRunning} -eq 0 ]; then
timeout=0
echo "OK - session finished"
break
fi
# calculate progress and write it to file for LCD to read
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
if [ ${#actualSize} -eq 0 ]; then
freshSize=0
fi
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
echo $progress > '.${name}.progress'
# detect if since last loop any progress occured
if [ ${actualSize} -eq ${freshSize} ]; then
timeoutInfo="${timeout}/${maxTimeoutLoops}"
timeout=$(( $timeout + 1 ))
else
timeout=1
timeoutInfo="no timeout detected"
fi
actualSize=$freshSize
# detect if mx timeout loop limit is reached
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then
echo "FAIL - download hit timeout"
break
fi
# display info screen
clear
echo "****************************************************"
echo "Monitoring Screen Session: ${name}"
echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
echo "Timeout: ${timeoutInfo}"
echo "If needed press key x to stop ${name}"
echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later."
echo "****************************************************"
screen -S ${name} -X hardcopy .${name}.out
newScreenDump=$(cat .Download.out | grep . | tail -8)
if [ ${#newScreenDump} -gt 0 ]; then
screenDump=$newScreenDump
fi
echo "$screenDump"
# wait 2 seconds for key input
read -n 1 -t 2 keyPressed
# check if user wants to abort session
if [ "${keyPressed}" = "x" ]; then
echo ""
echo "*** Checking Download ***"
echo "wait a moment"
sleep 5
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9')
if [ ${#downloadsize} -eq 0 ]; then
downloadsize=0
fi
# add some tolerance for checking
torrentsize="$(($torrentsize-1024000))"
echo "download size is(${downloadsize})"
if [ ${downloadsize} -lt ${torrentsize} ]; then
echo ""
echo "FAIL - download is not ${torrentsize}"
retry=$(($retry+1))
if [ ${retry} -gt 2 ]; then
echo "All Retry FAILED"
downloading=0
else
echo "--> RETRY(${retry}) in 10 secs"
sleep 10
echo ""
fi
else
echo "OK - Download is complete"
downloading=0
fi
done
if [ ${downloadsize} -lt ${torrentsize} ]; then
sleep 3
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57
response=$?
case $response in
0) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;;
esac
#
./00mainMenu.sh
exit 1;
echo "Aborting ${name}"
break
fi
echo ""
echo "*** Moving Files ***"
echo "moving files ..."
sudo mv /mnt/hdd/$torrent /mnt/hdd/bitcoin
echo ""
done
# set SetupState
echo "50" > /home/admin/.setup
echo "*** Next Step ***"
echo "You can now use this HDD as a source to copy the Blockchain during the setup of another RaspiBlitz."
sleep 4
# clean up
rm -f .${name}.out
rm -f .${name}.progress
# continue setup
./60finishHDD.sh
# quit session if still running
if [ ${isRunning} -eq 1 ]; then
# get the PID of screen session
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs)
echo "killing screen session PID(${sessionPID})"
# kill all child processes of screen sceesion
pkill -P ${sessionPID}
echo "proccesses klilled"
sleep 3
# tell the screen session to quit and wait a bit
screen -S ${name} -X quit 1>/dev/null
sleep 3
echo "cleaning screen"
screen -wipe 1>/dev/null
sleep 3
fi
fi
else
# HDD is not available yet
echo "*** Mount HDD on /mnt/hdd first ***"
# the path wget will download to
targetPath=$(echo ${url} | cut -d '@' -f2)
echo "path to downloaded data is ${targetPath}"
# calculate progress and write it to file for LCD to read
finalSize=$( du -s ${targetDir} 2>/dev/null | head -n1 | awk '{print $1;}' )
if [ ${#finalSize} -eq 0 ]; then
finalSize=0
fi
echo "final size is ${finalSize} of targeted size ${targetSize}"
# check result
if [ ${finalSize} -lt ${targetSize} ]; then
# Download failed
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 8 57
response=$?
case $response in
1) sudo rm -rf ${targetDir} ;;
esac
./00mainMenu.sh
exit 1;
else
# Download worked
echo "*** Moving Files ***"
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network}
echo "OK"
# continue setup
./60finishHDD.sh
fi

40
home.admin/50syncHDD.sh

@ -1,25 +1,31 @@
#!/bin/sh
msg=""
msg="$msg Syncing is just practical for Bitcoin TESTNET!\n"
msg="$msg TESTNET is OK for learning, testing and development.\n"
msg="$msg MAINNET is where things get real and fun.\n"
msg="$msg \n"
msg="$msg Syncing MAINNET on a raspberry is NOT practical.\n"
msg="$msg If you want MAINET, go back & try DOWNLOAD.\n"
msg="$msg \n"
msg="$msg Do you really want to work with ONLY TESTNET?"
# load network
network=`cat .network`
dialog --title " WARNING " --yesno "${msg}" 12 57
response=$?
case $response in
0) echo "--> OK";;
1) ./10setupBlitz.sh; exit 1;;
255) ./10setupBlitz.sh; exit 1;;
esac
# only show warning when bitcoin
if [ "$network" = "bitcoin" ]; then
msg=""
msg="$msg Syncing is just practical for Bitcoin TESTNET!\n"
msg="$msg TESTNET is OK for learning, testing and development.\n"
msg="$msg MAINNET is where things get real and fun.\n"
msg="$msg \n"
msg="$msg Syncing MAINNET on a raspberry is NOT practical.\n"
msg="$msg If you want MAINET, go back & try DOWNLOAD.\n"
msg="$msg \n"
msg="$msg Do you really want to work with ONLY TESTNET?"
dialog --title " WARNING " --yesno "${msg}" 12 57
response=$?
case $response in
0) echo "--> OK";;
1) ./10setupBlitz.sh; exit 1;;
255) ./10setupBlitz.sh; exit 1;;
esac
fi
echo "*** Activating Blockain Sync ***"
sudo mkdir /mnt/hdd/bitcoin
sudo mkdir /mnt/hdd/${network}
echo "OK - sync is activated"
# set SetupState

68
home.admin/50torrentHDD.sh

@ -0,0 +1,68 @@
#!/bin/sh
# *** BITCOIN Torrent ***
bitcoinTorrent="raspiblitz-bitcoin-2018-07-16"
bitcoinTorrentsize=231230512
# *** LITECOIN Torrent ***
litecoinTorrent="raspiblitz-litecoin-2018-07-29"
litecoinTorrentsize=10240000
# load network
network=`cat .network`
# settings based on network
torrent=$bitcoinTorrent
torrentsize=$bitcoinTorrentsize
if [ "$network" = "litecoin" ]; then
torrent=$litecoinTorrent
torrentsize=$litecoinTorrentsize
fi
echo ""
echo "torrentFile: ${torrent}"
echo ""
echo "*** Downloading TORRENT ***"
echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:"
echo "CTRL+z start ./10setupBlitz.sh choose other option"
echo "***************************"
echo ""
tmpfile=$(mktemp)
chmod a+x $tmpfile
echo "killall transmission-cli" > $tmpfile
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile
echo "OK - Download closed"
echo ""
echo "*** Checking TORRENT ***"
echo "wait a moment"
sleep 5
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9')
if [ ${#downloadsize} -eq 0 ]; then
downloadsize=0
fi
# add some tolerance for checking
size="$(($size-1024000))"
echo "download size is(${downloadsize}) needs to be minimum(${size})"
if [ ${downloadsize} -lt ${size} ]; then
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
response=$?
case $response in
1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;;
esac
./00mainMenu.sh
exit 1;
fi
echo "*** Moving Files ***"
echo "moving files ..."
sudo mv /mnt/hdd/$torrent /mnt/hdd/${network}
echo ""
# set SetupState
echo "50" > /home/admin/.setup
# continue setup
./60finishHDD.sh

46
home.admin/60finishHDD.sh

@ -1,34 +1,52 @@
#!/bin/sh
echo ""
# load network
network=`cat .network`
echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
# HDD is mounted
if [ -d "/mnt/hdd/bitcoin" ]; then
if [ -d "/mnt/hdd/${network}" ]; then
# HDD has content - continue
echo "OK - HDD is ready."
###### LINK HDD
echo ""
echo "*** Prepare Bitcoin ***"
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin
echo "*** Prepare ${network} ***"
sudo killall -u bitcoin
sleep 5
sudo rm -r /home/bitcoin/.${network} 2>/dev/null
sleep 2
if [ -d /home/bitcoin/.${network} ]; then
echo "FAIL - /home/bitcoin/.${network} exists and cannot be removed!"
exit 1
fi
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
sudo mkdir /home/admin/.${network}
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network}
sudo mkdir /mnt/hdd/lnd
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin
sudo chown -R bitcoin:bitcoin /mnt/hdd/${network}
sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd
sudo chown -R bitcoin:bitcoin /home/bitcoin/.bitcoin
sudo chown -R bitcoin:bitcoin /home/bitcoin/.${network}
sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd
echo "OK - Bitcoin setup ready"
echo "OK - ${network} setup ready"
###### START BITCOIN SERVICE
###### START NETWORK SERVICE
echo ""
echo "*** Start Bitcoin ***"
sudo systemctl enable bitcoind.service
sudo systemctl start bitcoind.service
echo "Giving bitcoind service 180 seconds to init - please wait ..."
echo "*** Start ${network} ***"
echo "This can take a while .."
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
sudo chmod +x /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload
sudo systemctl enable ${network}d.service
sudo systemctl start ${network}d.service
echo "Giving ${network}d service 180 seconds to init - please wait ..."
sleep 180
echo "OK - bitcoind started"
echo "OK - ${network}d started"
sleep 2
# set SetupState
@ -43,4 +61,4 @@ if [ ${mountOK} -eq 1 ]; then
else
# HDD is not available yet
echo "FAIL - HDD is not mounted."
fi
fi

188
home.admin/70initLND.sh

@ -1,47 +1,66 @@
#!/bin/sh
echo ""
# load network
network=`cat .network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# verify that bitcoin is running
echo "*** Checking Bitcoin ***"
bitcoinRunning=$(systemctl status bitcoind.service | grep -c running)
echo "*** Checking ${network} ***"
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
#doublecheck
bitcoinRunning=$(${network}-cli getblockchaininfo | grep -c verificationprogress)
fi
if [ ${bitcoinRunning} -eq 0 ]; then
# HDD is not available yet
echo "FAIL - Bitcoind is not running"
echo "FAIL - ${network}d is not running"
echo "recheck with orignal tutorial -->"
echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md"
fi
echo "OK - Bitcoind is running"
echo "OK - ${network}d is running"
echo ""
###### Wait for Blochain Sync
echo "*** Syncing Blockchain ***"
ready=0
while [ ${ready} -eq 0 ]
do
progress="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
ready=$(echo $progress'>0.99' | bc -l)
if [ ${ready} -eq 0 ]; then
echo "${sync_percentage}"
else
if [ ${ready} -eq 1 ]; then
echo "${sync_percentage}"
else
echo "waiting to start sync"
ready=0
fi
fi
echo "${sync_percentage}"
sleep 3
done
echo "OK - Blockchain is synced"
echo ""
###### Wait for Blochain Sync --> LET DO THIS LATER ON LND SCAN
#echo "*** Syncing Blockchain ***"
#ready=0
#while [ ${ready} -eq 0 ]
# do
# progress="$(sudo -u bitcoin ${network}-cli getblockchaininfo | jq -r '.verificationprogress')"
# verySmallProgress=$(echo $progress | grep -c 'e-');
# if [ ${verySmallProgress} -eq 1 ]; then
# progress="0.00";
# fi
# ready=$(echo $progress'>0.99' | bc -l)
# sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
# #echo "progress($progress) verySmallProgress($verySmallProgress) ready($ready) sync_percentage($sync_percentage)"
# if [ ${#ready} -eq 0 ]; then
# echo "waiting for init ... can take a while"
# ready=0
# elif [ "$sync_percentage" = "0.00%" ]; then
# echo "waiting for network ... can take a while"
# ready=0
# elif [ ${ready} -eq 0 ]; then
# echo "${sync_percentage}"
# else
# echo "finishing sync ... can take a while"
# fi
# sleep 3
# done
#echo "OK - Blockchain is synced"
#echo ""
###### LND Config
echo "*** LND Config ***"
configExists=$( sudo ls /mnt/hdd/lnd/ | grep -c lnd.conf )
if [ ${configExists} -eq 0 ]; then
sudo cp /home/admin/assets/lnd.conf /mnt/hdd/lnd/lnd.conf
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
if [ -d /home/bitcoin/.lnd ]; then
echo "OK - LND config written"
@ -56,39 +75,47 @@ echo ""
###### Start LND
echo "*** Starting LND ***"
lndRunning=$(systemctl status lnd.service | grep -c running)
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
sudo systemctl enable lnd
sudo systemctl start lnd
echo "Started LND .. waiting 30 seconds for init ..."
sleep 30
echo "Starting LND ... give 120 seconds to init."
sleep 120
fi
###### Check LND is running
lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL - LND is not running"
echo "recheck with original tutorial -->"
echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md"
exit 1
fi
lndRunning=0
while [ ${lndRunning} -eq 0 ]
do
lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
date +%s
echo "LND not ready yet ... waiting another 60 seconds."
echo "If this takes too long (more then 10min total) --> CTRL+c and report Problem"
sleep 60
fi
done
echo "OK - LND is running"
echo ""
###### Instructions on Creating LND Wallet
setupStep=0
setupStep=$(sudo cat "/home/admin/.setup")
if [ ${setupStep} -lt 65 ]; then
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
echo "walletExists(${walletExists})"
sleep 2
if [ ${walletExists} -eq 0 ]; then
# setup state signals, that no wallet has been created yet
dialog --backtitle "RaspiBlitz - LND Lightning Wallet" --msgbox "
Bitcoin and Lighthing Services are installed.
dialog --backtitle "RaspiBlitz - LND Lightning Wallet (${network}/${chain})" --msgbox "
${network} and Lighthing Services are installed.
You now need to setup your Lightning Wallet:
We will now call the command: lncli create
lncli = Lightning Network Command Line Interface
Learn more: https://api.lightning.community
Press OK and follow the 'Helping Instructions'.
" 14 52
clear
@ -100,37 +127,67 @@ Press OK and follow the 'Helping Instructions'.
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************"
echo ""
echo "lncli create"
sudo -u bitcoin lncli create
echo "lncli --chain=${network} create"
# execute command and monitor error
_error="./.error.out"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create 2>$_error
error=`cat ${_error}`
if [ ${#error} -gt 0 ]; then
echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo "${error}"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "Press ENTER to retry ... or CTRL-c to EXIT"
read key
echo "Starting RETRY ..."
./70initLND.sh
exit 1
fi
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!! Make sure to write down the 24 words (cipher seed mnemonic) !!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "If you are ready. Press ENTER."
read key
# set SetupState to 75 (mid thru this process)
echo "65" > /home/admin/.setup
fi
echo "--> lets wait 30 seconds for LND to get ready"
sleep 30
echo "--> lets wait 60 seconds for LND to get ready"
sleep 60
###### Copy LND macaroons to admin
echo ""
echo "*** Copy LND Macaroons to user admin ***"
macaroonExists=$(sudo -u bitcoin ls -la /mnt/hdd/lnd/admin.macaroon | grep -c admin.macaroon)
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
./AAunlockLND.sh
sleep 3
fi
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon
echo ""
echo "FAIL - LND Macaroons not created"
echo "Please check the following LND issue:"
echo "https://github.com/lightningnetwork/lnd/issues/890"
echo "You may want try again with starting ./70initLND.sh"
exit 1
fi
sudo mkdir /home/admin/.lnd
macaroonExists=$(sudo ls -la /home/admin/.lnd/ | grep -c admin.macaroon)
macaroonExists=$(sudo ls -la /home/admin/.lnd/data/chain/${network}/${chain}net/ | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo mkdir /home/admin/.lnd
sudo mkdir /home/admin/.lnd/data
sudo mkdir /home/admin/.lnd/data/chain
sudo mkdir /home/admin/.lnd/data/chain/${network}
sudo mkdir /home/admin/.lnd//data/chain/${network}/${chain}net
sudo cp /home/bitcoin/.lnd/tls.cert /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/admin.macaroon /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/lnd.conf /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon /home/admin/.lnd/data/chain/${network}/${chain}net
sudo chown -R admin:admin /home/admin/.lnd/
echo "OK - LND Macaroons created"
else
@ -139,11 +196,10 @@ fi
###### Unlock Wallet (if needed)
echo "*** Check Wallet Lock ***"
chain=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "OK - Wallet is locked ... starting unlocking dialog"
./unlockLND.sh
./AAunlockLND.sh
else
echo "OK - Wallet is already unlocked"
fi
@ -152,20 +208,30 @@ fi
echo ""
echo "*** Check LND Sync ***"
item=0
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')"
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true)
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 0 ]; then
echo "OK - wait for LND to be synced"
while :
do
# show sync status
./80scanLND.sh
sleep 3
sleep 15
# break loop when synced
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true)
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 1 ]; then
break
fi
# break loop when wallet is locked
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 1 ]; then
break
fi
sleep 15
done
clear
else

68
home.admin/80scanLND.sh

@ -1,20 +1,66 @@
# load network
network=`sudo cat /home/admin/.network`
# load name of Blitz
name=`sudo cat /home/admin/.hostname`
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# parse the actual scanned height progress from LND logs
item=0
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')"
gotData=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c height)
if [ ${gotData} -gt 0 ]; then
item=$(sudo tail -n 100 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep height | tail -n1 | awk '{print $9} {print $10} {print $11} {print $12}' | tr -dc '0-9')
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo)
chain="$(echo "${blockchaininfo}" | jq -r '.chain')"
## TRY to get the actual progress height of scanning
# 1) First try the "Rescanned through block" - it seems to happen if it restarts
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Rescanned through block" | tail -n1 | cut -d ']' -f2 | cut -d '(' -f2 | tr -dc '0-9')
# 2) Second try the "Caught up to height" - thats the usual on first scan start
if [ ${#item} -eq 0 ]; then
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -n1 | cut -d ']' -f2 | tr -dc '0-9')
fi
# TODO next fallback try later here if necessary
if [ ${#item} -eq 0 ]; then
item="?"
fi
# get total number of blocks
total=$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.blocks')
total=$(echo "${blockchaininfo}" | jq -r '.blocks')
# put scanstate
scanstate="${item}/${total}"
# calculate progress in percent
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }")
if [ ${percent} -e 100 ]; then
# normally if 100% gets calculated, item parsed the wrong height
percent=0
# get blockchain sync progress
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
# check if blockchain is still syncing
heigh=6
width=44
isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c)
isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c )
if [ ${isWaitingBlockchain} -gt 0 ]; then
isInitialChainSync=1
fi
if [ ${isInitialChainSync} -gt 0 ]; then
heigh=7
infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some time.\n ssh admin@${localip}\n Password A"
if [ "$USER" = "admin" ]; then
heigh=6
width=53
infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi
else
heigh=7
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A")
if [ "$USER" = "admin" ]; then
heigh=6
width=53
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi
fi
# display progress to user
dialog --backtitle "RaspiBlitz" --infobox " Lightning Rescanning Blockchain $percent%\nplease wait - this can take some time" 4 42
sleep 3
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${name})" --infobox "${infoStr}" ${heigh} ${width}

50
home.admin/90finishSetup.sh

@ -4,7 +4,7 @@ echo ""
# add bonus scripts
./91addBonus.sh
###### SWAP
###### SWAP & FS
echo "*** SWAP file ***"
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
if [ ${swapExists} -eq 1 ]; then
@ -20,7 +20,13 @@ else
sudo dphys-swapfile setup
sudo chmod 0600 /mnt/hdd/swapfile
sudo dphys-swapfile swapon
# expand FS of SD
echo "*** Expand RootFS ***"
sudo raspi-config --expand-rootfs
echo ""
fi
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
if [ ${swapExists} -eq 1 ]; then
echo "OK - SWAP is working"
@ -32,14 +38,39 @@ else
sleep 60
fi
# firewall - just install (not configure)
echo ""
echo "*** Setting and Activating Firewall ***"
sudo apt-get install -y ufw
echo "deny incoming connection on other ports"
sudo ufw default deny incoming
echo "allow outgoing connections"
sudo ufw default allow outgoing
echo "allow: ssh"
sudo ufw allow ssh
echo "allow: bitcoin testnet"
sudo ufw allow 18333 comment 'bitcoin testnet'
echo "allow: bitcoin mainnet"
sudo ufw allow 8333 comment 'bitcoin mainnet'
echo "allow: litecoin mainnet"
sudo ufw allow 9333 comment 'litecoin mainnet'
echo 'allow: lightning testnet'
sudo ufw allow 19735 comment 'lightning testnet'
echo "allow: lightning mainnet"
sudo ufw allow 9735 comment 'lightning mainnet'
echo "allow: lightning gRPC"
sudo ufw allow 10009 comment 'lightning gRPC'
echo "allow: trasmission"
sudo ufw allow 51413 comment 'transmission'
echo "allow: local web admin"
sudo ufw allow from 192.168.0.0/24 to any port 80 comment 'allow local LAN web'
echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# mark setup is done
echo "90" > /home/admin/.setup
# set the hostname inputed on initDialog
hostname=`cat .hostname`
echo "Setting new network hostname '$hostname'"
sudo hostnamectl set-hostname ${hostname}
# show info to user
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
Press OK for a final reboot.
@ -48,7 +79,14 @@ dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) "
you need to unlock the LND wallet.
" 10 42
# set the hostname inputed on initDialog
hostname=`cat .hostname`
echo "Setting new network hostname '$hostname'"
sudo raspi-config nonint do_hostname ${hostname}
# mark setup is done (100%)
echo "100" > /home/admin/.setup
clear
echo "Setup done. Rebooting now."
sudo shutdown -r now

13
home.admin/91addBonus.sh

@ -1,5 +1,6 @@
# https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_67_additional-scripts.md
echo ""
echo "*** Adding: raspibolt_67_additional-scripts.md"
echo "Creating the command lnbalance as well as lnchannels which will give you a nicer output"
cd
@ -11,10 +12,12 @@ chmod +x lnbalance
chmod +x lnchannels
sudo cp lnchannels /usr/local/bin
sudo cp lnbalance /usr/local/bin
echo "Done. Let's try them out"
echo "OK"
echo "installing bash completion for bitcoin-cli and lncli"
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
sudo cp *.bash-completion /etc/bash_completion.d/
echo "OK - bash completion available after next login"
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
cd
rm -r /home/admin/tmpScriptDL
echo "Output of lnbalance:"
lnbalance
echo "Output of lnchannels:"
lnchannels

125
home.admin/95switchMainTest.sh

@ -0,0 +1,125 @@
#!/usr/bin/env bash
# based on pull request from vnnkl
# load network
network=`cat .network`
echo ""
echo "*** Switch between Testnet/Mainnet ***"
# allow only on bitcoin network
if [ "${network}" = "bitcoin" ]; then
echo "Bitcoin network can be switched between testnet/mainnet ..."
else
echo "FAIL - Only Bitcoin Network can be switched between man/tast at the moment."
exit 1
fi
NETWORK_CONFIG="/home/bitcoin/.${network}/${network}.conf"
NETWORK_TEMPLATE="/home/admin/assets/${network}.conf"
LND_CONFIG="/home/bitcoin/.lnd/lnd.conf"
LND_TEMPLATE="/home/admin/assets/lnd.${network}.conf"
echo "NETWORK_CONFIG(${NETWORK_CONFIG})"
echo "LND_CONFIG(${LND_CONFIG})"
echo "NETWORK_TEMPLATE(${NETWORK_TEMPLATE})"
echo "LND_TEMPLATE(${LND_TEMPLATE})"
# function to detect main/testnet
function isMainnet(){
grep "^#testnet=1$" -q $NETWORK_CONFIG && return 1
return 0
}
function switchToMainnet {
echo "switching to mainnet"
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_CONFIG
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to mainnet"
}
function switchToTestnet {
echo "switching to testnet"
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_CONFIG
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to testnet"
}
# LND Service
lndInstalled=$(systemctl status lnd.service | grep loaded -c)
if [ ${lndInstalled} -gt 0 ]; then
echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli --chain=${network} closeallchannels' or main menu option."
echo "!!!!!!!!!!!!!!!!!!!"
exit 1
else
echo "no open channels found"
fi
echo "stopping lnd client"
systemctl stop lnd
sleep 4
else
echo "LND not running"
fi
# NETWORK Service
networkInstalled=$(systemctl status ${network}d.service | grep loaded -c)
if [ ${networkInstalled} -gt 0 ]; then
echo "stopping bitcoind client"
systemctl stop bitcoind
sleep 4
else
echo "Network ${network} not running"
fi
# TURN THE SWITCH
isMainnet
if [ $? -eq 1 ]; then
echo "switching from mainnet to testnet"
switchToTestnet
else
echo "switching from testnet to mainnet"
switchToMainnet
fi
echo "copying over config to admin user"
cp $NETWORK_CONFIG /home/admin/.${network}/
chown admin:admin /home/admin/.${network}/${network}.conf
cp $LND_CONFIG /home/admin/.lnd/
chown admin:admin /home/admin/.lnd/lnd.conf
# restarting network
if [ ${networkInstalled} -gt 0 ]; then
# start network
systemctl start bitcoind
echo "started ${network}d back up, giving it a 120 SECONDS to prepare"
sleep 120
# set setup info again
echo "60" > /home/admin/.setup
# run again the complete LND init procedure
./70initLND.sh
else
echo "No starting of network, because it was not running before"
fi

219
home.admin/96addTorService.sh

@ -0,0 +1,219 @@
#!/bin/bash
# Background:
# https://medium.com/@lopp/how-to-run-bitcoin-as-a-tor-hidden-service-on-ubuntu-cff52d543756
# https://bitcoin.stackexchange.com/questions/70069/how-can-i-setup-bitcoin-to-be-anonymous-with-tor
# https://github.com/lightningnetwork/lnd/blob/master/docs/configuring_tor.md
# load network
network=`cat .network`
chain="$(${network}-cli getblockchaininfo | jq -r '.chain')"
# location of TOR config
torrc="/etc/tor/torrc"
# check if TOR was already installed and is funtional
clear
echo ""
echo "*** Check if TOR service is functional ***"
torRunning=$(curl --connect-timeout 10 --socks5-hostname 127.0.0.1:9050 https://check.torproject.org | grep "Congratulations. This browser is configured to use Tor." -c)
if [ ${torRunning} -gt 0 ]; then
clear
echo "You are all good - TOR is already running."
echo ""
exit 0
else
echo "TOR not running ... proceed with switching to TOR."
echo ""
fi
# ask user if to proceed
dialog --title " WARNING " --yesno "At the moment you just can switch TOR on - YOU CANNOT SWITCH BACK. Do you want to proceed?" 8 57
response=$?
case $response in
1) exit 1;
esac
echo "*** Adding Tor Sources to sources.list ***"
echo "deb http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list
echo "OK"
echo ""
echo "*** Installing dirmngr ***"
sudo apt install dirmngr
echo ""
## lopp: gpg --keyserver keys.gnupg.net --recv 886DDD89
echo "*** Fetching GPG key ***"
gpg --keyserver keys.gnupg.net --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
echo ""
echo "*** Updating System ***"
sudo apt-get update
echo ""
echo "*** Install Tor ***"
sudo apt install tor tor-arm -y
echo ""
echo "*** Tor Config ***"
sudo rm -r -f /mnt/hdd/tor 2>/dev/null
sudo mkdir /mnt/hdd/tor
sudo mkdir /mnt/hdd/tor/sys
sudo mkdir /mnt/hdd/tor/web80
sudo mkdir /mnt/hdd/tor/lnd9735
sudo mkdir /mnt/hdd/tor/lndrpc9735
sudo chmod -R 700 /mnt/hdd/tor
sudo chown -R bitcoin:bitcoin /mnt/hdd/tor
cat > ./torrc <<EOF
### See 'man tor', or https://www.torproject.org/docs/tor-manual.html
DataDirectory /mnt/hdd/tor/sys
PidFile /mnt/hdd/tor/sys/tor.pid
SafeLogging 0
Log notice stdout
Log notice file /mnt/hdd/tor/notice.log
Log info file /mnt/hdd/tor/info.log
RunAsDaemon 1
User bitcoin
PortForwarding 1
ControlPort 9051
SocksPort 9050
CookieAuthFile /mnt/hdd/tor/sys/control_auth_cookie
CookieAuthentication 1
CookieAuthFileGroupReadable 1
# Hidden Service v2 for WEB ADMIN INTERFACE
HiddenServiceDir /mnt/hdd/tor/web80/
HiddenServicePort 80 127.0.0.1:80
# Hidden Service v2 for LND RPC
HiddenServiceDir /mnt/hdd/tor/lndrpc10009/
HiddenServicePort 80 127.0.0.1:10009
# Hidden Service v3 for LND incomming connections (just in case)
# https://trac.torproject.org/projects/tor/wiki/doc/NextGenOnions#Howtosetupyourownprop224service
HiddenServiceDir /mnt/hdd/tor/lnd9735
HiddenServiceVersion 3
HiddenServicePort 9735 127.0.0.1:9735
# NOTE: bitcoind get tor service automatically - see /mnt/hdd/bitcoin for onion key
EOF
sudo rm $torrc
sudo mv ./torrc $torrc
sudo chmod 644 $torrc
sudo chown -R bitcoin:bitcoin /var/run/tor/
echo ""
# NYX - Tor monitor tool
# https://nyx.torproject.org/#home
echo "*** Installing NYX - TOR monitoring Tool ***"
nyxInstalled=$(sudo pip list 2>/dev/null | grep 'nyx' -c)
if [ ${nyxInstalled} -eq 0 ]; then
sudo pip install nyx
else
echo "NYX already installed"
fi
echo ""
echo "*** Activating TOR system service ***"
echo "ReadWriteDirectories=-/mnt/hdd/tor" | sudo tee -a /lib/systemd/system/tor@default.service
sudo systemctl daemon-reload
sudo systemctl restart tor@default
echo ""
echo "*** Waiting for TOR to boostrap ***"
torIsBootstrapped=0
while [ ${torIsBootstrapped} -eq 0 ]
do
echo "--- Checking 1 ---"
date +%s
sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped" | tail -n 10
torIsBootstrapped=$(sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped 100" -c)
echo "torIsBootstrapped(${torIsBootstrapped})"
echo "If this takes too long --> CTRL+c, reboot and check manually"
sleep 5
done
echo "OK - Tor Bootstrap is ready"
echo ""
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
echo "Only Connect thru TOR"
echo "onlynet=onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
if [ "${network}" = "bitcoin" ]; then
echo "Adding some bitcoin onion nodes to connect to"
echo "addnode=fno4aakpl6sg6y47.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=toguvy5upyuctudx.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=ndndword5lpb7eex.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=6m2iqgnqjxh7ulyk.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=5tuxetn7tar3q5kp.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
fi
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Chain network already configured for TOR"
fi
echo "*** ${network} re-init - Waiting for Onion Address ***"
# restarting bitcoind to start with tor and generare onion.address
echo "restarting ${network}d ..."
sudo systemctl restart ${network}d
sleep 8
onionAddress=""
while [ ${#onionAddress} -eq 0 ]
do
echo "--- Checking 2 ---"
date +%s
testNetAdd=""
if [ "${chain}" = "test" ];then
testNetAdd="/testnet3"
fi
sudo cat /mnt/hdd/${network}${testNetAdd}/debug.log 2>/dev/null | grep "tor" | tail -n 10
onionAddress=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"address"' | cut -d '"' -f4)
echo "Can take up to 20min - if this takes longer --> CTRL+c, reboot and check manually"
sleep 5
done
onionPort=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"port"' | tr -dc '0-9')
echo "Your Chain Network Onion Address is: ${onionAddress}:${onionPort}"
echo ""
echo "*** Setting your Onion Address ***"
onionLND=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)
echo "Your Lightning Tor Onion Address is: ${onionLND}:9735"
echo ""
# ACTIVATE LND OVER TOR
echo "*** Putting LND behind TOR ***"
echo "Disable LND again"
sudo systemctl disable lnd
echo "Writing Public Onion Address to /run/publicip (just in case for TotHiddenServiceV3)"
echo "PUBLICIP=${onionLND}" | sudo tee /run/publicip
echo "Configure and Changing to lnd.tor.service"
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.tor.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.tor.service
sudo cp /home/admin/assets/lnd.tor.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
echo "Enable LND again"
sudo systemctl enable lnd
echo "OK"
echo ""
echo "*** Finshing Setup / REBOOT ***"
echo "OK - all should be set"
echo ""
echo "PRESS ENTER ... to REBOOT"
read key
sudo shutdown -r now
exit 0

57
home.admin/96removeTorService.sh

@ -0,0 +1,57 @@
#!/bin/bash
# load network
network=`cat .network`
# location of TOR config
torrc="/etc/tor/torrc"
echo "*** Stopping all Services ***"
sudo systemctl stop lnd
sudo systemctl stop ${network}d
sudo systemctl stop tor@default
echo ""
echo "*** Disable TOR service ***"
sudo systemctl disable tor@default
echo ""
echo "*** Changing ${network} Config ***"
sudo cat /home/bitcoin/.${network}/${network}.conf | grep -Ev 'onlynet=onion|.onion' | sudo tee /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
echo "*** Removing TOR from LND ***"
sudo systemctl disable lnd
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
sudo systemctl enable lnd
echo "OK"
echo ""
echo "*** Remove Tor ***"
sudo apt remove tor tor-arm -y
echo ""
echo "*** Remove dirmngr ***"
sudo apt remove dirmngr -y
echo ""
echo "*** Remove NYX ***"
sudo pip uninstall nyx -y
echo ""
echo "*** Remove TOR Files/Config ***"
sudo rm -r -f /mnt/hdd/tor
echo ""
echo "*** Finshing Setup / REBOOT ***"
echo "OK - all should be set"
echo ""
echo "PRESS ENTER ... to REBOOT"
read key
sudo shutdown -r now
exit 0

52
home.admin/97addMobileWalletShango.sh

@ -0,0 +1,52 @@
#!/bin/bash
# load network
network=`cat .network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# 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')
clear
echo "******************************"
echo "Connect Shango Mobile Wallet"
echo "******************************"
echo ""
echo "GETTING THE APP"
echo "At the moment this app is in closed beta testing and the source code has not been published yet."
echo "Go to http://www.shangoapp.com/insider sign up with your email (confirmation can take time)"
echo "iOS: Read https://developer.apple.com/testflight/testers/"
echo "Android: https://play.google.com/apps/testing/com.shango (from device, after confirmation email)"
echo ""
echo "*** STEP 1 ***"
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
echo "Then go to --> '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 OR' 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
clear
echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***"
echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/bitcoin/mainnet/admin.macaroon)," > qr.txt && cat ./.lnd/tls.cert >>qr.txt && qrencode -t ANSIUTF8 < qr.txt
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key
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 ""

14
home.admin/AAunlockLND.sh

@ -1,20 +1,26 @@
#!/bin/sh
# load network
network=`cat .network`
echo ""
echo "****************************************************************************"
echo "Unlock LND Wallet --> lncli unlock"
echo "Unlock LND Wallet --> lncli --chain=${network} unlock"
echo "****************************************************************************"
echo "HELP: Enter your PASSWORD C"
echo "****************************************************************************"
chain="$(bitcoin-cli -datadir=/home/bitcoin/.bitcoin getblockchaininfo | jq -r '.chain')"
while :
do
lncli unlock
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/bitcoin/${chain}net/lnd.log | grep -c unlock)
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 0 ]; then
break
fi
echo ""
echo "network(${network}) chain(${chain})"
sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log
echo "Wallet still locked - please try again or Cancel with CTRL+C"
done

77
home.admin/BBcashoutWallet.sh

@ -0,0 +1,77 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# 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 --chain=${network} 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 60 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\n$l2" 8 65 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
# TODO: check if fees are getting done right so that transaction will get processed
command="lncli --chain=${network} --conf_target 3 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 "OK. That worked :)"
echo ""

36
home.admin/BBcloseAllChannels.sh

@ -0,0 +1,36 @@
#!/bin/bash
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli --chain=${network} --force closeallchannels "
clear
echo "***********************************"
echo "Closing All Channels (EXPERIMENTAL)"
echo "***********************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
# execute command
if [ ${#command} -gt 0 ]; then
${command}
fi
echo ""
echo "OK - wait a 5 seconds"
sleep 5
echo "Your Open Channel List (to check):"
lnchannels

122
home.admin/BBconnectPeer.sh

@ -0,0 +1,122 @@
#!/bin/sh
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
# set ntwork map info
networkMap="https://lnmainnet.gaben.win"
if [ "$network" = "litecoin" ]; then
networkMap="https://lnexplorer.hcwong.me"
fi
if [ "$chain" = "test" ]; then
networkMap="https://explorer.acinq.co"
fi
# let user enter a <pubkey>@host
l1="Enter the node pubkey address with host information:"
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735"
l3="network map -> ${networkMap}"
dialog --title "Open a Connection to a Peer" \
--backtitle "Lightning ( ${network} | ${chain} )" \
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
_input=$(cat $_temp | xargs )
shred $_temp
if [ ${#_input} -eq 0 ]; then
exit 1
fi
# build command
command="lncli --chain=${network} connect ${_input}"
# info output
clear
echo "******************************"
echo "Connect to A Lightning Node"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT (might have to wait for timeout):"
win=1
info=""
# check if input is available
if [ ${#_input} -lt 10 ]; then
win=0
info="node pubkey@host info is too short"
else
gotAt=$(echo $_input | grep '@' -c)
if [ ${gotAt} -eq 0 ]; then
win=0
info="format is not pubkey@host - @ is missing"
fi
fi
# execute command
sleep 2
result="$info"
if [ ${win} -eq 1 ]; then
result=$($command 2>$_error)
fi
# on no result
if [ ${#result} -eq 0 ]; then
# basic error
win=0
info="No return value. Error not known."
# try to get error output
result=`cat ${_error}`
echo "$result"
# basic cli error
cliError=$(echo "${result}" | grep "[lncli]" -c )
if [ ${cliError} -gt 0 ]; then
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli."
fi
else
# when result is available
echo "$result"
# check if the node is now in peer list
pubkey=$(echo $_input | cut -d '@' -f1)
isPeer=$(lncli --chain=${network} listpeers 2>/dev/null| grep "${pubkey}" -c)
if [ ${isPeer} -eq 0 ]; then
# basic error message
win=0
info="Was not able to establish connection to node."
# TODO: try to find out more details from cli output
else
info="Perfect - a connection to that node got established :)"
fi
fi
# output info
echo ""
if [ ${win} -eq 1 ]; then
echo "******************************"
echo "WIN"
echo "******************************"
echo "${info}"
echo ""
echo "Whats next? --> Open a channel with that node."
else
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${info}"
fi
echo ""

91
home.admin/BBcreateInvoice.sh

@ -0,0 +1,91 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} 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} 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
# let user enter the invoice
l1="Enter the AMOUNT IN SATOSHI of the invoice:"
l2="1 ${network} = 100 000 000 SAT"
dialog --title "Pay thru Lightning Network" \
--inputbox "$l1\n$l2" 9 50 2>$_temp
amount=$(cat $_temp | xargs | tr -dc '0-9')
shred $_temp
if [ ${#amount} -eq 0 ]; then
echo "FAIL - not a valid input (${amount})"
exit 1
fi
# build command
command="lncli --chain=${network} addinvoice ${amount}"
# info output
clear
echo "******************************"
echo "Create Invoice / Payment Request"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
sleep 2
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "******************************"
echo "WIN"
echo "******************************"
echo "${result}"
echo ""
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4)
echo "Give this Invoice/PaymentRequest to someone to pay it:"
echo ""
echo ${payReq}
echo ""
echo "You can use 'lncli --chain=${network} lookupinvoice ${rhash}' to check the payment. "
# TODO: Offer to go into monitor for incommin payment loop.
fi
echo ""

63
home.admin/BBfundWallet.sh

@ -0,0 +1,63 @@
#!/bin/bash
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli --chain=${network} newaddress np2wkh"
clear
echo "******************************"
echo "Fund your Blockchain Wallet"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
# 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"
# get address from result
address=$( echo "$result" | grep "address" | cut -d '"' -f4)
# prepare coin info
coininfo="REAL Bitcoin"
if [ "$network" = "litecoin" ]; then
coininfo="REAL Litecoin"
fi
if [ "$chain" = "test" ]; then
coininfo="TESTNET Bitcoin"
fi
# output info
echo ""
echo "******************************"
echo "TODO"
echo "******************************"
echo "Send ${coininfo} to address --> ${address}"
if [ "$chain" = "test" ]; then
echo "get some testnet coins from https://testnet.manu.backend.hamburg/faucet"
fi
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or info on LCD to check if funds have arrived."
echo ""

136
home.admin/BBopenChannel.sh

@ -0,0 +1,136 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
echo "Wait until chain is sync with LND and try again."
echo ""
exit 1
fi
# check available funding
confirmedBalance=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${confirmedBalance} -eq 0 ]; then
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet."
echo "Please fund your on-chain wallet first and wait until confirmed."
echo ""
exit 1
fi
# check number of connected peers
numConnectedPeers=$(lncli --chain=${network} listpeers | grep pub_key -c)
if [ ${numConnectedPeers} -eq 0 ]; then
echo "FAIL - no peers connected on lightning network"
echo "You can only open channels to peer nodes to connected to first."
echo "Use CONNECT peer option in main menu first."
echo ""
exit 1
fi
# let user pick a peer to open a channels with
OPTIONS=()
while IFS= read -r grepLine
do
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
#echo "grepLine(${pubKey})"
OPTIONS+=(${pubKey} "")
done < <(lncli --chain=${network} listpeers | grep pub_key)
TITLE="Open (Payment) Channel"
MENU="\nChoose a peer you connected to, to open the channel with: \n "
pubKey=$(dialog --clear \
--title "$TITLE" \
--menu "$MENU" \
14 73 5 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
if [ ${#pubKey} -eq 0 ]; then
echo "Selected CANCEL"
echo ""
exit 1
fi
# find out what is the minimum amount
# TODO find a better way - also consider dust and channel reserve
# details see here: https://github.com/btcontract/lnwallet/issues/52
minSat=20000
if [ "${network}" = "bitcoin" ]; then
minSat=250000
fi
_error="./.error.out"
lncli --chain=${network} openchannel ${CHOICE} 1 0 2>$_error
error=`cat ${_error}`
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
minSat=$(echo "${error}" | tr -dc '0-9')
fi
# let user enter a amount
l1="Amount in SATOSHI to fund this channel:"
l2="min required : ${minSat}"
l3="max available : ${confirmedBalance}"
dialog --title "Funding of Channel" \
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
amount=$(cat $_temp | xargs | tr -dc '0-9')
shred $_temp
if [ ${#amount} -eq 0 ]; then
echo "FAIL - not a valid input (${amount})"
exit 1
fi
# build command
command="lncli --chain=${network} openchannel ${pubKey} ${amount} 0"
# info output
clear
echo "******************************"
echo "Open Channel"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "******************************"
echo "WIN"
echo "******************************"
echo "${result}"
echo ""
echo "Whats next? --> You need to wait 6 confirmations, for the channel to be ready."
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
echo "https://blockexplorer.com/tx/${fundingTX}"
else
echo "https://testnet.blockexplorer.com/tx/${fundingTX}"
fi
fi
if [ "${network}" = "litecoin" ]; then
echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/"
fi
fi
echo ""

106
home.admin/BBpayInvoice.sh

@ -0,0 +1,106 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} 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} 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
paymentRequestStart="???"
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
paymentRequestStart="lnbc"
else
paymentRequestStart="lntb"
fi
elif [ "${network}" = "litecoin" ]; then
paymentRequestStart="lnltc"
fi
testSite="???"
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
testSite="https://satoshis.place"
else
testSite="https://testnet.satoshis.place"
fi
elif [ "${network}" = "litecoin" ]; then
testSite="https://millionlitecoinhomepage.net"
fi
# let user enter the invoice
l1="Copy the LightningInvoice/PaymentRequest into here:"
l2="Its a long string starting with '${paymentRequestStart}'"
l3="To try it out go to: ${testSite}"
dialog --title "Pay thru Lightning Network" \
--inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp
invoice=$(cat $_temp | xargs)
shred $_temp
if [ ${#invoice} -eq 0 ]; then
echo "FAIL - not a valid input (${invoice})"
exit 1
fi
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq
# build command
command="lncli --chain=${network} sendpayment --pay_req=${invoice}"
# info output
clear
echo "******************************"
echo "Pay Invoice / Payment Request"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT (may wait in case of timeout):"
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "${result}"
echo "******************************"
echo "WIN"
echo "******************************"
echo "It worked :) - check out the service you were paying."
fi
echo ""

27
home.admin/XXcleanHDD.sh

@ -1,22 +1,27 @@
echo ""
# load network
network=`cat .network`
echo "!!!! This will DELETE your personal data from the HDD !!!!"
echo "--> use the HDD with just blockchain in a fresh setup"
echo "Press ENTER to continue - CTRL+c to CANCEL"
read key
sudo dphys-swapfile swapoff
sudo systemctl stop bitcoind.service
sudo systemctl stop ${network}d.service
sudo systemctl stop lnd.service
sudo rm -f -r /mnt/hdd/lnd
sudo rm -f /mnt/hdd/swapfile
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf
sudo rm -f /mnt/hdd/bitcoin/bitcoin.pid
sudo rm -f /mnt/hdd/bitcoin/*.dat
sudo rm -f /mnt/hdd/bitcoin/*.log
sudo rm -f /mnt/hdd/bitcoin/bitcoin.conf
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.dat
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.log
sudo rm -f /mnt/hdd/bitcoin/testnet3/.lock
sudo rm -f -r /mnt/hdd/bitcoin/database
sudo chown admin:admin -R /mnt/hdd/bitcoin
sudo rm -f /mnt/hdd/${network}/${network}.conf
sudo rm -f /mnt/hdd/${network}/${network}.pid
sudo rm -f /mnt/hdd/${network}/*.dat
sudo rm -f /mnt/hdd/${network}/*.log
sudo rm -f /mnt/hdd/${network}/*.pid
sudo rm -f /mnt/hdd/${network}/testnet3/*.dat
sudo rm -f /mnt/hdd/${network}/testnet3/*.log
sudo rm -f /mnt/hdd/${network}/testnet3/.lock
sudo rm -f -r /mnt/hdd/${network}/database
sudo rm -f -r /mnt/hdd/tor
sudo chown admin:admin -R /mnt/hdd/${network}
echo "1" > /home/admin/.setup
echo "OK - the HDD is now clean"

171
home.admin/XXscreenMonitor.sh

@ -0,0 +1,171 @@
#!/bin/sh
echo ""
# *** BITCOIN ***
bitcoinList="" # url to list with other sources
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16"
bitcoinSize=100
# *** LITECOIN ***
litecoinList="" # url to list with other sources
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29"
litecoinSize=19000000
# load network
network=`cat .network`
# settings based on network
list=$bitcoinList
url=$bitcoinUrl
size=$bitcoinSize
if [ "$network" = "litecoin" ]; then
list=$litecoinList
url=$litecoinUrl
size=$litecoinSize
fi
# screen background monitoring settings
name="Download"
targetDir="/mnt/hdd/download/"
targetSize=$size
maxTimeoutLoops=100
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}"
# starting session if needed
echo "checking if ${name} has a running screen session"
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
echo "isRunning(${isRunning})"
if [ ${isRunning} -eq 0 ]; then
echo "Starting screen session"
screen -S ${name} -dm ${command}
else
echo "Continue screen session"
fi
sleep 3
# monitor session
screenDump="... started ..."
actualSize=0
timeout=1
timeoutInfo="-"
while :
do
# check if session is still running
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
if [ ${isRunning} -eq 0 ]; then
timeout=0
echo "OK - session finished"
break
fi
# calculate progress and write it to file for LCD to read
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
if [ ${#actualSize} -eq 0 ]; then
freshSize=0
fi
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
echo $progress > '.${name}.progress'
# detect if since last loop any progress occured
if [ ${actualSize} -eq ${freshSize} ]; then
timeoutInfo="${timeout}/${maxTimeoutLoops}"
timeout=$(( $timeout + 1 ))
else
timeout=1
timeoutInfo="no timeout detected"
fi
actualSize=$freshSize
# detect if mx timeout loop limit is reached
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then
echo "FAIL - download hit timeout"
break
fi
# display info screen
clear
echo "****************************************"
echo "Monitoring Screen Session: ${name}"
echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
echo "Timeout: ${timeoutInfo}"
echo "Press key x to abort this process"
echo "****************************************"
screen -S ${name} -X hardcopy .${name}.out
newScreenDump=$(cat .Download.out | grep . | tail -15)
if [ ${#newScreenDump} -gt 0 ]; then
screenDump=$newScreenDump
fi
echo $screenDump
# wait 2 seconds for key input
read -n 1 -t 2 keyPressed
# check if user wants to abort session
if [ "${keyPressed}" = "x" ]; then
echo ""
echo "Aborting ${name}"
break
fi
done
# clean up
rm -f .${name}.out
rm -f .${name}.progress
# quit session if still running
if [ ${isRunning} -eq 1 ]; then
# get the PID of screen session
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs)
echo "killing screen session PID(${sessionPID})"
# kill all child processes of screen sceesion
pkill -P ${sessionPID}
echo "proccesses klilled"
sleep 3
# tell the screen session to quit and wait a bit
screen -S ${name} -X quit 1>/dev/null
sleep 3
echo "cleaning screen"
screen -wipe 1>/dev/null
sleep 3
fi
# the path wget will download to
targetPath=$(echo ${url} | cut -d '@' -f2)
echo "path to downloaded data is ${targetPath}"
# calculate progress and write it to file for LCD to read
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
if [ ${#actualSize} -eq 0 ]; then
finalSize=0
fi
echo "final size is ${finalSize} of targeted size ${targetSize}"
# check result
if [ ${finalSize} -lt ${targetSize} ]; then
# Download failed
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
response=$?
case $response in
1) sudo rm -rf ${targetDir}${targetPath} ;;
esac
./00mainMenu.sh
exit 1;
else
# Download worked
echo "*** Moving Files ***"
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network}
echo "OK"
# continue setup
./60finishHDD.sh
fi

17
home.admin/XXupdateScripts.sh

@ -0,0 +1,17 @@
#!/bin/bash
echo ""
echo "*** UPDATING SHELL SCRIPTS FROM GITHUB ***"
echo "justincase, not the final upadte mechanism"
echo "******************************************"
cd /home/admin/raspiblitz
git pull
cd ..
rm *.sh
rm -r assets
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.sh /home/admin
sudo -u admin chmod +x *.sh
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
echo "******************************************"
echo "OK - shell scripts and assests are up to date"
echo "Reboot recommended"
echo ""

12
home.admin/assets/bitcoin.conf

@ -1,7 +1,7 @@
# bitcoind configuration
# remove the following line to enable Bitcoin mainnet
testnet=1
# mainnet/testnet - to switch just comment/uncomment
#testnet=1
# Bitcoind options
server=1
@ -11,9 +11,9 @@ disablewallet=1
# Connection settings
rpcuser=raspibolt
# LINE15 -insert-> rpcpassword=[PASSWORDB]
zmqpubrawblock=tcp://127.0.0.1:29000
zmqpubrawtx=tcp://127.0.0.1:29000
rpcpassword=passwordB
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# Raspberry Pi optimizations
dbcache=100
@ -21,3 +21,5 @@ maxorphantx=10
maxmempool=50
maxconnections=40
maxuploadtarget=5000
datadir=/home/bitcoin/.bitcoin

23
home.admin/assets/bitcoind.service

@ -0,0 +1,23 @@
# RaspiBlitz: systemd unit for bitcoind
[Unit]
Description=Bitcoin daemon
Wants=getpublicip.service
After=getpublicip.service
# for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n
[Service]
User=bitcoin
Group=bitcoin
Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid
KillMode=process
Restart=always
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target

20
home.admin/assets/getpublicip.service

@ -0,0 +1,20 @@
# RaspiBolt LND Mainnet: systemd unit for getpublicip.sh script
# /etc/systemd/system/getpublicip.service
[Unit]
Description=getpublicip.sh: get public ip address from ipinfo.io
After=network.target
[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/getpublicip.sh
ExecStartPost=/bin/sleep 5
Restart=always
RestartSec=600
TimeoutSec=10
[Install]
WantedBy=multi-user.target

16
home.admin/assets/getpublicip.sh

@ -0,0 +1,16 @@
#!/bin/bash
echo 'getpublicip.sh started, writing public IP address every 10 minutes into /run/publicip'
while [ 0 ];
do
# check if TOR is running
torExists=$(sudo ls /mnt/hdd/tor/lnd9735/hostname 2>/dev/null | grep hostname -c)
if [ ${torExists} -eq 0 ]; then
# get and set public IP
printf "PUBLICIP=$(curl -vv ipinfo.io/ip 2> /run/publicip.log)\n" > /run/publicip;
else
# set onion address
printf "PUBLICIP=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)\n" > /run/publicip;
fi
sleep 600
done;

29
home.admin/assets/litecoin.conf

@ -0,0 +1,29 @@
# litecoind configuration
# mainnet/testnet - to switch just comment/uncomment
#testnet=1
# Bitcoind options
server=1
daemon=1
txindex=1
disablewallet=1
# Connection settings
rpcuser=raspibolt
rpcpassword=passwordB
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# Raspberry Pi optimizations
dbcache=100
maxorphantx=10
maxmempool=50
maxconnections=40
maxuploadtarget=5000
# litecoin specials
discardfee=0.00000001
mintxfee=0.00000001
minrelaytxfee=0.00000001
datadir=/home/bitcoin/.litecoin

20
home.admin/assets/litecoind.service

@ -0,0 +1,20 @@
[Unit]
Description=Bitcoin daemon
Wants=getpublicip.service
After=getpublicip.service
# for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n
[Service]
User=bitcoin
Group=bitcoin
Type=simple
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf
KillMode=process
Restart=always
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target

31
home.admin/assets/lnd.bitcoin.conf

@ -0,0 +1,31 @@
# lnd configuration
[Application Options]
debuglevel=info
maxpendingchannels=5
alias=raspiblitz
color=#68F442
# RPC open to all connections on Port 10009
rpclisten=0.0.0.0:10009
# Domain, could use https://freedns.afraid.org
#tlsextradomain=lightning.yourhost.com
[Bitcoin]
bitcoin.active=1
# enable either testnet or mainnet
#bitcoin.testnet=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
bitcoind.rpchost=127.0.0.1
bitcoind.rpcuser=raspibolt
bitcoind.rpcpass=passwordB
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
[autopilot]
autopilot.active=1
autopilot.maxchannels=5
autopilot.allocation=0.6

22
home.admin/assets/lnd.conf

@ -1,22 +0,0 @@
# lnd configuration
[Application Options]
debuglevel=info
debughtlc=true
maxpendingchannels=5
# LINE7 -insert-> alias=[ALIAS]
color=#68F442
[Bitcoin]
bitcoin.active=1
# enable either testnet or mainnet
bitcoin.testnet=1
#bitcoin.mainnet=1
bitcoin.node=bitcoind
[autopilot]
autopilot.active=1
autopilot.maxchannels=5
autopilot.allocation=0.6

27
home.admin/assets/lnd.litecoin.conf

@ -0,0 +1,27 @@
# lnd configuration
[Application Options]
debuglevel=info
maxpendingchannels=5
alias=raspiblitz
color=#68F442
# RPC open to all connections on Port 10009
rpclisten=0.0.0.0:10009
# Domain, could use https://freedns.afraid.org
#tlsextradomain=lightning.yourhost.com
[Litecoin]
litecoin.active=1
litecoin.mainnet=1
litecoin.node=litecoind
litecoind.rpchost=127.0.0.1
litecoind.rpcuser=raspibolt
litecoind.rpcpass=passwordB
litecoind.zmqpubrawblock=tcp://127.0.0.1:28332
litecoind.zmqpubrawtx=tcp://127.0.0.1:28333
[autopilot]
autopilot.active=1
autopilot.maxchannels=5
autopilot.allocation=0.6

27
home.admin/assets/lnd.service

@ -0,0 +1,27 @@
# RaspiBlitz: systemd unit for lnd
[Unit]
Description=LND Lightning Daemon
Wants=bitcoind.service
After=bitcoind.service
# for use with sendmail alert
#OnFailure=systemd-sendmail@%n
[Service]
# get var PUBIP from file
EnvironmentFile=/run/publicip
ExecStart=/usr/local/bin/lnd --externalip=${PUBLICIP}
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin
Group=bitcoin
LimitNOFILE=128000
Type=simple
KillMode=process
TimeoutSec=180
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target

32
home.admin/assets/lnd.tor.service

@ -0,0 +1,32 @@
# RaspiBlitz: systemd unit for lnd
[Unit]
Description=LND Lightning Daemon
Wants=bitcoind.service
After=bitcoind.service
# for use with sendmail alert
#OnFailure=systemd-sendmail@%n
[Service]
# get var PUBIP from file
EnvironmentFile=/run/publicip
# TOR Hidden Service v2
ExecStart=/usr/local/bin/lnd --tor.active --tor.v2 --listen=127.0.0.1:9735
# TOR Hidden Service v3
# ExecStart=/usr/local/bin/lnd --tor.active --tor.v3 --externalip=${PUBLICIP} --listen=127.0.0.1:9735
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin
Group=bitcoin
LimitNOFILE=128000
Type=simple
KillMode=process
TimeoutSec=180
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target

4
home.admin/assets/raspiblitz-hdd-2018-07-16.torrent → home.admin/assets/raspiblitz-bitcoin-2018-07-16.torrent

File diff suppressed because one or more lines are too long

801
home.admin/assets/raspiblitz-litecoin-2018-07-29.torrent

File diff suppressed because one or more lines are too long

BIN
pictures/bonus-lnbalance.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
pictures/bonus-lnchannels.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

BIN
pictures/shango1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
pictures/ssh0-welcome.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

BIN
pictures/ssh0-welcome2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
pictures/ssh5-blockchain.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

BIN
pictures/ssh5-blockchain2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
pictures/ssh9e-mainmenu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
pictures/ssh9e-mainmenu1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
pictures/ssh9e-mainmenu2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
pictures/tor1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

12
shoppinglist_fr.md

@ -0,0 +1,12 @@
## Hardware Needed (Amazon.fr Shopping List)
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.fr:*
* RaspBerry Pi 3 (38,00 EUR) https://www.amazon.fr/dp/B07BDR5PDW
* Micro SD-Card 16GB (9,53 EUR) https://www.amazon.fr/dp/B073K14CVB/
* Power (8,99 EUR) https://www.amazon.fr/dp/B01566WOAG
* 1TB Hard Drive (46,80 EUR) https://www.amazon.fr/dp/B07997KKSK
* Case (7,41 EUR) https://www.amazon.fr/dp/B0173GQF70/
* LCD-Display (16,99 EUR) https://www.amazon.fr/dp/B01N2N86HB/
**Total Price: 127,72 EUR**

9
shoppinglist_uk.md

@ -1,3 +1,8 @@
Your are from the UK? Your help is needed!
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.co.uk:*
It would be great if you can create a shopping list for amazon UK for the RaspiBlitz and test if everything is running with the hardware setup. Thx.
* RaspBerry Pi 3 https://www.amazon.co.uk/Raspberry-Pi-Model-64-Bit-Processor/dp/B07BDR5PDW
* Micro SD-Card 16GB https://www.amazon.co.uk/Kingston-SDC10G2-16GB-microSDHC-Included/dp/B0162YQEIE
* Power https://www.amazon.co.uk/iTrunk-Raspberry-Model-Supply-Charger/dp/B01MFFSPHE
* 1TB Hard Drive https://www.amazon.co.uk/Toshiba-Canvio-Basics-Portable-External/dp/B00KWHJY7Q
* Case https://www.amazon.co.uk/SB-Components-Transparent-Case-Raspberry/dp/B0173GQF8Y
* LCD-Display https://www.amazon.co.uk/ELEGOO-480x320-Raspberry-Monitor-Interface/dp/B01MRQTMTD

4
shoppinglist_usa.md

@ -4,9 +4,9 @@
* RaspBerry Pi 3 ($41.00 USD) http://a.co/ahl7RIp
* Micro SD-Card 16GB ($6.75 USD) http://a.co/6R49HZz
* Power ($7.89 USD) http://a.co/gGOtk30
* Power ($7.99 USD) https://www.amazon.com/Yuconn-Switch-Charger-Adapter-Raspberry/dp/B071YC2T9S
* 1TB Hard Drive ($49.99 USD) http://a.co/eUgVfLd
* Case ($7.99 USD) http://a.co/1774Hwl
* LCD-Display ($19.99 USD) http://a.co/65p2wu6
**Total Price: $145.85 USD**
**Total Price: $145.95 USD**

Loading…
Cancel
Save