How to setup a Globalcoin node on a Raspberry pi

This document will show you how to setup a staking wallet for globe on a raspberry pi. Disclaimer: While this worked for me, use at your own risk. I am not responsible for your coins.

Flash your raspberry pi with the raspbian os

Download raspbian stretch lite and flash with etcher

Boot your pi for the first time

For initial setup you will need:

  • Usb keyboard
  • Monitor w/hdmi cable
  • Micro usb power source

After initial setup we will run it headless so you won’t need a monitor or keyboard attached.

Connect the hdmi and keyboard and plug in the power. Once it boots you can login with the default login:

  • User: pi
  • Password: raspberry

Setup initial configuration

First, we will need to do some initial setup. to do that, bring up the config menu with the following command

sudo raspi-config

You should see a menu that looks like this raspi config menu

Perform initial configuration in raspberry pi config menu

you will want to set the following configuration options on your raspberry pi

1 - change user password for the current user
	change your defult password for the pi login
2 - change hostname
	name your raspberry pi whatever you like
4 - localisation options
	I1 - change locale
		The pi comes setup for a British UTF-8, to change this to a US UTF-8:
		remove en_gb.utf-8
		add en_us.utf-8 (en_us.utf-8)

		Or change it to the UTF_8 of your choice
	I2 - change timezone
		use your timesone
	I3 - change keyboard layout
		english (us) defaults or whatever you use

		For standard US keyboard select
			1) Generic 105-key (Intl) PC
			2) Other
			3) English (US)
			4) English (US)
			5) The default for the keyboard layout
			6) No compose key
	I4 - change wi-fi country
		set it to your country
5 - interfacing options
	P2 - ssh (enable)
7 - advanced options
	A1 - expand filesystem
	A3 - memory split 
		change from 64 -> 16

Select finish from the menu

Reboot if it doesn’t automatically

sudo reboot

Increase your swapfile size

login with pi/(new password)

sudo nano /etc/dphys-swapfile

Change conf_swapsize=100 to conf_swapsize=2000

Update your swapfile to the new 2gb size

sudo dphys-swapfile setup
sudo dphys-swapfile swapon

Setup wifi

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add to the bottom of file:

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

Turn on wifi

If you have the Raspberry Pi 3, you have built in wifi, you just need to turn it on.

sudo nano /etc/network/interfaces

Add the following to the bottom of the file: /etc/network/interfaces

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Reboot

sudo reboot

Once rebooted, login with pi/(new password)

Test network with

ping google.com

Note: you can use crtl+c to stop pinging

Add your user

You can use your own username, i used jproto. substitute whatever your username is for jproto in the following commands.

sudo adduser jproto
sudo usermod -aG sudo jproto

Shutdown your pi, you should now be able to ssh into your pi so you can unplug the monitor and keyboard and move it to a location is that out of the way.

sudo shutdown now

SSH into your pi

This tutorial assumes you use linux and have an ssh client already installed. if you are using windows you can use putty or cygwin for your ssh client and the usage will be similar.

Find your ip address

After powering on your raspberry pi, you will need to login to your router to find the ip address of your pi.

You can likely use your web browser and go to 192.168.0.1, but this differs based on your router. you may need to Google for your router’s specific details.

Note: if your router allows you to set the ip address of your pi to the same address, this is preferred. alternatively you can configure your pi with a static ip address, but that is outside the scope of this tutorial.

Ssh into your pi

Once you know the ip address of your pi you can log in from the ssh client of your local pc

ssh jproto@(ip address)

Update the software

once logged into your pi you should update the software.

sudo apt-get update && sudo apt-get upgrade -y

Setup firewall and rsa key login

Take thes steps to improve the security of your pi.

We will want to improve security by disabling password based authentication and moving to key based authentication.

After that, we will setup a firewall

Using key based authentication

Here is a good tutorial on how to setup key based auth in linux link. You can ignore the part about setting up a user and we will cover ufw below.

Adding firewall

We will use ufw as a firewall. to do this we need to

  • install ufw
  • allow ssh connections to the raspberry pi
  • enable the firewall
sudo apt-get install ufw
sudo ufw allow OpenSSH
sudo ufw enable

Install dependencies for wallet

Many of the dependencies can be installed through our package manager. However, a few need a specific version that is not available through the repositories, we will build those from source.

Install what we can from the repository

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

Install berkeley db

The globe wallet uses version 4.8 of the berkeley database so we’ll need to download, build, and install that.

First let’s make a directory for the source

mkdir ~/bin
cd ~/bin

Download the berkeley database source code, unzip it, then build the berkeleydb.

wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --enable-static
make -j4
sudo make install

Install openssl

The version of Open SSL in Raspbian Stretch is not currently compatable with boost. We need to compile a compatable version

Issue detail: [openssl issue - openssl-1.1.1 is not compatible with boost] (https://github.com/bitshares/bitshares-core/wiki)

Download and install open ssl 1.0.2

cd ~/bin
wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar -xf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l
./config
make -j4
make test
sudo make install

Note: If this incompatability is fixed in the future, you can just install libssl-dev from the repository

Download wallet source

We are now ready to build the wallet, let’s pull down the source code

cd ~/bin
sudo apt-get install git -y
git clone https://github.com/j-proto/global-wallet
cd global-wallet

Build leveldb

I had issues with building the packaged leveldb and had to build it myself. You can do this with the following series of commands.

cd ~/bin/global-wallet/src/leveldb
chmod +x ./build_detect_platform
make libleveldb.a libmemenv.a -j4
cd ~/bin/global-wallet

Build source

cd ~/bin/global-wallet/src
make -f makefile.unix CXXFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2 -I=/usr/local/ssl/include/" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib -L/usr/local/ssl/lib" -j4
strip globald
ln ./globald ~/bin/globald

Make the config file

Create the file ~/.global/global.conf

mkdir ~/.global
nano ~/.global/global.conf

Note: replace the value for rpcpassword with your own value, make it a strong password as this allows access to your coins.

rpcuser=globecoinrpc
rpcpassword=xxxxxxxxxxxxxxxxyourrpcpasswordxxxxxxxxxxxxxxxxxxxxx
rpcallowip=127.0.0.1
alertnotify=echo %s | mail -s "global alert" admin@foo.com
server=1
daemon=1
addnode=165.227.106.25

Restrict access to global.conf

chmod 600 ~/.global/global.conf

Add bin to your path

This will allow us to run scripts in ~/bin from any directory

nano ~/.bashrc

Add this to the bottom of the file

export PATH=$PATH:~/bin

Now reload bashrc

source ~/.bashrc

Start the node

globald

Check to make sure that you have connections and the blockchain is loading

globald getinfo

Problem connecting?

Find some node addresses here link You can include these in your config file using addnode if you are not getting connections

addnode=165.227.106.25

Setup wallet

You will want to encrypt your wallet, you can do this from the command line.

Create your own passprhase to replace the fake one below. Don’t forget it! if you do, you will be unable to stake or remove coins from the wallet.

globald encryptwallet xxxxxxyoursecretpasswordxxxxxxxxxxxxxxxxx

This will encrypt and stop the wallet. While it is stopped, make a copy so you can grab it (via sftp) as a backup and store it in a safe place.

cp ~/.global/wallet.dat ~/global2-2017-09-10.dat

Restart and test wallet

Now restart the wallet and make sure you can unlock it.

globald
globald walletpassphrase xxxxxxyoursecretpasswordxxxxxxxxxxxxxxxxx 9999999
globald walletlock

If this all worked, make sure you safely save your wallet.dat and passphrase somewhere. if you lose them you will lose access to your coins.

It is also a good idea to regularly back up your wallet.dat file.

globald backupwallet <location>

Unlock your wallet for staking

Now you need to unlock your wallet for staking. Do this by unlocking and setting the last parameter as true

globald walletpassphrase xxxxxxyoursecretpasswordxxxxxxxxxxxxxxxxx 9999999

If this worked you should see a value other than -1 for unlocked_until when you getinfo

globald getinfo

You can check on staking status with

globald getstakinginfo

Clear history

Since your passphrase is in your bash history, it is good to clear it with:

history -c

References

The following references were very helpful in setting this up, you may find them helpful too

You can also get a list of wallet commands with

globald help
Written on September 14, 2017