Book Image

Learning Bitcoin

Book Image

Learning Bitcoin

Overview of this book

Table of Contents (16 chapters)
Learning Bitcoin
About the Author
About the Reviewers


Bitcoin is truly a new kind of money. As an open network of computers, it exists purely on the Internet. Anyone with access to the Internet can send and receive money as easily as sending an e-mail. With this new form of digital cash, we are seeing the beginning of a new world of finance.

Bitcoin was launched in January 2009, just a few months after the financial crisis of 2008. As a true peer-to-peer currency, anyone in the world has access to bitcoin, with the ability to send it to anyone else. Its design insures that nobody can have their funds locked or taken away. The effects of this breakthrough currency are quite impressive. We have already seen the currency rise in price from less than one US cent to over a thousand dollars.

Since its launch, Bitcoin has challenged the mainstream view of finance. Originally designed as Digital Gold, Bitcoin's scarce supply and resistance to manipulation has resulted in an explosion of new ideas and projects with the strong potential to disrupt major industries and revolutionize finance.

Its anonymous creator, Satoshi Nakamoto, is only known through his contributions, namely the Bitcoin whitepaper and his initial forum posts to help guide core developers to support and maintain the source code. While nobody can confirm his identity, the value of his work is evident in the fact that the Bitcoin source code has been tested and challenged without any serious bugs or exploits reported. This is truly an amazing feat.

In this book, we will introduce Bitcoin with a hands-on approach. We will begin with a simple and easy-to-follow introduction, which includes buying and selling bitcoin. Throughout the middle, we will look into the internal workings of Bitcoin to understand how its various pieces work. Towards the end, we will explore various ways in which Bitcoin can be used as "programmable money".

What this book covers

Chapter 1, Setting Up a Wallet, introduces the reader to Bitcoin and how to purchase some within 15 minutes. It covers the basics of Bitcoin, which includes addresses, keys, and wallets.

Chapter 2, Buying and Selling Bitcoins, covers more advanced ways of buying and selling bitcoin. Market trading and the tools involved are introduced.

Chapter 3, Protecting Your Bitcoins, educates you about how to become your own bank. Different approaches to safeguarding bitcoin are introduced and discussed.

Chapter 4, Understanding the Blockchain, gets into the nuts and bolts of Bitcoin's underlying technology. Its various technologies and algorithms are illustrated and explained.

Chapter 5, Installing a Bitcoin Node, is a step-by-step tutorial on setting up a Bitcoin node, which allows you to participate in the network. Some basic Bitcoin programming is introduced.

Chapter 6, Understanding the Mining Process, guides you through the various options available for mining bitcoin. The chapter focuses on the expenses involved and helps you to evaluate profitability.

Chapter 7, Programming Bitcoin, dives into the potential of Bitcoin as "programmable money". The chapter describes an example of how to build a simple Bitcoin escrow service using JavaScript.

Chapter 8, Exploring Alternative Coins, takes a tour around four innovative alternative coins based on Bitcoin's original source code. It ends with an example of how to set up a voting ballot secured by cryptographic proof.

What you need for this book

To follow along with the examples of this book, you will need a modern web browser and a stable internet connection. Many of the Bitcoin services mentioned in the book are web-based and will only work on modern equipment. An iOS or Android smartphone might be necessary for some operations and authentication.

To be able to set up and install a Bitcoin node, a fast internet connection and a computer with a strong processor is required. The hard drive should have a minimum storage of 50 GB available, but more will be needed as the blockchain grows in size.

For the various aspects that involve programming, a computer with access to a terminal is required. Mac OS/X, Windows, and Linux have console access within a terminal. There are some additional tools required for setting up, such as Node.js, in order to follow along with the examples. Lists of the tools are provided with the examples.

If you are interested in setting up a Bitcoin mining rig, special equipment is required. Some of the equipment might be difficult to find and expensive to purchase. As the market is still new, one can expect many changes in pricing and availability. It is recommended that you check the forums and online marketplaces, such as eBay and Craigslist, to find more information about purchasing the equipment.

Who this book is for

This book is written to help introduce Bitcoin to anyone who has basic experience with online banking. Most of the first half of the book is written for those who are very new to digital finance.

The second half of the book is written for those who are interested in seeing Bitcoin's potential. You do not have to be a programmer or hardware engineer to follow along, as simple explanations with clear illustrations are provided.

For more technical readers, scripts and installation notes are provided to help develop a deeper understanding of Bitcoin.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles, and explanations of their meanings.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

// convert 'satoshi' to bitcoin value 
var satoshiToBTC = function(value) { 
  return value * 0.00000001 

Any command-line input or output is written as follows:

~ npm install bitcoinjs-lib -g 

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.