Bitcoin Adventures

Bitcoin continues its rise.

Bitcoin continues its rise.

I’ve been following the Bitcoin ecosystem for a few years now, and seeing as a coin is now worth well north of 100USD, I decided to finally explore bitcoin wallets and mining under OSX.

What are Bitcoins?

A lot has been written about Bitcoins over the past weeks as they’ve broken the $100/฿ mark. Without ignoring the canonical paper, simply put, Bitcoin is a peer-to-peer anonymous digital currency. An effective analog analog of Bitcoin is paper currency.

Paper currency is (or can be) peer-to-peer and completely anonymous. Possibly the biggest challenge to paper currency, and as we shall see, digital currency is the problem of double-spending. In the case of paper currency, a forgery of currency can lead to double-spending (or multiple-spending). For example, if a genuine bill is duplicated, and both the genuine bill and it’s copy are used to pay for goods or services, the bill is “multiply-spent”. This is why, for example, the US Federal Reserve takes great care to ensure its currency is not duplicated.

In the case of Bitcoin, all transactions are shared publicly in an anonymous, encrypted “blockchain”. When someone “mines” Bitcoins, they are working to build this blockchain by confirming transactions. As a reward for building the blockchain, miners are rewarded ฿25 (at the current difficulty). Those coin are only awarded if the block is completed, for a single miner this could take well over a year on average. Consequently, most miners work in groups to share the risk and reward of mining.

Wallet

A Bitcoin wallet manages your public keys – those that you share with others to receive coin, and your private keys – those which confirm your ownership of those coin, allowing you to spend it.

There are two frontrunners for Bitcoin wallets Electrum and Bitcoin-Qt. If you choose Bitcoin-Qt, you’ll have to download the entire blockchain, which is a hefty 6.6 GB at the last count. Electrum uses a remote server, simplifying its use. I chose Electrum, no complaints other than I wish there was a password prompt before the client could be opened, though I understand there is a prompt before coin can be sent.

Mining

Seeing of course how this was motivated by Bitcoin’s recent surge in value, I set off to investigate mining. There are a number of available miners. Seeing that I’m playing around on OSX and recently since I’ve been investigating OpenCL in Python, after a bit of search I settled with poclbm.

Installing Poclbm

Poclbm has a few dependencies

First install mako and pyserial using PIP

1
2
pip install mako
pip install pyserial

Then, install python-opencl by

1
2
3
4
5
6
7
git clone http://git.tiker.net/trees/pyopencl.git 
cd pyopencl/
git submodule init
git submodule update 
python configure.py 
make
sudo make install

jansson from homebrew

1
brew install jansson

Finally pull down the most recent poclbm from github.

1
git clone git://github.com/m0mchil/poclbm.git

Since mining individually earns on average a block every year. To try to amortize my mining rewards, I then registered a pool account at mining.bitcoin.cz (other alternatives include btcguild.com).

Now of course using OpenCL under OSX is a little wonky and I couldn’t get the GPU in my laptop to kick in. So with my i7 alone I get around 5MH/s. Now, 5MH/s is not (not not) very much computing power and according to this calculator, at the current difficulty (about 10M) I should be mining on average around ฿0.0002 per day. At the current exchange rate, that’s maybe $0.03 per day. If my laptop draws 50W when mining, and I pay $0.07 per kW*hr, each day it costs me $0.084 each day to run my laptop. So… bitcoin mining on my laptop is a net loss of about $0.05 per day. This wasn’t surprising.. remember this is an experiment!

Where to go from here?

It seems that the mining landscape is gonna completely change with the introduction of ASIC miners which boast multiple gigahash per second. However, the availability of these miners are spotty at best. FPGA mining is intriguing but, with similar hash performance their only advantage is dramatically lower power consumption. Another downside is FPGA mining hardware is most likely specialized, and when they’re eventually obsoleted by ASICs their resale value may be limited. That said, I do have several FPGA development platforms, it would be great to get them up and running. And then, maybe look into making an ASIC of my own.. Until then, GPUs it is.