The Meaning of "Easy"
Writing programs that manipulate money in Bitcoin is easy. However, as we walk through this process, it might not seem very easy to you.
But imagine, instead, if we built our app or service using a traditional e-commerce system. Roughly, here's what those steps would look like:
1. Incorporate your business to receive a DUNS number.
2. Get a corporate account at your bank.
3. Have your account verified by a merchant services provider (Intuit, PayPal, Stripe, Apple, etc.).
4. Set up an account via the provider with your DUNS number to get access keys.
5. Acquire proprietary library software from the provider (you'll probably need to update this library regularly to maintain your software).
6. Redirect your customers to a special provider to authorize payments.
7. Write your code.
8. Have your finished app reviewed by the payment provider.
Here is the main step needed to get a Bitcoin-based, e-commerce system up and running:
1. Write your code.
Having to complete just this one task is what we mean when we use the term easy when programming with Bitcoin.
Three Ways to Write Bitcoin Software
To write Bitcoin-enabled software, you can use three different approaches:
1. Use a merchant service.
2. Connect to a local Bitcoin wallet program (typically the original Bitcoin wallet application based on Satoshi's initial code, named bitcoind).
3. Create a program that inserts itself directly into the Bitcoin network.
Using approach #1, you would connect to a web API over the Internet. That API would be supplied by a third-party company to manage your bit-coins. Companies that supply these APIs for sending and receiving bitcoins are typically called merchant services.
For example, if your website sells widgets and you want people to buy your widgets with bitcoins, using a merchant service may be a simple, no-fuss way to get your website working quickly. An additional benefit of a merchant service is that it may also offer services to automatically convert Bitcoin to/from other currencies as part of a transaction. Many companies supply these APIs, and BitPay is a common choice. But you can find a more extensive list of companies on the official Bitcoin foundation website.
However, this approach has some drawbacks. First, these vendor APIs arguably go against the spirit of Bitcoin, because using an API middleman makes you beholden to an external party; serious Bitcoiners prefer to retain 100 percent control over their money. Second, these APIs are mostly designed only for common use cases, so they don't allow the flexibility and innovative app development that we want to foster with this book. Third, the design of these APIs tends to change frequently, making it difficult to provide you with current information. For these reasons, we won't spend much time discussing vendor APIs in this book.
Bitcoin Core and bitcoind share the same code. This common code is called the Bitcoin reference client, or just Bitcoin. It was the first implementation of the Bitcoin protocol and eventually was split into two variants: Bitcoin Core has a friendly graphical interface (UI), and bitcoind is a more stripped-down version with a text-based interface.
Approach #3 involves going right to the metal and inserting your Bitcoin-enabled program directly into the Bitcoin network. You can do this in languages such as Java, C++, or Go or any language that has a fully implemented Bitcoin client library available. This approach is more robust and less resource-intensive than approach #2, but it is more technically complex.
However, if you're a programmer who believes in the Bitcoin ethos, being able to write an app that is a real first-class citizen in the Bitcoin net-work—a true Bitcoin node participating in the Bitcoin system—is motivating. The reason is that absolutely no limitations restrict what your app can do (as long as your app obeys the rules of the network.) In Appendix B, we'll write some programs that use this approach.