It was 2013 when I first dove into Bitcoin as a (wannabe) developer and since then I hoarded a remarkable amount of websites, articles, readings, threads, mailing lists. Well, it’s been 2 years and I can still see a clear, major bottleneck: we fall extremely short of developer resources. While it may be a matter of pioneering (is it really? we’re far beyond 2009…), when it comes down to investors, politics and philosophy we all agree that Bitcoin is in the spotlight.
Given the above, many enthusiasts out there might not have the tools or the time to join the active side of the community. As of today, reinventing the wheel at times may be as unreasonable as unavoidable.
Around the blockchain
The goal of this series is speeding up the learning process by providing a step-by-step description of the blockchain from a programmer perspective. No in-depth experience is required, I only assume:
- You’re a programmer.
- You know hex system and endianness.
- You’re able to read C code.
- You interacted with Bitcoin at some point (e.g. you paid a product in bitcoins).
Ideally, you’ve had a wallet once in your life and possibly used it to send or receive some coins. You’ve been flooded by hundreds of articles and wikis worshipping the revolutionary nature of the blockchain, but you’ve been curious enough to read past the buzzwords. You may have taken a peek at websites like blockchain.info to gain insight into your own transactions or just for the sake of tasting the hackerish side of the thing. Skip the math behind the mining process, still you know that bitcoins spring out of an algorithm somehow.
Well, that’s how far I expect you to have gone. Meanwhile there’s plenty of wikis and articles explaining way better than me what the blockchain is and why it’s such an awesome discovery by the human being.
Here I’ll cover the Bitcoin transaction system and teach you how to assemble your own transactions. Since the beginning, I’ll draw a path leading you to understanding how the high-level blockchain entities translate to raw bytes. Nuts and bolts, no big deal. I’ll start with a few theoretical concepts to make better sense of the code snippets attached but trust me, I want this series to be practical.
However, this is a beginner course and it’ll take you a little more to get your feet wet with the Bitcoin Core codebase. With this in mind, this is surely a good place to start.
All sample code is written in C language and prefixed with
ex-. To quickly compile a sample on an UNIX-like platform (like Linux, Mac OS X, *BSD), I suggest you use the test.sh bash script after editing it to point to your local OpenSSL headers. Here’s how:
given that you want to compile and execute the code from
ex-sample-name.c. The executable is written to