DMDv3 Wallet Compilation Guide for Raspberry Pi version 2

More info here: bit.diamonds 

Dmdv3 wallet compilation guide for raspberry pi (headless mode), october 2017, version 2

1.

Disclaimer

1.This guide will walk you through the compilation steps of a headless DMD client. That means you won�t have a GUI, just the console version of the wallet (also called rpc wallet). If you are not comfortable with the command line, you may give up on the idea of using the Pi altogether, and opt for a fully featured PC instead (Linux, Mac, or Windows based) with enough resources to run a fully fledged QT wallet.

2.Once compiled, the wallet can be used for holding DMD funds, coin staking, or to setup a masternode. The specifics for running such variation will not be presented here, and should be obtained at bitcointalk.org, bitdiamonds website, or the Slack Diamond group.

2.The compilation process described herein was based on the Broadcom BMC2835 (ARMv6) architecture, available in the following Pi models: 2, B, B+, A, A+, zero, and zero W.

3.Newer Pi models based on the BMC2836 (Pi2) and BMC2837 (Pi3) architectures are supposed to be backwards compatible, and therefore should also be capable of compiling the wallet, as long as the recommended Raspbian OS version and software packages described in this guide are used.

4.Although Pi models with 256Mb RAM should be equally capable of compiling the wallet, the process can be very lengthy and may take several hours, or even days.

5.This document will guide you in the installation of the wallet, nothing more. It is not, and does not intend to be, an official wallet release. The author of the guide or the DMD Development Team should NOT be held responsible for any loss of DMD funds as a consequence of improper wallet compilation. In short, use the guide at your own risk!

6.As a safety measure, it is strongly recommended that you make transfer tests with smaller coin amounts to ensure you have a fulling working wallet, prior to managing larger DMD amounts.

7.If you enconter any dificulties along the compilation process, please PM user shinebright on DMD�s Slack group, and I�ll be glad to help you anyway I can. Please note that I�m no TI expert, just a DMD user with lots of interest in low power consumption staking with the most solid and rewarding cryptocoin!

2.

Hardware requirements

- Raspberry Pi with 512mb RAM (models B and above)

- Power cable (5V, 2A minimum recommended)

- SD card with minimum 8Gb capacity

- Monitor with suitable connection interface, depending on your Pi model (required for initial setup)

- USB Keyboard (required for initial setup)

3.

System requirements

- Raspbian Jessie Lite

Warning: The latest version of Raspbian (Stretch) is not recommended due to potential Boost library version conflicts. If you have Raspbian this version already installed, you are welcome to try compiling DMD wallet anyway, but results are not granted.

4.

Download Raspbian Jessie Lite

You can find the latest stable version of Raspbian Jessie Lite here:

downloads.raspberrypi.org

Note that Raspbian Lite is the console-only version of the OS, with a very small footprint (ideal to be run in headless mode).

5.

Burn the OS into the SD Card

For this step, I recommend that you follow Raspberry Pi�s official tutorial at

raspberrypi.org

There you can find detailed instructions for 'burning' the image into the SD card, on various host operating systems (Window, Linux or Mac).

6.

Boot Raspbian Jessie Lite

- Insert the SD card with Jessie Lite (obtained in step 5) into your Pi.

- Plug in your keyboard and monitor.

- Connect the ethernet cable (make sure you have a working internet connection).

- Plug the power cable to the Pi, and wait for the onscreen boot process to finish.

- Log in as the default pi user:

- username: pi

- password: raspberry

7.

Create a new username and password

As a safety precaution, you should create a new user, since the default pi's username and password are too common.

Create a new user

 CODE

sudo adduser USERNAME

Replace USERNAME with whatever name you desire. You will be asked to provide a password. Make sure to create a strong one, since this user account will harbor all your DMD coins.

Give superuser (sudo) priviledges to the new user

 CODE

sudo usermod -aG sudo USERNAME

Log in into the new account, typing your new password when prompted

 CODE

su - USERNAME

8.

Initial setup

If you intend to connect the Pi via wifi, go to step 9. Otherwise, skip to step 10 (ethernet only).

9.

Setup wifi connection

Edit the network interfaces file

 CODE

sudo nano /etc/network/interfaces

Add this to the first line

 CODE

auto wlan0

And add the following to the end of the file

 CODE

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

Configure wpa_supplicant

 CODE

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following to end of the file

 CODE

network={
ssid="NETWORK_SSID"
psk="NETWORK_PASSWORD"
}

Where NETWORK_SSID is your network ID, and NETWORK_PASSWORD is, obviously, the password.

Reboot the Pi

 CODE

sudo reboot

After the boot has finished, login again (please use your NEW username for this, not 'pi') and your Pi should connect automatically to the wifi network.

Additional security-related configuration steps can be found here: raspberrypi.org

10.

Get your IP address

Get your local IP address

 CODE

ifconfig

Among the results, you should see a line in the following format

 CODE

inet addr:192.168.0.10

That's your IP address. Save it for the next step. Note that if you have both ethernet and wifi connections working simultaneously, there will be 2 blocks of information, one regarding the former (eth0) and another the latter (wlan0 or something similar). You must decide which connection type you will henceforth use, and save the respective IP address.

If you want to use the Pi as a headless client, go to step 11. On the other hand, if you want to use it as a regular desktop computer with keyboard and monitor, you may skip to step 12.

11.

Remote connect to the Pi

You may now unplug any peripherals (keyboard, display) and establish a remote connection to the Pi via terminal (Mac or Linux) or putty (Windows). You can download putty here: putty.org.

From now on, all the steps assume that you are in a console environment, regardless of the your main computer operating system, and that the Pi is connected to the network, either via wifi or ethernet cable. All the commands should now be issued on your main computer, not on the Pi (except for those using it as a regular desktop computer).

Open terminal (Mac or Linux) or putty (Windows) and connect to the Pi via ssh

 CODE

ssh USERNAME@ADDRESS

Where ADDRESS is the IP address obtained in step 11. Once the connection has been established, go to step 12.

12.

Create a swapfile

Since compilation requires a lot of RAM (Pis are rather limited in this regard), you will need to create a swapfile. A swap size of 1024Mb is recommended, regardless of the amount of RAM your Pi has.

Check available swap size

 CODE

free -m

If your swap is around 1024 mb, you're fine. Otherwise, you need to change it

 CODE

sudo nano /etc/dphys-swapfile

Change the swap size:

 CODE

CONF_SWAPSIZE=1024

Turn swap on

 CODE

sudo dphys-swapfile swapon

Reboot the Pi. Issue `free -m` again to confirm swap size has changed.

13.

Install dependencies

Once the boot process has finished, you will need to update the system

 CODE

sudo apt-get update

Next, you need to install the compilation dependency packages

 CODE

sudo apt-get install git automake build-essential libtool autotools-dev autoconf pkg-config libssl-dev libboost-all-dev libminiupnpc-dev

14.

Download DMD wallet v.3.0.13 from GitHub

Navigate to your home directory

 CODE

cd

Clone the DMD wallet into your home folder

 CODE

git clone https://github.com/DMDcoin/Diamond.git

This will create the Diamond folder inside your home directory

15.

Install BerkeleyDB-4.8

Download and compile BDB 4.8 from Oracle

 CODE

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
make
sudo make install

Export paths

 CODE

export BDB_INCLUDE_PATH="/usr/local/BerkeleyDB.4.8/include"
export BDB_LIB_PATH="/usr/local/BerkeleyDB.4.8/lib"

Create symbolic links

 CODE

sudo ln -s /usr/local/BerkeleyDB.4.8/lib/libdb-4.8.so /usr/lib/libdb-4.8.so
sudo ln -s /usr/local/BerkeleyDB.4.8/lib/libdb_cxx-4.8.so /usr/lib/libdb_cxx-4.8.so

credit to trancsitu.wordpress.com

16.

Edit the secp256k1 library

This step is required to avoid some compilation errors

Open configure.ac

 CODE

cd Diamond/src/secp256k1
sudo nano configure.ac

Find the line

 CODE

AM_INIT_AUTOMAKE([foreign])

And make it look like this

 CODE

AM_INIT_AUTOMAKE([foreign subdir-objects])

17.

Compile the wallet

Run autogen.sh (this will take some time, so be patient)

 CODE

cd
cd Diamond
./autogen.sh

Run configure (with custom flags)

 CODE

./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"

Compile

 CODE

make

This runs the GCC compiler. If everything goes smoothly, you should now have a compiled wallet. Note that the process may take many hours, depending on the Pi's memory specs and swapfile size.

18.

Disable the swapfile

After compilation, the swapfile will not be needed anymore, so you can disable it. Leaving it on is not recommended, since successive read/writes can eventually corrupt your SD card.

 CODE

sudo swapoff -a

Reboot the pi

 CODE

sudo reboot

19.

Initiate the wallet

Type

 CODE

cd
cd Diamond/src
./diamondd

You should get the following message `DMD server starting`

You may receive an error message regarding rpcuser and rpcpassword. This is perfectly normal (we will sort this our in step 20).

Since this is the first time the wallet is iniated, the Diamond wallet configuration folder (.DMDV3) will be freshly created with all configuration files inside it.

If the system hasn't exit the daemon automatically, you can now stop it by hitting Control + C, so we can edit the configuration files (full blockchain synching will be performed later).

20.

Edit the config file

Navigate to the .DMDV3 folder

 CODE

cd
cd .DMDV3

Open the diamond.conf file

 CODE

sudo nano diamond.conf

The document should be initially blank. Populate it with the following text

 CODE

rpcuser=DMDUSERNAME
rpcpassword=DMDPASSWORD
rpcport=17772
rpcallowip=127.0.0.1
listen=1
daemon=1
server=1
noirc=1
staking=0
maxconnections=24
addnode=94.100.221.211
addnode=94.130.107.224
addnode=94.130.107.225
addnode=94.130.107.227
addnode=94.130.99.25
addnode=94.177.230.81
addnode=94.197.121.95
addnode=95.18.83.207
addnode=96.37.74.144
addnode=96.38.137.224
addnode=96.39.182.63
addnode=96.39.253.106
addnode=96.60.68.148
addnode=98.146.162.121
addnode=99.192.81.50
addnode=99.21.69.25

Where DMDUSERNAME and DMDPASSWORD can be random characters (or you can use the values suggested in the error message generated in step 19). You do not need to save or store these values, they are only required at wallet runtime.

Exit the file by hitting Control + X (type �y� for saving and then ENTER)

If you need the most recent node list, please check: chainz.cryptoid.info

21.

Synchronize to DMD's blockchain

Run the daemon

 CODE

cd
cd Diamond/src
./diamondd

You should get the message:

 CODE

DMD server starting

Run `top` to verify resources usage

`top`

Find diamondd (diamond daemon) in the table. It should be consuming most of your Pi�s CPU. This is actually expected, since the wallet should now be synchronizing the blockchain.

At this stage, you should wait for the blockchain to be fully downloaded. You will be able to verify this when a dramatic drop in CPU usage happens (from 90% to 5%, for instance). That means the wallet has been fully sync'ed. When that happens, hit Control + Z to exit 'top'.

P.S. The time required for full synchronization depends on your system, internet connection and blockchain size.

22.

Check wallet information and blockchain synchronization status

Check wallet info

 CODE

./diamond-cli getinfo

This will show your wallet general info, including wallet version, total balance, blocksize, etc. If you get an error message, it problably means the wallet is still synchronizing. Wait a few minutes and try again until you get something like this:

 CODE

"version" : 3000013,
"protocolversion" : 70717,
"walletversion" : 61000,
"balance" : 0.00000000,
"mixTX_balance" : 0.00000000,
"blocks" : 18649,
"timeoffset" : 0,
"connections" : 16,
"proxy" : "",
"difficulty" : 17052.66698695,
"testnet" : false,
"keypoololdest" : 1507817040,
"keypoolsize" : 1001,
"paytxfee" : 0.00000000,
"relayfee" : 0.00010000,
"staking status" : "Staking Not Active",
"errors" : ""

23.

Check receiving address

Type

 CODE

./diamond-cli getaddressesbyaccount ""

This will show you the public key (address) generated at wallet creation time.

24.

Double-check the receiving address

Type

 CODE

./diamond-cli validateaddress <ADDRESS>

You should get: `isvalid=true` and `ismine=true` among the results

This informs that the address belongs to your wallet and can be used to receive funds.

25.

Encrypt the wallet

Type

 CODE

./diamond-cli encryptwallet <YOURPASSPHRASE>

This may take a few seconds. Make sure you choose a strong, long passphrase. Be careful to secure the passphrase somewhere safe. If you loose it, you will not be able to open the wallet anymore and all your funds will be lost forever. Note that the encryptwallet parameter will not be available anymore after passphrase creation.

26.

Backup your wallet into your main computer

Check if the blockchain is fully sync'ed, by verifying if the block number matches the latest found here: chainz.cryptoid.info

If you're using the Pi as a desktop computer with monitor and keyboard, all you have to do is copy the wallet.dat file from the .DMDV3 folder into a pendrive and secure it in a safe place.

If using the Pi as headless client with a Mac or Linux main computer, you will use 'scp' to copy files over the network. This software should be previously installed in most Mac and Linux distributions

 CODE

scp USERNAME@ADDRESS:~/.DMDV3/wallet.dat ~/

This will copy wallet.dat to your home folder

If using a Windows PC, first you need to download pscp from the putty homepage: chiark.greenend.org.uk

After installation, you should be able to transfer your wallet file over the network to your main computer

 CODE

pscp USERNAME@ADDRESS:~/.DMDV3/wallet.dat C:\Users\YOURNAME\Downloads\

This will copy wallet.dat to your Downloads folder (make sure you replace YOURNAME by your windows username). Remember to secure the file in a safe place afterwards.

After backup, you can now start transfering funds to you wallet!

27.

Staking

If you wish to stake, you first need to stop the client.

 CODE

./diamond-cli stop

Open the diamond.conf file

 CODE

cd
cd .DMDV3
sudo nano diamond.conf

Change the line `staking=0` to `staking=1`

Exit the file by hitting Control + x (type �y� for saving and then ENTER)

Restart the client and unlock the wallet for staking

 CODE

cd
cd Diamond/src
./diamondd

Wait a few seconds for the wallet to sync.

Unlock the wallet

 CODE

./diamond-cli walletpassphrase YOURPASSPHRASE 600000000

The trailing number is the parameter used for setting the time (in seconds) that the wallet will be unlocked for staking. We usually use a long random number.

28.

Additional wallet commands

You will need to know additional commands to manage your DMD funds. There are 2 different help parameters that can be used to this end. Each will spit out different results, but are all self-informative

 CODE

./diamond-cli help
./diamond-cli --help

If you find this guide helpful, please consider donating to my DMD address: dEDEPoPDcf6RhABkEXttPzzwBX5SMTjiYU

Enjoy your DMDv3 wallet and happy staking!





go top