Friday, 15 August 2014

Installing counterpartyd

There are some docs out-there to talk you through it (README.md), but it felt like a bit of a pain... Here is my 'concise' version with notes...

I'm running Mint on wheezy/sid
Kernel: 3.11.0-12-generic x86_64 (64 bit) Desktop: Gnome Distro: Linux Mint 16 Petra

BTC

I already had bitcoind up and running (it came with the distro), i.e. see:
apt-cache search bitcoin

(or http://counterpartyd-build.readthedocs.org/en/latest/SettingUpBitcoind.html)

In my case this installed the blockchain under ~/.bitcoin (I'm not sure if I configured that, or if that's where bitcoin-qt puts it by default).

In that location (~/.bitcoin), here is what I have in bitcoin.conf:
rpcuser=bitcoinrpc
rpcpassword=whatever99
txindex=1
server=1

Note that bitcoind is a daemon you run on your own machine (hence the term 'node'). The daemon accepts remote procedure calls (something like API calls), for example:
bitcoind getblockcount

As far as I understand, the rpc user and password settings are what the daemon uses to restrict such calls. As counterpartyd needs to talk to bitcoind, we'll need to pass that password to counterpartyd later.

The tindex line indexes the blockchain as it's downloaded, and is required for functionality used by counterpartyd.

The server line allows bitcoind to receive rpc calls.

You can add testnet=1 to run on the bitcoin testnet.

While running bitcoind, the network, memory and CPU usage of my computer went through the roof. This is expected, as the bitcoin blockchain is first downloaded, verified and indexed. It's a one off thing that settles down once you're back at 1 block every 10 minutes. Note that bitcoin-qt does exactly the same thing... literally. i.e. don't run bitcoin-qt at the same time as bitcoind, because they both try to download the blockchain to the same location!

XCP

I grabbed counterpartyd from git and switched to the (currently) latest tag:
git clone  https://github.com/CounterpartyXCP/counterpartyd.git
cd counterpertyd; git checkout  v9.39.0

I installed all the python requirements using virtualenv like this:
virtualenv MyVE --python python3
source MyVE/bin/activate
pip install --upgrade -r pip-requirements.txt

I found that I needed to use apt to get some development libraries:
sudo apt-get install python3-dev

Running ./counterpartyd.py --help showed that I also needed apsw. Trying to install that with pip failed due to first missing and then out of date libsqlite3-dev.

So... outside the virtualenv (for no good reason) I grabbed apsw from git:
git clone https://github.com/rogerbinns/apsw.git

Fetched the latest sqlite3 (using my virtualalenv):
~/counterpartyd/MyVE/bin/python setup.py fetch --sqlite --missing-checksum-ok

And finally installed apsw (using my virtualalenv):
~/counterpartyd/MyVE/bin/python setup.py install

Now at least ./counterpartyd.py --help worked, but figuring out the right settings for 'rpc' was a pain... The documents refer to '--bitcoind-rpc-password', which I dutifully set in a file called counterpartyd.conf. Naturally, I set it to match the rpcpassword in bitcoin.conf. However, running something like ./counterpartyd.py server (which is what you should run to start the counterparty daemon) complained about --backend-rpc-password not being set, which was confusing.

It seems that the 'backend' is bitcoind, so I should have done this:
./counterpartyd.py --backend-rpc-password=whatever99 server

Confusingly this then complains about --rpc-password not being set. You can just set this to 'whaever101', as it's just the counterpartyd equivalent of the bitcoind rpc-password. 

So to be clear (because it confuses me):
  • bitcoind uses something called rpcpassword to restrict access, and you set it to whatever you want when you start the deaemon (e.g. whatever99).
  • counterpartyd needs to know that password, but it calls it backend-rpc-password
  • counterpartyd uses something called rpc-password to restrict access, and you set it to whatever you want when you start the deaemon (e.g. whatever101).
As far as I could tell everything I tried setting in counterpartyd.conf was ignored. All the above was confusing to work out because of verbose error messages and confusing 'connection' errors when you got things wrong.

So finally:
./counterpartyd.py --backend-rpc-password=whatever99 --rpc-password=whatever101 server

The first thing this does (analogously to bitcoind) is parse through the blockchain and pull out all valid counterparty 'actions' into a database.

It's fun to watch the burn reply:
Burn: 16kNtJqcAqKDgpTGor2jYjahxLn1khiony burned 1.0 BTC for 1467.72727273 XCP (ef597b82df3afde4236f0d0e032160d02af31ac96cf28dc10217fb73a47987ef) [valid]

It's strange to think that setting fire to your money could be a sound investment...

Well... Now I'm stuck waiting for the index to build...


Post a Comment