Compile your VPS MN from sources

Compiling an PowerSwitch daemon from source

In this guide, we will compile a PowerSwitch deamon from its Github sources (Linux).

If you want to run an PowerSwitch Masternode, you could in theory use a regular QT-version of the wallet (the version with a user interface). But that would be pretty useless, since there is nothing to 'see'.

Most people run their masternode on a (Linux-based) Virtual Private Server (VPS), which has no graphical user interface, just a command-line interface.

So, we'll need a headless (=no user interface) version of the wallet and run it as a daemon (=background) process.

1. Prepare your environment

To compile the daemon, you will need :

  • A development environment;

  • The PowerSwitch sources;

  • The Boost library;

  • The Berkely DB 4.2 Database library (for the wallet file);

  • The MiniUPnP library (to use uPnP);

  • The GMP library;

  • The OpenSSL library.

1.1 Prepare your system for compiling c++ sources

To build the sources, we will need some development tools :

$ sudo apt-get update -y
$ sudo apt-get upgrade -y
$ sudo apt-get install -y build-essential libtool autotools-dev pkg-config libdb5.3++ autoconf automake libqt4-dev  software-properties-common

Also, we need Git to get the sources from Github :

$ sudo apt-get install git

We need libsecp256k1 to run PowerSwitch, let’s download it and compile it :

$ git clone
$ cd ~/secp256k1
$ ./
$ ./configure
$ make
$ ./tests
$ sudo make install

1.2 Download the sources

Create a folder to download the sources to, eg '~\sources' and download the sources from GIT :

$ cd ~
$ mkdir sources
$ cd sources
$ git clone

This will give you an PowerSwitch directory within the sources.

1.3 Install Boost

To install the Boost library libboost, the following should be enough

$ sudo apt-get install libboost-all-dev

1.4 Install Berkely DB 4.8

BerkeleyDB is required for the wallet.

Ubuntu and Debian have their own libdb-dev and libdb++-dev packages, but these will install BerkeleyDB 5.1 or later, which break binary wallet compatibility with the distributed executables which are based on BerkeleyDB 4.8.

For Ubuntu only: db4.8 packages are available here. You can add the repository and install using the following commands :

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:bitcoin/bitcoin
$ sudo apt-get update
$ sudo apt-get install libdb4.8-dev libdb4.8++-dev

1.5 Install MiniUPnP

$ sudo apt-get install libminiupnpc-dev

1.6 Install GMP

$ sudo apt-get install libgmp-dev

1.7 Install openSSL

$ sudo apt-get install libssl-dev openssl

2. Compile the sources

Now, we're ready to compile the sources.

2.1 Use make to compile

There is a Makefile (makefile.unix) to build a headless version :

$ cd ~/sources/Wallet/src
$ sudo make -f makefile.unix 

This might take quite some time. But if all goes well, you'll end up with an PowerSwitchd file in your directory.

If you get errors, see the FAQ below.

2.1 strip the executable

It will be quite a big file but you can strip unnecessary symbols from it with 'strip' command. It will become about 5MB then.

$ strip PowerSwitchd

3. Install the deamon

Congratulations, you have a personally-compiled the PowerSwitchd daemon for your system !

Finally, copy the file to a folder that's on your PATH, e.g. /usr/local/bin :

$ sudo cp PowerSwitchd /usr/local/bin

4. Use it

From now on, you can start the deamon process as follows:

To start the deamon process :

$ PowerSwitchd -daemon

To stop the deamon process :

$ PowerSwitchd stop

To interact with it :

$ PowerSwitchd getinfo
    "version" : "v1.1.0.1-60030",
    "blocks"  : 13783,

Frequently Asked Questions

FAQ 1: I get an error virtual memory exhausted: Cannot allocate memory

you don't have enough physical memory to compile. Adding a swap file usually helps.

run these commands as ROOT user to add some swap and retry compilation step.

fallocate -l 4G /swap 
chmod 600 /swap 
mkswap /swap 
swapon /swap 
echo "/swap none swap sw 0 0" >> /etc/fstabfallocate -l 4G /swap 
chmod 600 /swap