Build Your Own Raspberry Pi Litecoin Supernode [version 0.8.7.5]



LAST UPDATED JUNE 28, 2015
Disclaimer: I cannot guarantee these steps will work 100% of the time. Like all DIY tutorials they make assumptions about things and are subject to external libraries and software being updated or changed. I periodically test and update these steps for changes or additions, but I can't guarantee that some troubleshooting won't be needed to get your node up and running.

PRELIMINARIES

This tutorial is to install Litecoin version 0.8.7.5 on a Raspberry Pi 2. This is not the latest version, and DIY steps for the latest can be found here. Options are given to install the GUI and wallet or not. The blockchain is currently around 4.6GBs and so a minimum 16GB microSD card should be used unless the blockchain is to be stored externally (like on a USB drive).

If you run into any Raspberry Pi problems while going through these steps, the Raspberry Pi Docs are a good source for help:

http://www.raspberrypi.org/documentation/

FULL STEPS

EQUIPMENT FOR NODE

PURCHASE OPTIONS

You can find what is needed to build a Litecoin raspnode for less than $100.

The CanaKit Raspberry Pi Starter Kit costs $70 (plus tax and shipping) and comes with everything you need except an Ethernet cable (if you wish to cable directly to your router) and it comes with an 8GB microSD instead of the required 16GB.

EQUIPMENT FOR SETUP

ASSEMBLY

How to assemble your Raspberry Pi will depend on the case purchased. Once assembled, plug in your USB keyboard, HDMI cable to your monitor, and either your USB Wifi adapter or an Ethernet cable going to your router.

The device will automatically power on once you plug in the micro USB power cable.

INSTALLING THE RASPBIAN OS

If your Raspberry Pi came with a microSD card preloaded with NOOBS you can insert the microSD card into your Raspberry Pi, plug in your power cable and it will walk you through your setup. Make sure you select Raspbian as your OS choice, which should be the first on the list. It will take a few minutes to install. Once that is finished, reboot and jump to Raspbian config options.

If you have a brand new microSD card, you will need to download a Raspbian image to your PC and image your microSD card. This tutorial will assume you are using a PC running Microsoft Windows. Instructions for imaging using Mac or Linux can be found in the Raspberry Pi documents:

http://www.raspberrypi.org/documentation/installation/installing-images/README.md

You can find the latest on the Raspberry Pi downloads page:

http://www.raspberrypi.org/downloads/

Or directly download the latest here:

http://downloads.raspberrypi.org/raspbian_latest

Once downloaded, unzip the file. If you don't have an application installed for unzipping files, you can use the open source 7zip:

http://www.7-zip.org/

The unzipped folder will have a large .img file. In order to put this image on your microSD card we'll need to use the open source Win32DiskImager which can be found on sourceforge:

http://sourceforge.net/projects/win32diskimager/

Or directly download the latest here:

http://sourceforge.net/projects/win32diskimager/files/latest/download

Once downloaded run the installer, this will install Win32DiskImager.

Insert your microSD card into your PC. Launch Win32DiskImager. Select the Raspbian .img file as the 'image file' and select your microSD card as your 'device'. Make sure what is selected is your microSD card and nothing else, especially your hard drive. Click 'write'. This will take a few minutes.

Once finished, eject your microSD card. Insert your microSD card into your Raspberry Pi and plug in the power cable and wait while it boots up.

RASPBIAN CONFIG OPTIONS

When you first boot Raspbian you will be prompted with the raspi-config menu shown below:

If you used NOOBS to install Raspbian your file system will already be expanded to fill your full microSD card. However if you installed a Raspbian image you'll need to expand it now.

Select “1 Expand File System" which will expand the file system to fill the card.

OPTIONAL

If you won't be using Litecoin-Qt (the GUI) then you can run it 'headless' and we can allocate a little more RAM to the CPU.

Select "8 Advanced Options" then select "Memory Split"

Change 64 to 16

Select "OK"

If you want to be able to SSH into your Raspnode, you can enable the SSH server here.

Select "8 Advanced Options" then select "SSH"

Select "Enable"

Change hostname. The default hostname is set to "raspberry". We'll change ours to "raspnode" and the rest of the tutorial will assume this. If you leave yours as "raspberry" or change it to something else, anytime you see the hostname mentioned, use that instead of "raspnode".

Select "8 Advanced Options" then select "Hostname"

Edit the hostname to “raspnode" without quotes (or to your desired hostname)

Select "OK"

Here you can also change the default user (which is "pi") and password (which is "raspberry"). We'll leave these as is for the tutorial. If you change your username, make sure to use that instead of "pi" when it shows up in this tutorial.

You can overclock your Raspberry Pi in order to give it a little more processing power. This may make the initial verification of the blockchain quicker, but is not needed for normal node operations.

Select "7 Overclock"

Choose the desired level of overclocking

Select "OK"

To set your timezone:

Select "4 Internationalisation Options"

Select "Change Timezone"

Go through the selection process to select your timezone, then select "OK"

Once done, select "Finished" and your Raspberry Pi will reboot.

When you get the "login" prompt, enter your username "pi" and it will prompt you for your password. Enter your password (which won't show up) and hit <enter> to log in (the password will be "raspberry" if you didn't change it in the raspi-config).

EDITING FILES

We'll be using the command line to edit files. If you are not familiar with a command line this may be a little tricky. Raspbian comes with a few editors. Nano is a relatively friendly editor and this tutorial will use that, but Raspbian also has vi for users who prefer it and can be used instead. If you have not used vi before, you should stick with nano.

For those not familiar with Linux, some actions we take will require root privileges. We get that by using the command “sudo" before our desired command. This will only work if you are logged in as a user with sudo rights, which the default Raspbian user (“pi" in our case) has. Sudo can be set to require a password, but the default Raspbian user should be set to not need one.

You may want to change the default keyboard layout. Edit /etc/default/keyboard

pi@raspnode~$ sudo nano /etc/default/keyboard

Change the line

XKBLAYOUT="gb"

to equal your desired country code, so for US keyboard layout change it to

XKBLAYOUT="us"

Then save and exit. Reboot to have it take effect. Reboot with

pi@raspnode~$ sudo shutdown -r now

NETWORKING ON THE RASPBERRY PI

If you are using an Ethernet cable and plugging directly into your router and DHCP is turned on, you can plug that in and you should have access to the Internet. You can check by pinging out:

pi@raspnode~$ ping google.com

If you start to see pings you are good. Hit <ctrl> + c to stop the pings. If you are using a wifi adapter and have a password set for your router, there are a few more steps to take. Setting up and troubleshooting wifi on the Raspberry Pi is beyond the scope of this tutorial, so if the basic setup shown here doesn't work, you can reference the Raspberry Pi documentation for help:

http://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

To setup your wifi, edit the file /etc/wpa_supplicant/wpa_supplicant.conf:

pi@raspnode~$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add this to the bottom of the file:

network={
    ssid="<your wifi ssid here>"
    psk="<your wifi password here>"
}

For example, if your wifi network is named myHomeWifi and your wifi password is mySuperSecret then wpa_supplicant.conf should look something like:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="myHomeWifi"
    psk="mySuperSecret"
}

Then restart your wifi interface:

pi@raspnode~$ sudo ifdown wlan0
pi@raspnode~$ sudo ifup wlan0

If you need to set a static IP, that is currently out of the scope of this tutorial.

DOWNLOADING LITECOIN DEPENDENCIES

In order to install Litecoin we need to install a few tools and software packages. First let's make sure everything is up to date and update it if it isn't:

pi@raspnode~$ sudo apt-get update
pi@raspnode~$ sudo apt-get upgrade -y

This one liner will download and install the packages we will need for Litecoin 0.8.7.5:

pi@raspnode~$ sudo apt-get install libssl-dev libdb++-dev libboost-all-dev libminiupnpc-dev -y

That should take just a couple minutes. If you plan on using litcoin-qt (the GUI and wallet) then you'll have to install additional dependencies:

pi@raspnode~$ sudo apt-get install qt4-qmake libqt4-dev libqrencode-dev -y

INSTALLING LITECOIN

Make a directory to download required files:

pi@raspnode~$ mkdir ~/bin
pi@raspnode~$ cd ~/bin

Download the Litecoin 0.8.7.5 source code from github:

pi@raspnode~/bin$ git clone -b master-0.8 https://github.com/litecoin-project/litecoin.git

If you plan on using Litcoin-Qt (the GUI) then use these commands to build it:

pi@raspnode~/bin$ cd litecoin
pi@raspnode~/bin/litecoin$ qmake "USE_QRCODE=1"
pi@raspnode~/bin/litecoin$ make -j2

If you don't want to generate QR codes for the addresses, you can omit the '"USE_QRCODE=1"' argument and the 'libqrencode-dev' from the 'apt-get install' above. The 'make -j2' should take a little under 30 minutes to complete. If you get errors with 'make -j2', then just use 'make' and it may take around 40 minutes.

If you just want litecoind (command line only) then use these commands to build it:

pi@raspnode~/bin$ cd litecoin/src
pi@raspnode~/bin/litecoin/src$ make -f makefile.unix -j2

The 'make...' will take around 20 minutes. If there are memory errors, remove the '-j2' and try again, but it will take longer.

CONFIGURE AND RUN LITECOIN

Move to your home directory:

pi@raspnode~/bin/litecoin$ cd ~/

If you installed litecoind, then you'll need to create a config file. First run litecoind with:

pi@raspnode~$ ~/bin/litecoin/src/litecoind -daemon

Some text will return that gives you an rpcuser and rpcpassword to use. You don't have to use these, but it is recommended.

Press <ctrl> + c to stop litecoind and get the prompt back. This will also create the hidden .litecoin directory in your home directory which is where you need to add the config file. Create the new file and edit it with:

pi@raspnode~$ nano .litecoin/litecoin.conf

And add in a rpcuser and rpcpassword, it should look something like this if you use the one suggested by litecoind:

rpcuser=litecoinrpc
rpcpassword=21Hy2d5kycuoLzWxdJjQoVN1jtL7Q5kzqhHz3ZfuYNCU

THIS IS JUST AN EXAMPLE, DO NOT USE THIS PASSWORD!

Save and exit and now you can run litecoind with:

pi@raspnode~$ ~/bin/litecoin/src/litecoind -daemon

Or if you want to be able to run litecoind from anywhere you can move it with:

pi@raspnode~$ sudo mv ~/bin/litecoin/src/litecoind /usr/local/bin/

And then you can run

pi@raspnode~$ litecoind -daemon

from anywhere.

If you want to run Litcoin-Qt (the GUI with wallet) then you'll have to first launch the desktop:

pi@raspnode~$ startx

Once the desktop has launched, open a terminal window:

Then run:

pi@raspnode~$ ~/bin/litecoin/litecoin-qt

If you want to be able to run Litecoin-Qt from anywhere, move it with:

pi@raspnode~$ sudo mv ~/bin/litecoin/litecoin-qt /usr/local/bin/

And then you can run

pi@raspnode~$ litecoin-qt

from anywhere.

Downloading and verifying the full Litecoin blockchain on the raspberry pi takes around 36 hours as of June 2015. If you already have a copy of the blockchain on another computer, you can transfer the contents of the litecoin data directory (except for wallet.dat, unless you wish to move your wallet over as well) to the .litecoin directory.

CONFIGURE HOME NETWORK TO SYNC WITH THE LITECOIN NETWORK

In order to act as a supernode and upload blocks to requesting nodes you will need to configure your home router to forward port 9333 to your raspnode. To do this you'll need your raspnode's IP address which you can get by running ifconfig:

pi@raspnode~$ ifconfig

If you are cabled into your router directly the IP address will be under "eth0", if you are on wifi it will be under "wlan0".

CONFIRM YOUR NODE IS REACHABLE BY THE NETWORK

To confirm that you are seeding the Litecoin network you can check and see if you have more than 8 connections by running:

pi@raspnode~$ litecoind getinfo