Crypto Currency (Bitcoin/Litecoin) on a Pi


7 posts
by bitguy » Sat May 18, 2013 7:50 pm
How to install the bitcoin daemon on a Raspberry Pi (also works for litecoin, feathercoin, etc...)

-----------------------------------------------------------------------------------
IMPORTANT NOTES:

a line starting -- is a comment, just read it.
a line starting > is a command, just type it and press "Enter".

This will work on a Raspberry Pi Model B with 256 Mb of RAM.

The current bitcoin blockchain is about 9Gb.
Make sure that you have enough room on either your sd-card or an attached device to hold this file.
Remember it is only going to get bigger!

This also works for any of the bitcoin based crypto-currencies, simply change the git url and navigate to the relevant directory.

!!!!SECURITY!!!!
If you are running this as a daemon, permanently connected to the internet make sure that you install and configure iptables and fail2ban at the very least. It is also wise to setup SSL for RPC connections.

-----------------------------------------------------------------------------------
OBTAINING AND COMPILING THE BITCOIN CLIENT

-- Update all existing software on the Pi
> sudo apt-get update
> sudo apt-get upgrade

-- Install the prerequisites required for compilation
> sudo apt-get install checkinstall subversion git git-core build-essential
> sudo apt-get install libssl-dev libdb++-dev libminiupnpc-dev
> sudo apt-get install libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev

-- Go to your home directory
> cd ~

-- Obtain a copy of the latest version of the bitcoin client
> git clone git://github.com/bitcoin/bitcoin.git

-- We need a large swap file for this to work, the temp files can easily get to 500Gb.
> sudo nano /etc/dphys-swapfile
-- Modify the line to change the setting from 100Mb to 500Mb.
-- change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=500

-- Exit from nano
> ctrl-o
> enter
> ctrl-x

-- Reset the swapfile to implement the new size or just reboot, probably safest to just reboot.
> sudo dphys-swapfile setup
> sudo dphys-swapfile swapoff
> sudo dphys-swapfile swapon

-- To check all is OK run the free command.
> free
-- Check that the swap total is ~500000

-- Navigate to your downloaded bitcoin source files
> cd ~/bitcoin/src

-- Compile it! This will take a looooooonnnnnggg time. Mainly because your swap is on the sdcard and it is slooooowwwwww.
-- Seriously, I sanded and washed down the skirting and doors in a bedroom, then had lunch, then painted it in the time it took to compile.
> sudo make -f makefile.unix

-- Make it smaller by removing unneeded assemblies and what not.
> strip --strip-unneeded bitcoind

-- Run it!
> ./bitcoind -daemon

-----------------------------------------------------------------------------------
CONFIGURING THE DAEMON

-- Use the information located at https://en.bitcoin.it/wiki/Running_bitcoind and follow the instructions!

-----------------------------------------------------------------------------------
-- Whilst compiling you can open a separate shell and use the "free" command to monitor the memory usage.

-- You can use the compilation for temperature benchmarking by entering the following command in a new shell.
> /opt/vc/bin/vcgencmd measure_temp

BTC: 18HQQv1rmEkByDWNi8UMWf2FLd9DvQ3ryg
Posts: 3
Joined: Sat May 18, 2013 7:31 pm
by bitguy » Sun May 19, 2013 11:35 am
UPDATE FOR LITECOIN:

You may receive this error message:

"An error occured while setting up the RPC port 9332 for listening: open: Address family not supported by protocol."

This is because litecoin needs IPv6 enabled.

To test this is the problem you can manually load the ipv6 module by typing
> sudo modprobe ipv6
and then restarting litecoin.

To permanently fix this error you need to modify the boot-time modules:
> sudo nano /etc/modules
Add the line "ipv6" without the quotes to the end of the file and restart the Pi.

I have also been asked how to view what the client is doing. To monitor the client directly rather than by RPC use the command:
> ./litecoind -printtoconsole


------------------------------------------------------------------------------------------------------------------
BTC: 18HQQv1rmEkByDWNi8UMWf2FLd9DvQ3ryg
Posts: 3
Joined: Sat May 18, 2013 7:31 pm
by fulltimedreamer » Mon May 20, 2013 7:23 am
Could you show us the hashrate for both BTC and LTC?
Posts: 1
Joined: Mon May 20, 2013 7:20 am
by bitguy » Tue May 21, 2013 3:19 pm
I haven't got Bitcoin installed on a Pi anymore because I took it off to play with Litecoin.

I have just tested Litecoin and I get a grand total of ~56 hashes per second or 0.056Kh/s.

I was thinking more of using the Pi as a secure, portable wallet.
Posts: 3
Joined: Sat May 18, 2013 7:31 pm
by marked » Fri May 24, 2013 3:49 pm
for litecoin, cpuminer-2.2.3 gets approx 0.39khash/s with overclock of the cpu at 900Mhz

though today it appears to be running slightly higher...
[2013-05-24 16:41:49] thread 0: 15231 hashes, 0.45 khash/s
[2013-05-24 16:42:11] LONGPOLL detected new block
[2013-05-24 16:42:11] thread 0: 9990 hashes, 0.45 khash/s
[2013-05-24 16:43:11] thread 0: 27244 hashes, 0.45 khash/s
[2013-05-24 16:43:13] thread 0: 945 hashes, 0.45 khash/s
[2013-05-24 16:43:13] accepted: 3972/4051 (98.05%), 0.45 khash/s (yay!!!)
[2013-05-24 16:44:12] thread 0: 26388 hashes, 0.45 khash/s

http://sourceforge.net/projects/cpuminer/files/pooler-cpuminer-2.2.3.tar.gz

currently that is generating at a rate of about 0.0009 ltc a day.

marked
Posts: 54
Joined: Fri Jul 29, 2011 4:25 pm
by merlz42 » Wed May 29, 2013 11:25 am
The pi does just over 300 khash/s for bitcoin on CPU (from memory). I have some ideas and shader code for doing it on GPU, but no time at the moment to write up a client and see how fast it is.
Posts: 20
Joined: Sun May 13, 2012 1:19 pm
by scruss » Wed May 29, 2013 11:34 am
You might get very slightly faster results if you enable the SoC's hardware random number generator. It might not make a noticeable difference.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
User avatar
Posts: 284
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON