Bitcoin Cash Node, Raspberry Pi with LCD Display, Tor Network Enabled
See the HARDWARE tab for parts list and assembly/build information
Latest Update 11th November 2017
Step (1) Preparing the Pi
Because all the preparation steps are the same for all nodes here, I have made a beginner friendly guide with images, step-by-step. "Getting started" Link opens a new window
Getting Started
Then continue below...
Latest Update 11th November 2017
Step (1) Preparing the Pi
Because all the preparation steps are the same for all nodes here, I have made a beginner friendly guide with images, step-by-step. "Getting started" Link opens a new window
Getting Started
Then continue below...
Step (2) Enabling WiFi
Wifi is available once the Pi is rebooted. Either reboot now using
sudo reboot and remove the ethernet cable. Or continue, and reboot later as it is required after the next step. |
With the Pi turned on, booted and you logged in with SSH we can start the setup.
First WiFi network connections are stored: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf Go to the bottom of the file and add the following text: network={ ssid="YOUR WIFI ROUTER NAME" psk="YOUR WIFI ROUTER PASSWORD" } **Note: Enter details between the quotes, leave the "" in save and exit using ctrl+O Then 'enter' ctrl+X |
Step (3) Expand the file system, (making full use of the SD card) and changing the Password.
|
enter:
sudo raspi-config The default password for obvious security reasons should be changed. That is done in this menu. select "1 change user password", and follow the on-screen instructions. This will be the new password when using PUTTY to SSH into the Pi. Because we installed a 2GB image onto the card, the Pi may think that the card is only 2GB in size. So we tell it to expand the file-system (returns it to it's full size allowed): select "7 advanced options" select "A1 expand filesystem" select 'finish' system will reboot, (remove the ethernet cable if you didn't at the previous step). And log back in with SSH and PUTTY once reboot is complete. |
Step (4) Updates
The image we downloaded may have an update or two since they released it:
sudo apt-get update
sudo apt-get upgrade
select 'y' to accept the storage requirement.
The image we downloaded may have an update or two since they released it:
sudo apt-get update
sudo apt-get upgrade
select 'y' to accept the storage requirement.
Step (5) Installing the screen
sudo wget http://www.spotpear.com/download/diver24-5/LCD-show-170309.tar.gz
sudo tar xvf LCD-show-170309.tar.gz
cd LCD-show/
Then pick and type one command from the list below depending on your screen size/resolution.
If your display is the Raspberry Pi 2.4inch, 2.8inch or Raspberry Pi 3.2inch
sudo ./LCD32-show
If your display is the Raspberry Pi 3.5inch
sudo ./LCD35-show
If your display is the Raspberry Pi 3.5 inch HDMI LCD
LCD35-HDMI-480x320-show
OR
LCD35-HDMI-800x480-show
If your display is the Raspberry Pi 4inch
sudo ./LCD4-show
If your display is the Raspberry Pi 4inch HDMI(800x480)
sudo ./LCD4-800x480-show
If your display is the Raspberry Pi 4.3inch
sudo ./LCD43-show
If your display is the Raspberry Pi 5inch
sudo ./LCD5-show
If your display is the Raspberry Pi 7inch (800x480)
sudo ./LCD7-800x480-show
If your display is the Raspberry Pi 7inch (1024x600)
sudo ./LCD7-1024x600-show
If your display is the Raspberry Pi 10.1inch (1024x600)
sudo ./LCD101-1024x600-show
This command takes some time ("LCD configure 0" displayed for a while) and it reboots when it is complete but reboots in the background so it confuses PUTTY. The reboot causes PUTTY to crash and is normal. I recommend waiting until the activity indicator on the pi has been lazy for a minute or two (an indication it has finished) then press enter. PUTTY will bring up an error and close. (This has been updated and did this twice on a rebuild) This is fine. Log back in with SSH and PUTTY
sudo wget http://www.spotpear.com/download/diver24-5/LCD-show-170309.tar.gz
sudo tar xvf LCD-show-170309.tar.gz
cd LCD-show/
Then pick and type one command from the list below depending on your screen size/resolution.
If your display is the Raspberry Pi 2.4inch, 2.8inch or Raspberry Pi 3.2inch
sudo ./LCD32-show
If your display is the Raspberry Pi 3.5inch
sudo ./LCD35-show
If your display is the Raspberry Pi 3.5 inch HDMI LCD
LCD35-HDMI-480x320-show
OR
LCD35-HDMI-800x480-show
If your display is the Raspberry Pi 4inch
sudo ./LCD4-show
If your display is the Raspberry Pi 4inch HDMI(800x480)
sudo ./LCD4-800x480-show
If your display is the Raspberry Pi 4.3inch
sudo ./LCD43-show
If your display is the Raspberry Pi 5inch
sudo ./LCD5-show
If your display is the Raspberry Pi 7inch (800x480)
sudo ./LCD7-800x480-show
If your display is the Raspberry Pi 7inch (1024x600)
sudo ./LCD7-1024x600-show
If your display is the Raspberry Pi 10.1inch (1024x600)
sudo ./LCD101-1024x600-show
This command takes some time ("LCD configure 0" displayed for a while) and it reboots when it is complete but reboots in the background so it confuses PUTTY. The reboot causes PUTTY to crash and is normal. I recommend waiting until the activity indicator on the pi has been lazy for a minute or two (an indication it has finished) then press enter. PUTTY will bring up an error and close. (This has been updated and did this twice on a rebuild) This is fine. Log back in with SSH and PUTTY
And at the bottom you will find
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
Adding a # before a line make the Pi ignore it and is called a comment.
Comment out the dtoverlay=ads7846...line by adding a #.
The line that we want active is the dtoverlay=waveshare35a
The rotation value should be changed here from now on too, by adding :rotate=0 as in the image above
Choose your rotation value. 270 is the HDMI port at the top. Use 0,90,180,270 as needed.
It should look like this after, (depending on rotation preferences)
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a:rotate=270
#dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
then
sudo reboot
And you will have your display working.
(If rotation is wrong, edit the config.txt again and change rotate=<figure>. Reboot required for changes to take affect)
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
Adding a # before a line make the Pi ignore it and is called a comment.
Comment out the dtoverlay=ads7846...line by adding a #.
The line that we want active is the dtoverlay=waveshare35a
The rotation value should be changed here from now on too, by adding :rotate=0 as in the image above
Choose your rotation value. 270 is the HDMI port at the top. Use 0,90,180,270 as needed.
It should look like this after, (depending on rotation preferences)
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a:rotate=270
#dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
then
sudo reboot
And you will have your display working.
(If rotation is wrong, edit the config.txt again and change rotate=<figure>. Reboot required for changes to take affect)
Step (6) Adding the GUI (the desktop)
A very easy copy/paste step:
sudo apt-get install --no-install-recommends xserver-xorg
sudo apt-get install --no-install-recommends xinit xserver-xorg-video-fbdev
sudo apt-get install lxde-core lxappearance
sudo apt-get install lightdm
sudo apt-get install --no-install-recommends matchbox chromium-browser
don't reboot just yet...
A very easy copy/paste step:
sudo apt-get install --no-install-recommends xserver-xorg
sudo apt-get install --no-install-recommends xinit xserver-xorg-video-fbdev
sudo apt-get install lxde-core lxappearance
sudo apt-get install lightdm
sudo apt-get install --no-install-recommends matchbox chromium-browser
don't reboot just yet...
Step (7) Force the output to the LCD, not HDMI
sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
Step(8) Disable screensaver, auto-boot chrome
Now it's booted tot he GUI you can disbale the screen saver with a USB mouse. Open the menu in the bottom left, preferences, screensaver. and select disable from the drop down list.
Then the via SSH
The file below contains setting for the GUI
sudo nano ~/.config/lxsession/LXDE/autostart
Now it's booted tot he GUI you can disbale the screen saver with a USB mouse. Open the menu in the bottom left, preferences, screensaver. and select disable from the drop down list.
Then the via SSH
The file below contains setting for the GUI
sudo nano ~/.config/lxsession/LXDE/autostart
Change it to look like
@lxpanel --profile LXDE @pcmanfm --desktop --profile LXDE @xscreensaver -no-splash @chromium-browser --kiosk --incognito http://www.realtimebitcoin.info/ **Note, dont add the @bitcoind line yet, we'll do that later. This screenshot was from my running node so is a step ahead** Any web address can be used above, I suggest looking at http://www.bitcoinlinks.net/blockchain-tools for their list of bitcoin specific pages. From worldwide node distribution to price widgets, transaction data... |
Reboot the pi to autostart chrome at the chosen page. Either shutdown through the GUI or SSH as usual with sudo reboot
We will come back to this file later to tell it to auto boot the node.
We will come back to this file later to tell it to auto boot the node.
Step (9) Moving everything to the USB drive
People have been making projects (not just nodes) on the raspberry pi for some time. A common failure point seems to be the SD cards. The constant read/write process 24/7 drastically shorten their life. We can reduce this by moving the entire file-system to the USB drive, and where possible using traditional platter HDDs. Check out the 'HARDWARE' section for cheap solutions available to the Raspberry Pi.
For moving the file-system we need the "git" repository
sudo apt-get install git
Insert the USB drive if you havn't already, then check it is mounted to the Pi.
sudo lsblk
99% of the time it will be mounted as /dev/sda with a partition called sda1. However if it has found sda1 it won't let us continue until it is unmounted. (It would be telling it to make changes to the filesystem whilst it's in use. It won't let us and doesn't like it). So we unmount with
umount /dev/sda1
We need to delete this partition to stop raspbian from automatically using the drive on boot, at this point. The helper in the next step will automatically create a new partition to do it's job of moving the files.
sudo fdisk /dev/sda
d
(deletes old partition)
w
(writes and commits the changes)
Now it's compatible with the helper script.
The folks at Adafruit have made a very useful helper to reduce the amount of commands you need. These next three lines create a new partition and move the entire file system onto the USB drive. It does warn you that any data currently written to /sda will be overwritten. If you are an advanced user and have called the partition something other than /sda, this is where it should be changed.
git clone https://github.com/adafruit/Adafruit-Pi-ExternalRoot-Helper.git
cd Adafruit-Pi-ExternalRoot-Helper
sudo ./adafruit-pi-externalroot-helper -d /dev/sda
It will ask you to check that you are writing to the correct partition, select y when you are sure. When I do this step it takes a little under 10mins. Please be patient.
People have been making projects (not just nodes) on the raspberry pi for some time. A common failure point seems to be the SD cards. The constant read/write process 24/7 drastically shorten their life. We can reduce this by moving the entire file-system to the USB drive, and where possible using traditional platter HDDs. Check out the 'HARDWARE' section for cheap solutions available to the Raspberry Pi.
For moving the file-system we need the "git" repository
sudo apt-get install git
Insert the USB drive if you havn't already, then check it is mounted to the Pi.
sudo lsblk
99% of the time it will be mounted as /dev/sda with a partition called sda1. However if it has found sda1 it won't let us continue until it is unmounted. (It would be telling it to make changes to the filesystem whilst it's in use. It won't let us and doesn't like it). So we unmount with
umount /dev/sda1
We need to delete this partition to stop raspbian from automatically using the drive on boot, at this point. The helper in the next step will automatically create a new partition to do it's job of moving the files.
sudo fdisk /dev/sda
d
(deletes old partition)
w
(writes and commits the changes)
Now it's compatible with the helper script.
The folks at Adafruit have made a very useful helper to reduce the amount of commands you need. These next three lines create a new partition and move the entire file system onto the USB drive. It does warn you that any data currently written to /sda will be overwritten. If you are an advanced user and have called the partition something other than /sda, this is where it should be changed.
git clone https://github.com/adafruit/Adafruit-Pi-ExternalRoot-Helper.git
cd Adafruit-Pi-ExternalRoot-Helper
sudo ./adafruit-pi-externalroot-helper -d /dev/sda
It will ask you to check that you are writing to the correct partition, select y when you are sure. When I do this step it takes a little under 10mins. Please be patient.
This is our drives labels and addresses. We need to check that the PARTUUID long number (that's the USB), is entered into
sudo nano /boot/cmdline.txt |
So everything has been copied over and the drive configured. We just need to change the boot file so it starts from the USB drive from now on. The helper untility should have done this automatically. But recently this has not been the case. Do this just to check, it's simple and is just a copy/paste action. sudo blkid -o export /dev/sda1 The numbers will be different but it brings up something like the image on the left. |
Enter:
sudo nano /boot/cmdline.txt And ensure that the helper has changed root=PARTUUID= to match the one that was listed to you above. Yours will be different to mine. Then Save and exit using ctrl+o then ctrl+x. Do another reboot with sudo reboot and when the Pi starts this time your USB activity light will blink like crazy, showing it's now getting it's data from there. |
Step (10) Installing Bitcoin Cash
We start with making a directory to hold the blockchain:
mkdir ~/bitcoinData then enlarge something called a swapfile so the blockchain loads quicker (like artifictialy boosting available memory) sudo nano /etc/dphys-swapfile And change the default size of 100(MB, to 1000 as shown to the left save, exit, ctrl+o ctrl+x |
Then, to build the new swap file...
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
This one liner will download and install the packages we will need for Bitcoin Cash:
sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev -y
make a directory to download the files
mkdir ~/bin
cd ~/bin
then download Bitcoin Cash
git clone -b BitcoinCash https://github.com/BitcoinUnlimited/BitcoinUnlimited.git
then navigate to our bitcoin folder to install it all
cd BitcoinUnlimited
./autogen.sh
./configure --enable-upnp-default --disable-wallet
make
**Note** 'make' took around 2 hours on my last build. It has been recommended to use 'make -j2' as the command as it is quicker. The -j2 flag tells the pi how many cores of it's processor to use in that instruction. The pi has 4 cores available but it is not recommended to use them all for a task. If you encounter errors just stick with 'make'.
Then
sudo make install
then we configure the node.
sudo nano /home/pi/bitcoinData/bitcoin.conf
and add to it
rpcuser=<yourbitcoinrpcuser>
rpcpassword=<yourpasswordhere>
**make up some values here remove the <>
save, exit, ctrl+o ctrl+x
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
This one liner will download and install the packages we will need for Bitcoin Cash:
sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev -y
make a directory to download the files
mkdir ~/bin
cd ~/bin
then download Bitcoin Cash
git clone -b BitcoinCash https://github.com/BitcoinUnlimited/BitcoinUnlimited.git
then navigate to our bitcoin folder to install it all
cd BitcoinUnlimited
./autogen.sh
./configure --enable-upnp-default --disable-wallet
make
**Note** 'make' took around 2 hours on my last build. It has been recommended to use 'make -j2' as the command as it is quicker. The -j2 flag tells the pi how many cores of it's processor to use in that instruction. The pi has 4 cores available but it is not recommended to use them all for a task. If you encounter errors just stick with 'make'.
Then
sudo make install
then we configure the node.
sudo nano /home/pi/bitcoinData/bitcoin.conf
and add to it
rpcuser=<yourbitcoinrpcuser>
rpcpassword=<yourpasswordhere>
**make up some values here remove the <>
save, exit, ctrl+o ctrl+x
Step (11) Tor Network Configuration
Install Tor
sudo apt-get install Tor
Install Tor
sudo apt-get install Tor
Edit torrc
sudo nano /etc/tor/torrc add these settings to the bottom of the file ControlPort 9051 CookieAuthentication 1 CookieAuthFileGroupReadable 1 HiddenServiceDir /var/lib/tor/bitcoin-service/ HiddenServicePort 8333 127.0.0.1:8333 save+exit, press: ctrl+o,enter,ctrl+x Restart tor (It's systemct L Not 1 (one)) sudo systemctl restart tor.service |
The line below will make the node available on Tor, IPv4 and IPv6. (A kind of dual mode)
@bitcoind -datadir=/home/pi/bitcoinData -daemon -proxy=127.0.0.1:9050 -externalip=<torhostnameyoucopied>.onion -listen -discover &
Use this line to use the Tor network ONLY (and reachable by other nodes on Tor network):
@bitcoind -datadir=/home/pi/bitcoinData -daemon -proxy=127.0.0.1:9050 -externalip=<torhostnameyoucopied>.onion -listen -bind=127.0.0.1 &
*There are many other options and features available. Intermediate users that require additional settings or want to customise can look here for the full list...
https://github.com/bitcoin/bitcoin/blob/master/doc/tor.md
That's it! When you reboot the Pi next it will run the node and connect by which ever preferences you specified in the Tor section.
To verify it's working use bitcoin-cli -datadir=/home/pi/bitcoinData getblockchaininfo check you have at least 8 connections (after giving it 5 mins to start) and each time you use that command, the value of "blocks": xxxxx should be increasing. That is your current block height. It will get slower to increase later on as blocks start getting busier. The "version": is referring to the version of Core you're using. It could be a higher number than the one in my screen shot |
Once you're happy it's downloading and sycronising it'd be worth checking that the tor network is enabled. You can do that with:
bitcoin-cli -datadir=/home/pi/bitcoinData getnetworkinfo Each paragraph represents a connection. For a connection being used it is "limited": false, and "reachable": true. So you can see here I have the node available to IPv4, IPv6 and Tor connections. If you configured for Tor only earlier, IPv4 and IPv6 would be "limited":true "reachable":false. As I said earlier there are plenty of configuration options with Tor. |
This is the tedious bit. It has to download approx 130GB+ of blocks and verify every transaction within it. That's a big ask for a little raspberry pi! It handles it fine though and on the nodes I have built it has taken approx 4 weeks. Just check on it every-other day or so with the getinfo command above. I've not had one crash yet. I should also mention that it builds the block-chain very quickly at first. For the first few years the block-chain is mostly empty, now the blocks are mostly at capacity and there are many more transactions to verify. It will get slower, this is normal. Once it has fully sync'd the Pi pretty much idles until a new block appears, busying itself with the transaction mempool.
**I believe there are requests not to use Tor to sync the blockchain from scratch, it will do it but is a sizeable burden for the network which often struggles for resources anyway. If you are able to sync via an IPv4 or 6 connection first and then enable your Tor connection that would be preferred.
To stop the node (recommended before disconnecting power, or using sudo reboot/shutdown from now on to prevent data corruption) use:
bitcoin-cli -datadir=/home/pi/bitcoinData stop
**I believe there are requests not to use Tor to sync the blockchain from scratch, it will do it but is a sizeable burden for the network which often struggles for resources anyway. If you are able to sync via an IPv4 or 6 connection first and then enable your Tor connection that would be preferred.
To stop the node (recommended before disconnecting power, or using sudo reboot/shutdown from now on to prevent data corruption) use:
bitcoin-cli -datadir=/home/pi/bitcoinData stop
Step (11) Security
I've been made aware that there are some underlying defaults that can affect system security. One is to disable root login by ssh by editing
sudo nano /etc/ssh/sshd_config and changing PermitRootLogin without-password to PermitRootLogin no and add the line below to only allow ssh access to user 'pi' AllowUsers pi Save, ctrl+o, enter, exit ctrl+x then reboot just sshd by sudo /etc/init.d/ssh restart I will update any security recommendations as I become aware of them. Enjoy |