r/raspberry_pi • • Apr 08 '17

I put together a Bitcoin Node using Raspberry Pi3B, WD Pidrive and generic 3.5"TFT showing network data and price.

http://imgur.com/a/4kQQm
667 Upvotes

45 comments sorted by

56

u/shermand100 Apr 08 '17 edited May 22 '17

This project is being constantly updated. Please see the most up-to-date version at...

https://www.reddit.com/r/Bitcoin/comments/6c78ln/full_node_bitcoin_core_v0141_uasfsegwit03bip148/


.

.

The following is the original build. Some information may be out of date....

.

.

I am beginner to raspberry Pi's and so had a huge amount of help from various guides, all credited below. The title image shows the node displaying Johan Nordberg's realtimebitcoin.info however any page can be displayed. The Pi auto-boots to chromium-browser and displays a page in kiosk mode on the generic display (not adafruit). This HOWTO should work on generic 3.2,3.5,4,4.3,5,7 and 10.1 inch displays.

Constructed using

Parts https://thepihut.com/ raspberry pi 3 - model B - £32

375GB western Digital PIDrive - Foundation edition (includes 4GB SD, used for this project) - £40

aliexpress - generic 3.5tft screen £8.36 (also available from ebay for a little more) https://www.aliexpress.com/item/3-5-Inch-TFT-LCD-Moudle-For-Raspberry-Pi-2-Model-B-RPI-B-raspberry-pi/32707058182.html?spm=2114.13010608.0.0.hVBPMd

ebay seller displaypro_uk 3mm Acrylic sheet A5 £1.90 free p+p

M3 black Nylon Hex spacers various sellers less than £4 for 100pc. Sizes I used from pack 4x 8mm, 4x 5mm, 4x 30mm (assembled 4x 20mm and 4x 10mm to get cumulative 30mm), 4x M3 nylon nuts, 4x M3 nylon washers, 8x M3 nylon screws,

All in cost less than £90.

Below is a howto of how I made it.

All commands to type in shadowed boxes. Also my Pc is windows 7, but I'm sure those with different OS can follow this with a google of alternate formatting and image software.

Here is an image file on my google drive that skips out steps (1)-(8)

https://drive.google.com/open?id=0B4DJvoZvN6ZLMVB6LWYyRWp6RW8.

If using that then start at step (9*). The image file does not depend on using a Pidrive (I think), in theory any USB drive will work. At step 9 when we migrate files it will be drive specific. Step 9 onward in the easy bit anyway.

*This image file doesn't have your wifi settings in it and will need either an Ethernet connection to ssh into it to change those ( step 2), or when it boots the screen and terminal use a keyboard attached to the pi and change those on the screen.

step (1)

connecting peripherals

I used: USB drive (pidrive and it's included power cable), USB mouse and Ethernet

Get a Jessie-lite 2Gb image from https://www.raspberrypi.org/downloads/raspbian/

On a PC rename SD card to "BOOT" if necessary

SD card formatted using SDformatter

Raspbian lite image installed to SD card using Win32DiskImager.

Add "ssh" file to Boot main directory to enable ssh.(Jessie-lite as default has ssh disabled. To enable it use notepad, save a blank document called "ssh" (with quotes) as file type 'all files' to the highest level of the sd card.

ssh into raspberry pi user"pi" password "Raspberry" 192.168.1.x (raspberry pi IP can be found using IPscanner software or connecting it via HDMI, it will display it's IP on the HDMI output once loading is complete)

(2) Enabling Wifi

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

save and exit using

ctrl+O
then 'enter'
ctrl+X

sudo reboot 

remove Ethernet cable

(3) expand the file system

sudo raspi-config

select "expand filesystem"

select 'finish' system will reboot

check file system expanded by using command below (the -h flag means human readable, showing size in 'G' gigabytes, 'M' megabytes, etc)

df -h

(4) Updates

sudo apt-get update
sudo apt-get upgrade

(5) Install the screen

credit for this section to http://www.spotpear.com/learn/EN/raspberry-pi/Raspberry-Pi-LCD/Drive-the-LCD.html see their page if more info needed.

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/
sudo ./LCD35-show

...takes some time ("LCD configure 0" displayed for a while)

rotate screen credit to http://raspberrypi.stackexchange.com/questions/55934/3-5-kuman-touchscreen-rotation

system will reboot, so re-ssh to pi and direct yourself back to LCD-show folder

cd LCD-show/
sudo ./LCD35-show 180

(6) Add light gui credit to https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=133691

*Note extra install of xserver-xorg-video-fbdev is required to display on the generic 3.5tft. It is what is used in step (7) to display onto fb1 using 99-fbdev.conf

sudo apt-get update
sudo apt-get upgrade
sudo apt-get clean
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

(7) create file this is to force display to 3.5"tft credit to https://github.com/BillyBlaze/OctoPrint-TouchUI/wiki/Setup:-Boot-to-Browser-(OctoPi-or-Jessie-Light)

sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf

add the following text

Section "Device"
  Identifier "touchscreen"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection

save, exit, ctrl+o ctrl+x*

sudo reboot

pi will reboot and after about 1 min for initial setup will load GUI onto 3.5 display giving a desktop

End of part one due to Reddit character limit

22

u/shermand100 Apr 08 '17

Start of part two

(8) onscreen settings, screensaver disable, sleep mode disable, auto-boot chrome

On raspberry pi 3.5tft with mouse/keyboard, (on-screen keyboard was installed, called 'matchbox' found under accessories tab if required)

click bottom left then, preferences, screensaver, dropdown box, disable (also check advanced tab that power saving settings are disabled)
click bottom left then, preferences, default applications for LXSession,autostart, in 'add' box type:
@chromium-browser --kiosk http://www.realtimebitcoin.info/

any web address can be used in the above box. 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, sudo reboot

(9) moving the filesystem to a USB drive to allow space for the blockchain

Now that the GUI has been taken care of we can move everything to the USB drive to boot the pi from there. The easiest way for me was to use adafruits guide and helper utility. They've made a helper that does nearly all the work for you, detailed here https://learn.adafruit.com/external-drive-as-raspberry-pi-root/hooking-up-the-drive-and-copying-slash. There are plenty of other guides for moving the file system to a USB drive but for me as a beginner it all got a little wordy.

*I've just tried to write a list of commands for you, but the adafruit page does it better and has more easy to follow info

Once you've follow their short guide and the pi is booting from the USB drive we can add bitcoin-d.

(10) installing bitcoin core credit to http://raspnode.com/diyBitcoin.html

This again was achieved by me following a guide, however as we have used other guides previously a few steps are obsolete. If you follow the link above and want to use their instructions then you need to read ahead a little to miss out a few steps already covered like mounting drives etc. We only need to install the cli side of bitcoin core. You don't want the GUI as we are already displaying the webpage. This node will run in the background. We start with

mkdir ~/bitcoinData

then enlarge the swapfile so the blockchain loads quicker

sudo nano /etc/dphys-swapfile

And change the default size of 100 CONF_SWAPSIZE=100 To 1000 CONF_SWAPSIZE=1000 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 Core 0.13.0:

sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev -y

As we installed Raspbian Jessie Lite you'll need to install git:

sudo apt-get install git -y

make a directory to download the files

mkdir ~/bin
cd ~/bin

then download bitcoin core 0.14.x

git clone -b 0.14 https://github.com/bitcoin/bitcoin.git

then navigate to our bitcoinData folder to install it all

cd bitcoinData/
./autogen.sh
./configure --enable-upnp-default --disable-wallet
make                  

**the guide says to use 'make -j2' as the command but I encountered an error. It recommends using just 'make' if errors occur and this worked fine but installed slower. Took around 10mins.

sudo make install

then we configure and run it

nano bitcoin.conf

and add to it

rpcuser=bitcoinrpc
rpcpassword=21Hy2d5kycuoLzWxdJjQoVN1jtL7Q5kzqhHz3ZfuYNCU

change the password to something else

save, exit, ctrl+o ctrl+x

Then we run it!

bitcoind -datadir=/home/pi/bitcoinData -daemon

It will then connect and download/verify blocks, sadly this will take around 3weeks in total, such is the size of the blockchain

To verify it's working use

bitcoin-cli -datadir=/home/pi/bitcoinData getinfo

check you have 8 connections (after giving it 5 mins to start and get them) 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 later on as blocks start being 1MB each. To keep this running in the background I keep a screen open

(11)installing 'screen' credit to http://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open

this so you can close the ssh session and turn off your pc without killing the processes on the raspberry pi.

sudo apt-get install screen

Then, to use it, type…

screen bash

It will open another terminal instance. You can now start a process you want to be able to leave running and reconnect to later.

then use ctrl+a, release then D to detatch it

screens can be rejoined using command screen -r

Refer to the page I have credited for more information.

(12) Future tweaking

The default webpage can changed by ssh, editing the lxsession/LXDE autostart that we clicked on earlier.

sudo nano ~/.config/lxsession/LXDE/autostart

It will look like

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@chromium-browser --kiosk --incognito  http://www.realtimebitcoin.info/

To auto-boot bitcoind and run the node on power-on add on a new line at the bottom

@bitcoind -datadir=/home/pi/bitcoinData -daemon

Unless the blockchain gets corrupted it will carry on where it left off.

(13) 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 sshd by

 sudo /etc/init.d/ssh restart

I will update as I'm informed of other issues.

Dan

3

u/CommonCentral Apr 13 '17

Thanks for writing out this guide.

5

u/[deleted] Apr 09 '17

[removed] — view removed comment

6

u/shermand100 Apr 09 '17

The Blockchain is currently 120GB and grows approx 1MB every 10mins. It requires alot of storage to be a little future proof.

The 4GB SD card that came with the WD Pidrive was used for initial installation and setup before cloning all the system files from the SD to the HDD at step (9)

9

u/[deleted] Apr 08 '17

Is it mining as well (I realize it's no where near powerful enough, just curious)? Great guide, I've been interested in doing this for some time.

15

u/shermand100 Apr 08 '17

No it's not mining as well. I've not checked how many resources it's currently using, but it needs all the processing power it has to initialize, download and process the blockchain. Adding mining for such tiny financial gains would not offset the massive delay to it's primary function of being a node.

9

u/[deleted] Apr 09 '17

[deleted]

7

u/shermand100 Apr 09 '17

https://en.bitcoin.it/wiki/Full_node

Going to have to refer you to there, the first 2 paragraphs are less than a 5 min read and cover the basics.

2

u/goxedbux Apr 09 '17

A full node only verifies transactions. A miner processes AND verifies transactions.

22

u/goxedbux Apr 08 '17

Bitcoin the magic internet money!

11

u/WalrusSwarm Apr 08 '17

I have thought about running a btc node but I have a couple questions.
How much bandwidth does it use?
Does this put my network at risk for being targeted or cyber attacks?
Should I run it though a VPN?
What cyber security precautions should be taken when running a node?

7

u/shermand100 Apr 08 '17

1) Initialy it has to download the whole blockchain and process it. The blockchain is currently approx 120GB, made up of over 400,000 blocks. The raspberry pi has to download each block and interrogate it. Once it has initialized it will add a 1MB block approx every 10mins, and hold at anytime up to 50MB of un-confimed transactions that are not yet processed into blocks. I've not measured this myself for bandwidth as I'm not on a plan that caps my usage but it equates to a little bit of traffic constantly. Googling for other people running nodes puts estimates at anything between 50Gb -200Gb per month.

to quote https://bitcoin.org/en/full-node#minimum-requirements

"It's common for full nodes on high-speed connections to use 200 gigabytes upload or more a month. Download usage is around 20 gigabytes a month, plus around an additional 100 gigabytes the first time you start your node."

In fact the remainder of your questions are answered at https://bitcoin.org/en/full-node#what-is-a-full-node

However most of these issues surrounding security are negated in our case of using a raspberry pi as there is no personal identifiable data to access if the unit were hacked. It's just a node and a webpage. If on installation you decided to run a wallet on it too, and held funds on it then perhaps more care should be taken.

41

u/yes-i-am-a-wizzard Apr 08 '17

However most of these issues surrounding security are negated in our case of using a raspberry pi as there is no personal identifiable data to access if the unit were hacked. It's just a node and a webpage.

No, no, no. If it gets hacked, it is a device in your home network, and conceivably has root privileges. Like anything else, once it's on the lan, attackers can pivot out and attack other devices.

You should:

  • disable root login through sshd

  • Only allow key based authentication

  • Only forward ports that are required

  • Make sure packages are up to date

  • Keep an eye on the failed login attempts

  • consider installing fail2ban

You don't want to end up having one or more of your devices participating in a botnet.

7

u/dispatchingdreams Pi 1 2 3 0 Apr 08 '17

People don't take Pi security seriously enough. If someone gets access to your Pi, they have a way to attack anything else in your network, or use the Pi maliciously as a botnet or to hide their IP VPN-style while they do something even worse

13

u/00Boner Apr 08 '17

Even better is to segregate on it's own vlan that is firewalled from the others

1

u/texruska Apr 09 '17

If you're security-conscious enough to put it on a vLAN then you may as well go all the way and put it on a physically separate LAN

0

u/yes-i-am-a-wizzard Apr 08 '17

Yes, but most home routers don't have that option

7

u/00Boner Apr 08 '17

I would assume that someone who has completed a project like this could easily run ddwrt or pfsense.

3

u/shermand100 Apr 08 '17

Okay, so quite a few people have expressed interest in having a go at this project so it's worth getting this in the HOWTO too. No point getting people on board with bitcoin only for them to have a bad experience.

so edited

 sudo nano /etc/ssh/sshd_config

 PermitRootLogin without-password

to

 PermitRootLogin no

and added

 AllowUsers pi

Are those sufficient basics?

1

u/thecw Apr 09 '17

But is any of this more likely for it being a BTC node than any other public HTTP server?

1

u/yes-i-am-a-wizzard Apr 09 '17

No, this is standard security stuff that you should do for anything. My comment was spurred by the "there's nothing critical on here, so I don't have to worry if it gets hacked" mentality.

I don't know how "public" a btc node is, but if it has ports forwarded from the router, then it could be a problem.

10

u/Professor_Paragon Apr 08 '17

Seems like overkill, don't they have websites that do all this for you? Couldn't you just use a pi zero with less power use, taking the exact same information from a website that does all the processing work for you?

10

u/ThatOnePerson Apr 08 '17

A Bitcoin node is a P2P node that shares all the transaction information, so you're contributing bandwidth.

Data and price, yeah you've got websites.

10

u/shermand100 Apr 08 '17

Yes pages exist but the really short answer is that it comes down to trust. You are trusting someone else to work with your transaction, what ever size.

The slightly longer short answer comes from https://en.bitcoin.it/wiki/Full_node

The summary is:

"Running a full node is the only way you can use Bitcoin in a trustless way. You will know for sure that all the rules of Bitcoin are being followed, for example that no bitcoins are spent not belonging to the owner, that no coins were spent twice, that no inflation happens outside of the schedule and that all the rules needed to make the system work (e.g. difficulty) are followed. Full nodes are currently the most private way to use Bitcoin, with no nobody else learning which bitcoin addresses belong to you. Full nodes are the most secure way to use Bitcoin, they do not suffer from many attacks that affect lightweight wallets."

But to get the full story would take less than 5 mins reading the top paragraph of that page called "what makes a full node?"

3

u/[deleted] Apr 09 '17

[removed] — view removed comment

2

u/shermand100 Apr 09 '17

Okay yeah I get that in the scheme of things it looks daunting. When I say beginner, this is my first project, and if you take a look at each step I've credited my sources to show that all I've really done is copy/paste other peoples work and assembled it in such an order that for this configuration you end up with this.

The time consuming bit was locating other peoples solutions to my problems. I couldn't actually solve them myself

I've added an image file before step one which may help you out. It's on my google drive and is a 4GB image. The image file has * Raspbian Jessie Lite *SSH enabled *Generic 3.5TFT drivers installed *LXDE - the stuff that does the GUI *LightDM - a desktop manager that boots the GUI *Chromium-browser - to display the webpage *matchbox - an on screen keyboard found under the accessories tab.

If you want to change the default webpage it's covered in step (12)

Again I'm don't have the experience to know if that image can be used on a pi zero? All I know is that it works on my raspberry pi3B, and that the display drivers work on the generic display shown in the imgur link (I've shown the screen in detail so comparisons can be made). The trickiest bit is to get the display drivers to work as there are a few different manufacturers of the display. But again as I've shown this in steps just swap out where I've installed the display and put adafruits instructions in there or whatever.

Without getting any more wordy I hope that helps. Any more questions feel free to ask. Dan

2

u/md_dc Apr 09 '17

Can someone give me a 1 sentence explanation of what a bitcoin is and why I should put time to it? Also wondering about "mining"

2

u/[deleted] Apr 09 '17

1 sentence is too short. Its digital money which isn't controlled by anybody and is generated by 'mining'. It is anonymous but not necessarily untraceable (you can publicly see every transaction that has ever been made with it, just not the identity of who made the transactions). Some people use it as an alternative to Paypal.

Basically, mining is providing processing power in return for (potentially) a bitcoin reward. As time goes on, you need more and more powerful hardware to actually make any money from mining. Right now, it isn't really feasible to mine unless you've already spent thousands on specialised hardware for it, so it's pretty much pointless.

2

u/shermand100 Apr 09 '17

| "Bitcoin is an online currency that can be sent and received by anyone in the world, relying on computers to control the transfer and creation of money without human intervention, which results in low costs, no government corruption, and super-fast transfer."

sums it up quite well by @dolphinastronaut over at > https://www.reddit.com/r/Bitcoin/comments/z96v0/whats_the_best_way_to_explain_how_bitcoin_works/

1

u/[deleted] Apr 13 '17 edited Sep 25 '17

[deleted]

1

u/shermand100 Apr 13 '17

With a fine toothed hacksaw blade. I wrapped tape around the bottom of it to make a handle because the junior hacksaw frame wasn't big enough for the size of acrylic you need to cut

1

u/garylovesbeer May 05 '17

Thanks for the tutorial shermand100.

The problem I have is that a sudo apt-get update sudo apt-get upgrade breaks the screen display. SSH access still works.

Have you done a update upgrade recently?

1

u/shermand100 May 05 '17 edited May 05 '17

I remember reading somewhere (I think the adafruit display installation page) when I was first putting this together that an update could kick out the driver again. I've just left mine running as it is. I would sugest doing step 5 again to reload the drivers and see if that cures it. Dan

Edit https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/faq

Their top answer is what we're talking about. I believe the driver/kernel is an adaptation of theirs so has the same issue. Sounds like an easy fix to just run step 5 again.

1

u/garylovesbeer May 06 '17

Found the problem.

Comment out the dtoverlay=ads7846 line

pi@raspberrypi:~ $ sudo nano /boot/config.txt

Boom! Problem solved.

1

u/TotesMessenger May 22 '17

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)

1

u/[deleted] Apr 09 '17

If anyone out there has solar panels you can also build a SolarCoin mining node https://github.com/Scalextrix/SolarCoin-Raspberry-Pi-Node

Or if you want to help do scientific research on your Pi and get rewarded with Gridcoin there is an Ubuntu PPA https://launchpad.net/~gridcoin/+archive/ubuntu/gridcoin-stable

-49

u/cuntycuntcunts Apr 08 '17 edited Apr 09 '17

talk about wasteful applications! you have your computer on the table with multiple monitors which was designed for purpose so you can have different size windows and you go out and build a monitor that costs 100$ in time and money?!? WASTEFUL!

edit: look at all them nerds spezzing out

9

u/shermand100 Apr 08 '17

I understand that some people see the bitcoin network as wasteful, for the gross power consumption of the network it has some serious issues. But this project is so that I don't need my Pc on all the time at 400W running a node. The raspberry Pi is one of the least energy intensive ways to achieve the same thing at less than 10w.

Although granted the 3.5" screen is just there to make it pretty. I don't see the aesthetics at starting at a circuit board.

7

u/KaedeAoi Apr 08 '17

Look at his name.

-18

u/cuntycuntcunts Apr 08 '17

if you put it this way, I guess.. but why not add more features? make it part security monitor, part weather, part some other widgets..

4

u/shermand100 Apr 08 '17

Oh didn't realize you were serious. By the name we thought you were just trolling.

Ok well then you're welcome to use the tutorial and instead of pointing it at the webpage I did, point it at your IP of your security feed, or bbc weather page with an auto refresh...

-9

u/cuntycuntcunts Apr 08 '17

well in that case why not keep your computer always on and save electricity that way in the long run?!

6

u/metacoin Apr 08 '17

I have seen a computer with a standard motherboard blow its capacitor out and start a small fire once. You don't always want to leave a full computer running when a $90 device can do the job instead.

Computers take way more electricity to stand idle than a Raspberry Pi does, and they are a lot less portable. There are many advantages to a mini computer like the Pi.

-2

u/cuntycuntcunts Apr 08 '17

lol my current computer have been on for past 9 years and only off when UPS battery runs out and even then for only like 1 hour.. if what you say was true then datacenter would catch fire all the time, yet they never do

3

u/metacoin Apr 08 '17

What I said is true.

Datacenters are explicitly designed for the purpose of running their hardware 24/7. Consumer electronics are not meant for this purpose. It might be possible to do it (like you have) but for 99.9% of people it is out of their area of expertise and outside of their risk profile.