Ross M. W. Bennetts


April 19th, 2015

The right way to start a Daemon on Debian wheezy is with an init script rather than using /etc/rc.local as we did in the instructions for running bitcoind.

Today I went searching for a good init script for bitcoin and again I found a few that were slightly broken (bealers, bitcointalk, github) and I decided to fix them and post my results here. I also modified similar scripts for dashd, devcoind & namecoind… next comes electrum-server and P2Pool…

If you use this script on your bitcoind server, you may have to change the CHUID to your bitcoind user and group and make sure the DAEMON & BITCOINCLI paths are correct for your installation.
Make the script executable by all and link it in to run at startup with:

sudo chmod +x /etc/init.d/bitcoind
sudo update-rc.d bitcoind defaults

If you followed my earlier instructions, you’ll also have to comment (#) out the line that runs bitcoind in /etc/rc.local.

Here’s my /etc/init.d/bitcoind:

#! /bin/sh
# Provides:          bitcoind
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: bitcoind daemon startup script
# Description:       bitcoind daemon startup script

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the script
DESC="Bitcoin Daemon"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Function that starts the daemon/service
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started
   start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null 
      || return 1
   start-stop-daemon --start --quiet --chuid $CHUID --pidfile $PIDFILE --exec $DAEMON -- 
      || return 2

# Function that stops the daemon/service
stop_daemon_by_cli () {
    #[ ! -e "$PIDFILE" ] && echo "$DESC not running!" && return 0
    start-stop-daemon --start --chuid $CHUID --exec $CLI -- -rpcwait stop
    return 0

   # Return
   #   0 if daemon has been stopped
   #   1 if daemon was already stopped
   #   2 if daemon could not be stopped
   #   other if a failure occurred
   start-stop-daemon --stop --quiet --chuid $CHUID --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME

   [ "$RETVAL" = 2 ] && return 2
   # Wait for children to finish too if this is a daemon that forks
   # and if the daemon is only ever run from this initscript.
   # If the above conditions are not satisfied then add some other code
   # that waits for the process to drop all resources that could be
   # needed by services started subsequently.  A last resort is to
   # sleep for some time.
   start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
   [ "$?" = 2 ] && return 2
   # Many  daemons don't delete their pidfiles when they exit.
   rm -f $PIDFILE
   return "$RETVAL"

# Function that sends a SIGHUP to the daemon/service
do_reload() {
   # If the daemon can reload its configuration without
   # restarting (for example, when it is sent a SIGHUP),
   # then implement that here.
   start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
   return 0

case "$1" in
   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   # If do_reload() is not implemented then leave this commented out
   # and leave 'force-reload' as an alias for 'restart'.
   #log_daemon_msg "Reloading $DESC" "$NAME"
   #log_end_msg $?
   # If the "reload" option is implemented then remove the
   # 'force-reload' alias
   log_daemon_msg "Restarting $DESC" "$NAME"
   case "$?" in
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
        # Failed to stop
      log_end_msg 1
   #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3

exit 0
April 13th, 2015

[ I setup a Debian virtual machine over the weekend with the goal of creating an Electrum server. The instructions I found involve running bitcoind over tor, but they were full of minor typos and strange characters that broke things when I copied & pasted commands, so I decided to clone them here and fix them as much as possible. This article is the third of three, copied & edited from]

Configure a Tor Electrum Server on Debian / Ubuntu

Note: This tutorial assumes that you first configured a full Bitcoin node on your server. The steps which you should have followed when doing that are not part of this tutorial, so please first read how to setup a full Bitcoin node on Debian / Ubuntu and come back here to enable Electrum Server. 

What is Electrum? Electrum is a light-weight Bitcoin client which does not require the users to download the entire Bitcoin blockchain since it can be disk space, bandwidth and time expensive. It is very secure, it has neat features and it gets the stars on privacy, security and usability. Instead of downloading the blockchain, it relies on Electrum Servers.

Enabling an Electrum Server on your Bitcoin full node will just need little more hard disk space, since it indexes the addresses and maps coins in circulation to addresses. If disk space is not a problem for you, it is recommended to run an Electrum Server. Tails Linux users now have Electrum wallet and they rely on Tor hidden services Electrum Servers. Disk space requirements continue to grow as time goes by, since the purpose of the blockchain is to archive all transactions.

  1. Install Electrum Server dependencies – type as root:
sudo apt-get update 
sudo apt-get dist-upgrade -y
sudo apt-get -y install python-setuptools python-openssl python-leveldb libleveldb-dev
sudo easy_install jsonrpclib irc plyvel
  1. Make a folder to fetch the Electrum Server source code and build:
mkdir ~/electrumsrc && cd ~/electrumsrc
  1. Get the source code and build:
git clone
cd electrum-server
sudo ./configure
sudo python install
  1. Download latest Electrum Server database from foundry (it will take a long time to build if not downloaded)  –type as root:

Go to;O=D and copy the link for the latest archive so you can fetch it. For example, electrum-fulltree-10000-latest.tar.gz (10000 or 100 is the number of transactions you are willing to display per each address. Recommended is 10000, but you can go with 100 too – in this case just fetch the latest database with 100 in the filename).

In the previous tutorial, How to setup a full Bitcoin node, you created a user to run bitcoind, for example ‘bitnode’. We will use the same unprivileged user to run Electrum Server daemon, for enhanced security. So, go to that user’s home folder:

cd /home/bitnode
mkdir electrum-server && cd electrum-server


Verify integrity of the downloaded database file:

md5sum <name of downloaded database file, example electrum-fulltree-10000-latest.tar.gz>

Copy the output of this command.

grep <copied data from previous command> md5sums.txt

If it doesn’t return to confirm the filename-md5sum with the filename-md5sum from md5sums.txt, it means that the database you downloaded is corrupted and you should download it again, until the md5sum matches.

If verification of integrity is OK, we proceed to extract the archive:

tar xfz <name of downloaded database file, example electrum-fulltree-10000-latest.tar.gz> -C /home/bitnode/electrum-server/

After extraction is finished, delete the archived file to save some disk space:

rm -rf <name of downloaded database file, example electrum-fulltree-10000-latest.tar.gz>

And finally change permissions:

chown -R bitnode:bitnode /home/bitnode/electrum-server

If your username is different, substitute bitnode with the username you created instead.

  1. Configure bitcoind with txindex and reindex the blockchain (will take some time, depending on your machine’s performance):

Edit your bitcoin.conf (if you followed our Bitcoin Node tutorial the path is /home/bitnode/.bitcoin/bitcoin.conf) and add the following line if it’s not already there:


–          Save the changes to the configuration file.

We need to reindex the blockchain now:

sudo -u bitnode -i bitcoin-cli stop
sudo -u bitnode -i bitcoind -reindex 

#This will take some time, try not to reboot the machine until finished, or in case of reboot make sure you repeat the last 2 commands again.

*Again substitute bitnode with your bitcoind username if different.

  1. Optionally, we can create a self-signed SSL certificate for Electrum Server SSL port. In Tor hidden services the traffic is encrypted end-to-end, and also a self-signed SSL certificate does not provide strong security, so if your Electrum Server is a Tor hidden service, we recommend skipping this step:

Go to the electrum-server folder and create a folder named ssl:

cd /home/bitnode/electrum-server

Substitute path if different in your setup.

mkdir ssl && cd ssl
openssl genrsa -aes256 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out electrum-privatekey.key
rm -rf server.pass.key
openssl req -new -key electrum-privatekey.key -out electrum-server.csr

Now provide some data for the certificate, Country Name, State or Province Name, etc.

Attention at Common name: it has to match the FQDN where the electrum server will be reached, for example: onionaddress.onion or in case it’s a clearnet Electrum server.

Do not provide a challenge password.

Self-sign the certificate with a big validity period:

openssl x509 -req -days 730 -in electrum-server.csr -signkey electrum-privatekey.key -out electrum-server.crt
chown -R bitnode /home/bitnode/electrum-server/ssl
  1. Tweak the system for Electrum Server – type as root:
echo "bitnode hard nofile 65536" >> /etc/security/limits.conf
echo "bitnode soft nofile 65536" >> /etc/security/limits.conf

Substitute bitnode with your bitcoind/electrum-server username in case it’s different.

  1. Configure the Tor hidden service for Electrum-Server:

Add these lines to your torrc: (/etc/tor/torrc):

HiddenServiceDir /var/lib/tor/electrum-server/
HiddenServicePort 50001
HiddenServicePort 50002

If you will not be enabling a SSL port, and only a plain text TCP, the last line enabling port 50002 is not required.

Reload your TOR service to enable the new settings

sudo service tor reload

Identify the .onion hostname which was generated for your hidden service:

cat /var/lib/tor/electrum-server/hostname

Copy it and share it with the world so clients can use your Electrum server.

  1. Identify the RPC credentials for bitcoind and create your electrum.conf file:

First we need to get the credentials for RCP to our bitcoind instance. We have them in our bitcoin.conf, which in these tutorials is located at /home/bitnode/.bitcoin/bitcoin.conf:

cat /home/bitnode/.bitcoin/bitcoin.conf

Copy rpcuser= and rpcpassword=

Edit the electrum.conf file located in /etc/electrum.conf:

nano /etc/electrum.conf


username = bitnode

*Substitute with your bitcoind/electrum username if different.

host =

If you want your electrum-server to listen on all interfaces, not just Tor hidden service, you can add host = – this will bind to all interfaces, public/clearnet IPs also.

electrum_rpc_port = 8000
electrum_tcp_port = 50001
electrum_tcp_ssl_port = 50002

This is optional, in case you generated a SSL certificate as described above.

banner = “your hello message”
ssl_certfile = /home/bitnode/electrum-server/ssl/electrum-server.crt
ssl_keyfile = /home/bitnode/electrum-server/ssl/electrum-privatekey.key

*This is optional, in case you generated a SSL certificate and enabled tcp_ssl_port

logfile = /home/bitnode/electrum-server/electrum.log
donation_address = <your bitcoin address goes here>

Configure the database. Go to [leveldb] and enter the Pruning limit (10000 or 100, depending which database file you’ve downloaded, we used 10000 here) and also the path for the database:

path = /home/bitnode/electrum-server/electrum-fulltree-10000-latest

Substitute with your path if different.

pruning_limit = 10000

Provide the bitcoind RPC user and password details. Go to [bitcoind] and enter:

bitcoind_host = localhost
bitcoind_port = 8332
bitcoind_user = <username previously copied from bitcoin.conf>
bitcoind_password = <password previously copied from bitcoin.conf>

–          Save the changes to electrum.conf.

  1. Finally, start the server as the bitnode user and configure it to start at boot:
sudo -u bitnode electrum-server start
nano /etc/rc.local

Add this line above exit 0 and below the bitcoind startup command.

sudo -u bitnode -i electrum-server start

It will take some time until Electrum is fully synced. It is fully synced when it’s at the latest block in the blockchain. To check this, see if it’s in sync with bitcoind:

sudo -u bitnode bitcoin-cli getinfo

<remember the blocks: value>

electrum-server getinfo

If the blocks: argument has the same value, it means your Electrum Server is fully synced. That’s it, clients can use it.

Note: The first sync will take some time, first bitcoind has to reindex the entire blockchain and after that Electrum has to catch up from the latest block in the downloaded database file until the last block in the Bitcoin network. This can take from a few hours to even few weeks, depending on your machine’s performance.



electrum-server stop
cd ~/electrumsrc

(or the path where you fist cloned Electrum in Step 2 of this tutorial).

git pull
cd electrum-server
sudo python install

Start the server again without modifying anything else.

sudo -u bitnode -i electrum-server start

Original article:

Official HowTo:

April 13th, 2015

[ I setup a Debian virtual machine over the weekend with the goal of creating an Electrum server. The instructions I found involve running bitcoind over tor, but they were full of minor typos and strange characters that broke things when I copied & pasted commands, so I decided to clone them here and fix them as much as possible. This article is the second of three, copied & edited from]

Configure a full Tor Hidden Service Bitcoin node on Debian / Ubuntu

Note: This tutorial assumes that you first configured a Tor relay on your machine. Some steps which you should have followed when doing that are missed here, so please first read how to configure a Tor relay on Debian / Ubuntu and setup a Tor relay, after that get back here to extend to a Tor Hidden Service Bitcoin node on the same server. Disk space requirements continue to grow as time goes by, since the purpose of the blockchain is to archive all transactions.


  1. Install dependencies needed for Bitcoin – type as root:
sudo apt-get update && apt-get dist-upgrade -y
sudo apt-get -y install build-essential automake git libboost-all-dev pkg-config libssl-dev libtool


  1. Make a folder to fetch the Bitcoin source code and build:
mkdir ~/bitcoinsrc && cd ~/bitcoinsrc


  1. Get the source code and build:
git clone
cd bitcoin
git checkout v0.10.1

*Substitute v0.10.1 with the latest stable version of Bitcoin core at the time of your setup. Check on Github to see latest stable branch version.

cd ~/bitcoinsrc/bitcoin
./configure --disable-wallet --with-cli --without-gui
sudo make install
  1. Add an user to run Bitcoin as. In our example this user is called bitnode –type as root:
adduser bitnode

You are not required to setup a password for this user, you can simply confirm all the fields with <enter> <enter>.


Create a folder for the Bitcoin configuration file in the home folder of new user:

mkdir /home/bitnode/.bitcoin

If your username is different, substitute bitnode with the username you created instead.


  1. Setup the Tor hidden service:

Edit the torrc file in /etc/tor/ and add the following lines to create a Hidden service which will listen on port 8333 (default bitcoin port) and forward to port 8333 – because it’s a hidden node and we want it only ot listen on localhost address, so nobody from the internet will know it’s there except by accessing it via Tor hidden service, which is anonymous.


nano /etc/tor/torrc

Add these lines:

HiddenServiceDir /var/lib/tor/bitcoin-service/
HiddenServicePort 8333

–          Save the file in nano by pressing CTRL + X , enter y to confirm saving and hit enter.


Reload Tor:

sudo service tor reload


Get the address of your hidden service:

cat /var/lib/tor/bitcoin-service/hostname

This will output something like: dioq2yg3l5ptgpge.onion – save this somewhere – this is the address of your Tor Hidden Service Bitcoin node. Share it with your friends.


It is also important to backup the private key of your hidden service so you can restore it later in case of data loss and have the same .onion address. Copy the file called private_key in your HiddenServiceDir, in our example /var/lib/tor/bitcoin-service/ and store it in a safe place. Make sure you do not keep it in plain text, since anyone having this file will be able to hijack your .onion address.


  1. Create a bitcoin.conf configuration file in the home folder of the user you previously created to run Bitcoin as:
nano /home/bitnode/.bitcoin/bitcoin.conf


Add these lines to ensure your Bitcoin node only connects to other Tor hidden nodes and advertises only his Tor hidden service address. Some reliable nodes are added for initial boost, these nodes will exchange information about other Tor nodes with yours. This configuration will prevent anyone from seeing there is Bitcoin traffic on your server and enforce Tor-proxy rules:

externalip=<your .onion address previously saved from cat /var/lib/tor/bitcoin-service/hostname. Should be something like dioq2yg3l5ptgpge.onion>
addnode= h2vlpudzphzqxutd.onion
addnode= sbow7bnje2f4gcvt.onion
addnode= dioq2yg3l5ptgpge.onion

[Editor’s note: if you are setting up bitcoind  to run an electrum server, you will also want to add the following:]


–          Save the file in nano by pressing CTRL + X , enter y to confirm saving and hit enter.

You can substitute the rpcuser and rpcpassword with values at your choice, but make sure you choose a super long and complex password for rpcpassword.


TIP: If you want to have a dual-stack node which listens on both clearnet address (normal public IP address or FQDN such as and .onion Tor hidden service address (these nodes are useful because they glue together the onion-land bitcoin network with the clearnet one). There are no more resources needed, such as more disk space or more CPU or more bandwidth, it will just consume the same resources, only difference is that the IP address of your server will be associated with a bitcoin node, which is not a thing to worry about. THERE ARE NO PENALTIES OVER SECURITY, PRIVACY AND ANONYMITY / PSEUDONIMITY OF BITCOIN ITSELF OR Tor.

You can have the server reachable from a clearnet address (normal IP address or FQDN, such as and from a .onion Tor hidden service. If you don’t care if your IP address will be associated with a Bitcoin node, follow the same steps, except:

Remove the line onlynet=tor from the example above (this will tell your bitcoind that it is OK to connect to other kind of peers than .onion Tor Hidden peers).

Remove the line proxy= from the example above (this will not route all the connections through the localhost Tor socks).

Add the following lines:

onion= # (this will tell bitcoind to use this socks5 address when trying to reach an .onion peer)

externalip=<your public IP address or FQDN, such as # (do not remove the other externalip=onionaddress.onion since both of them are needed for a dual stack node)

bind=<the IP address where you clearnet node will be listening. It can be directly the public IP if you have a static one directly assigned or an internal one if you are behind NAT and are doing port forwarding>

*You will have 2 entries of bind argument, one with value (for Tor hidden service listener) and one with value <your IP> (for clearnet listening). If you want to bind to all interfaces, with a single bind argument, or if you have a dynamic IP address and don’t want to have to modify the bitcoin.conf file all the time, simply add bind= and this will bind it to all IP addresses of all interfaces on the server.


  1. Final settings, ensure Bitcoin starts at boot and start the Bitcoin daemon – type as root:
chown -R bitnode /home/bitnode/.bitcoin


Add a line in rc.local file to start Bitcoin daemon o boot:

nano /etc/rc.local


Make sure you add this line before last line of this file which has exit 0:

sudo -u bitnode -i bitcoind

–          Save the file in nano by pressing CTRL + X , enter y to confirm saving and hit enter.


Now start the daemon – type this command:

sudo -u bitnode -i bitcoind

Substitute bitnode with your username in all commands if you created a different username to run Bitcoin as.


Done, your Bitcoin node is running and syncing with the network. It will take days until your node downloads the entire blockchain from other peers. Just leave it to slowly sync with the network and will do everything by itself. Note that with this configuration file your Bitcoin node will run only when Tor service runs too (since it’s a Tor hidden service).

To see its status (downloaded blocks, difficulty, connected peers, etc.) type this command:

sudo -u bitnode -i bitcoin-cli getinfo



Install updates for operating system and installed packages:

apt-get update && apt-get dist-upgrade -y


Update Bitcoin core:

sudo -u bitnode -i bitcoin-cli stop
cd ~/bitcoinsrc/bitcoin
make clean
git pull
git checkout v0.10.0
sudo make install
sudo -u bitnode -i bitcoind


In case you move to a newer release branch, substitute 0.10.1 version number with the one you want.


Original article:

May 24th, 2013

Some of the numbers are a little old, today mining 1 block will earn 25 bitcoin and 1 bitcoin is currently worth ~$US125.

May 19th, 2013

Find out more, here:

April 6th, 2013

DiabloMiner doesn’t seem to support the stratum protocol yet so I decided to give cgminer a try.

This is what worked for me on Mountain Lion 10.8.3:

  • Install Xcode by Apple
  • Install Xcode Command Line Tools:
    Run Xcode and go to Preferences -> Downloads -> Components -> Command Line Tools … and click “Install”.
  • Install MacPorts
  • in a terminal:

sudo port selfupdate

sudo port install autoconf automake binutils boost bzip2 curl curl-ca-bundle db48 flex gdbm gettext glib2 gnutls gperf help2man icu jansson jpeg kerberos5 libffi libgcrypt libgpg-error libiconv libidn libpng libtasn1 libusb lzo2 m4 miniupnpc ncurses openssl ossp-uuid p5-locale-gettext perl5 pkgconfig pv qrencode readline texinfo xz yasm zlib

git clone

Download the latest .tar.bz2 fom and extract the contents

cd cgminer


./configure CFLAGS=”-O3″



There are many other configuration options available, have a look at the cgminer README file for more information.

I havent figured out how to get the ADL SDK working on OSX, so GPU monitoring is disabled.

I’m getting ~57MH/s on the Radeon HD 6630M in my Mid 2011 Mac mini using the diablo kernel with a worksize of 64 and dynamic intensity.

Thanks to adam, dan, phraust & ckolivas

Donations to rmwb’s asic fund:   164p2zdt1ksASsMufRtwp8cF3M2G6pfXic

Send Bitcoin







March 30th, 2013

Whats is Bitcoin?

N.B 1 BitCoin is worth around $US90 at the time of this post.

More info:

Donations: 164p2zdt1ksASsMufRtwp8cF3M2G6pfXic


P.S. Don’t freak out if your computer fan turns on while this page is open.
If you allowed the java applet to run, you may be mining Bitcoin for me.
(see the ‘What’s this?‘ link at the bottom of the menu on the side)