0% found this document useful (0 votes)
943 views39 pages

Grokking Bitcoin

Uploaded by

hugoeana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
943 views39 pages

Grokking Bitcoin

Uploaded by

hugoeana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

MEAP Edition

Manning Early Access Program


Grokking Bitcoin
Version 6

Copyright 2018 Manning Publications

For more information on this and other Manning titles go to


www.manning.com

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
welcome
Thank you for purchasing the MEAP for Grokking Bitcoin. I sincerely hope that you will find
this book valuable.
Bitcoin is digital money. You can transfer bitcoins globally, quickly, cheaply. Bitcoin is a
global network of computers that collectively keeps track of who owns what bitcoins. There
is no central authority, like a central bank, that controls the issuance of money or verifies
payments. All tasks performed by central authorities in traditional financial systems are
instead performed by the Bitcoin network.
Let's face it: Bitcoin is hard. But it is my firm belief that anyone with a technical interest
can understand the basics of Bitcoin. If you know what a database, a computer program,
and a computer network is, you should be able to follow most parts of this book. Some parts
might be a bit too technical for you, but they are optional and I'll warn you ahead of those
sections.
The number one goal of this book is to give you enough understanding to decide for
yourself whether you trust Bitcoin or not. If we reach that goal, it also means that you'll
quickly understand more simple stuff not covered by this book, like how to install a Bitcoin
wallet and what buttons to click to make payments. Understanding the hard stuff makes the
simple stuff simple. The book is not intended as a tutorial on "how to use Bitcoin", but as a
way to empower yourself with knowledge, to Grok.
You can't write a book alone. You need feedback from many different people. I hope that
you will not hesitate to give honest, and even frank, feedback in the forum. Where did you
get stuck? Did you spot a factual error? Is the learning path awkward? Me and the good folks
at Manning don't have the eyes of the intended reader, so without you we are fumbling in
the dark.

Thank you again for your interest in this book.

— Kalle Rosenbaum
 

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
brief contents
1 Introduction to Bitcoin
2 Cryptographic hash functions and digital signatures
3 Addresses
4 Wallets
5 Transactions
6 The blockchain
7 Proof of work
8 Peer to peer network
9 Transactions Revisited
10 Segregated witness
11 Bitcoin Upgrades
Appendixes
A Using Bitcoin-cli
B Answers to Exercises
C Web Resources

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
Foreword
Preface
Bitcoin is changing the world.
The world has seen several major improvements to human life.
Among them are vaccine, electricity, radio, automobiles, and
the Internet. Some of these technologies start out as rich man’s
games, but eventually they will trickle down to the general
public and bring huge benefits to Earths population. Bitcoin is
right there among them. Soon.
This is what makes me super-excited about Bitcoin. Luckily, I’m
fortunate enough to live in a pretty functional society. I have
never had problems conducting in financial transactions
without someone knocking on my door. I’ve never felt that I
need to spend my money immediately, because otherwise
hyperinflation will eat my lunch. But that also makes it harder
for me to grok why Bitcoin is important. Bitcoin is mostly
theoretical to me, but when I hear reports from less fortunate
people living under oppressive or incompetent regimes about
how Bitcoin makes their lives better, it gets very real. Bitcoin
will give people an opportunity to opt-out of the system they
were previously held hostage in.
Satoshi Nakamoto, a pseudonym for a person or a group that
wants to remain unknown, published a scientific paper on a
cryptography-oriented e-mail list in October 2008. The title of
the paper was "Bitcoin: A Peer-to-Peer Electronic Cash System",
see Web resource 1. Nakamoto’s paper described the vital parts
of Bitcoin, the first digital money system where there’s no
central authority to issue money or process transactions. Later,
in January 2009, Nakamoto published the first software
program to implement the described system. Bitcoin didn’t get
much attention then, apart from within a very limited set of
cryptography experts. Gradually, as the system proved itself to
be working, more people got interested in it. But the resistance
against Bitcoin was and is still far bigger and louder than the
adopters, as is the case with all ground-breaking new
technology. As of 2018, hundreds of millions of people are

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
aware of Bitcoin and millions of people are using Bitcoin.
When I started exploring Bitcoin in 2013, it took me a lot of
time to get a decent understanding of the technology. That’s
not because I’m remarkably stupid, it’s because Bitcoin is a
complex system. It’s not just a fancy database, it’s a mishmash
of economy, mathematics, technology, and anthropology.
I started a technical blog about Bitcoin in 2015, and I guess
Manning liked my content, because they emailed me and
asked if I was interested in writing a book about "blockchain".
Since my passion is with Bitcoin, not just the blockchain (which
is a tiny part of Bitcoin), I replied and thanked them for their
interest in me and said that I’d be interested in writing a book
about Bitcoin. I’ve struggled a few years trying to find a good
place in the Bitcoin community, and this opportunity seemed
like a great fit. The project started and it turned out to be far
harder and far more time consuming than I thought.
The book started out as a typical technical description of
Bitcoin, but it was hard to teach one topic without the full
context of Bitcoin. The cognitive load in the beginning of the
book would simply be too overwhelming. It became clear that I
needed to do something else. I discussed it with my wife and
we came up with the idea of conceptually building Bitcoin
from the ground up. We start with a really simple spreadsheet
system that anyone can understand and we let that system
evolve into Bitcoin. Each chapter points out a problem with the
current system and we fix it by adding the technology covered
by that chapter.
Grokking Bitcoin will be released under the Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International (CC
BY-NC-SA 4.0) license no later than three months from
publication. Releasing under an open source license was a
requirement I had for writing the book. This is my way of giving
back to the Bitcoin community that has given me so much over
the years. However, there are other, less philanthropic reasons:
Open sourcing the will probably benefit sales because the
book will get more exposure and people can browse through
the content before buying.
I hope you enjoy reading Grokking Bitcoin as much as I
suffered writing it.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
Acknowledgments
I have a lot of people to thank for making this book possible.
First, I’d like to thank my wife, Linnéa, for all valuable
discussions and your consistent encouragement. You are
absolutely fantastic.
Christina Taylor at Manning, my dear development editor.
Thank you for keeping me busy and winging this project. Work
work work. Thank you also to Bert Bates for your very valuable
input on the pedagogy.
I’d like to also thank everyone else on Manning, who
contributed with their professionalism. Ozren Harlovic,
Rebecca Rinehart, Candace Gillhoolley, Ana Romac, Michael
Stephens, Erin Twohey, Christopher Kaufmann, Matko Hrvatin,
Greg Wild. Thanks.
I’d also like to thank Jonathan Jogenfors and Pontus Lindblom
for reviewing some chapters covering their respective fields of
expertise.
A lot of people on various forums on the Internet has been very
helpful during my research. The ones that stand out the most
are David A. Harding, Pieter Wuille and Mark "Murch" Erhardt.
Thank you for all Twitter conversations and great answers on
Bitcoin Stack Exchange, Web resource 2.
I got help from Andreas M. Antonopoulos when negotiating
the open source terms for this book. Your encouragement
during that process was gold. Thank you! And also, thank you
for the "vegetarian restaurant" analogy used in Chapter 11.
thank you also for all your amazing talks, you are major source
of inspiration for me.
I have written this book using asciidoctor, which is a text
markup language. Thank you Dan Allen for your hard work on
asciidoctor. It’s fantastic.
The book has gone through three review rounds, with several
reviewers in each round. Those reviews have been extremely
useful in vetting our ideas and finding gaps in the learning
path: Jan Goyvaerts, Max Humber, Iryna Romanenko, Jean-
François Morin, Al Krinker, Joel Kotarski, Markus Beckmann,
Christopher Bailey, Viton Vitanis, Paolo Freuli, Tomo Helman,
Marcello Seri, Maciej Drozdzowski, Cicero Zandona, Barnaby
Norman, Frances Buontempo, Glenn Swonk, and Sergio
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
Fernandez Gonzalez.
Thank you also to all MEAP (Manning Early Access Program)
readers who contributed their thoughts, corrections, and
questions on the Manning Forum.
If I left someone out, I’m terribly sorry, thank you too.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
About this book
Who should read this book
This book is intended for technically interested people wanting
to understand Bitcoin on a deep technical level. The book does
not require any programming skills, but a basic understanding
of some technical concepts are beneficial, for example
databases, computer networks, computer programs, and web
servers.
The primary goal of the book is that you will be able to
decide for yourself whether you trust Bitcoin or not. That
primary goal is hard to achieve, because you need to learn
most concepts in Bitcoin, such as digital signatures, proof-of-
work, and peer-to-peer networks, on a pretty deep level. Some
secondary goals falls out naturally from the primary goal:
• Install and use a Bitcoin wallet on your phone, and
understand what you’re doing.
• Engage in technical Bitcoin discussions.
• Make informed decisions on how to store your private
keys depending on Bitcoin amounts stored and required
level of security and convenience.
• Run a full Bitcoin node to engage in financial transactions
without trusting a third party.

How this book is organized


This book consists of 11 chapters and three appendices.
1. An overview of Bitcoin. You’ll learn what Bitcoin is, why it
matters and roughly how it operates.
2. Cryptographic hash functions and digital signatures.
These are the fundamental building blocks needed for the
rest of this book. We also lay the groundwork for a fictive
money system, cookie tokens, that we’ll build upon during
chapters 2 through 8.
3. Bitcoin addresses. What is a Bitcoin address, why are they
needed and how are they created and used?
4. Wallets. We go through how a Bitcoin wallet keeps track of
your secret keys and how multiple secret keys can be
generated from a single huge random number, called a
seed. Backups are also discussed in detail.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
5. Transactions. We explore the anatomy of a Bitcoin
transaction and how they are digitally signed and
processed.
6. The blockchain. Transactions are stored in a database that
we call the blockchain. We walk you through how the
blockchain is structured and how it enables the use of so-
called lightweight wallets.
7. Proof of work. Proof of work is used to select who gets to
add new transactions to the blockchain. This process,
called mining, is what keeps your bitcoins secure in the
blockchain.
8. The Bitcoin network. Bitcoin has no central point of
control, we will see how that’s possible with a peer to peer
network. We also explain how to take active part in the
Bitcoin network by running your own node.
9. Transactions revisited. We circle back to transactions and
discover some bells and whistles that are important for
various applications.
10. Segregated witness. In 2017, Bitcoin was upgraded with a
major improvement to transaction reliability and
blockchain capacity. This chapter gives you all the details.
11. Bitcoin upgrades. We will go through soft forks and hard
forks and how soft forks together with a careful
deployment plan can be used to safely upgrade Bitcoin.
I suggest that you read chapters 2-8, where we will build the
cookie token system from the ground up, sequentially. Each
chapter will add a technology to the cookie token system to
solve a specific problem, and in chapter 8 we will have built
Bitcoin. Chapters 9, 10 and 11 can then be read out-of-order, or
some of those chapters may be skipped. I do however
recommend to read chapter 11 carefully, because I think it is
the essence of Bitcoin. If you get chapter 11, you’re grokking
Bitcoin.

We will reuse some overview figures from Chapter 1 every The periscope
now and then throughout the book to help you with
orientation, both in chapter intros and embedded inside the
chapters. It’s easy to lose track of the big picture and what the
goal of the current topic is. Look for the periscope picture and
section headers like "Where were we?".
Each chapter, except Chapter 1, contains exercises. They are
there for you to assess your skills. Each batch of exercises is
divided into an easier section called "Warm up", used for
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
shorter fact checks, and a tougher section, "Dig in", that
requires more thinking. The difficulty of some exercises,
especially in the "Dig in" sections, can be dreadful, so please
don’t feel put off if you get stuck on some of them. If you get
stuck, I suggest that you consult Appendix B for answers.

About the Code


There’s not much code in this book. None actually. But there
are some linux commands in Chapter 8 and Appendix A. A
command is prefixed by a dollar sign and a space, `$ `, as
follows:
$ cd ~/.bitcoin

When a command is too long to fit on a single line we break


the line with a backslash \ where the line is broken and indent
the next line by 4 characters as follows:
$ ./bitcoin-cli getrawtransaction \

30bca6feaf58b811c1c36a65c287f4bd393770c23a4cc63c0be00f28f62ef170 1

Backslash can be used to write commands across multiple lines


in most linux command line interpreters, so you can copy and
paste line breaked commands into your terminal. The output
from commands are not line-breaked with backslash, they are
just wrapped as needed.
Throughout the book we will write data in fixed-width font, for
example 7af24c99. We usually don’t explicitly write out what
encoding (decimal numbers, hexadecimal strings, base64
strings, base58 strings and so forth) we use, because it’s often
obvious from the context.

Author online
Other author resources
If you have specific questions about Bitcoin that you didn’t find
the answer to in this book, I really recommend Bitcoin Stack
Exchange, Web resource 2, which is a platform for questions
and answers where good answers get up-voted by readers.
I can also recommend the Bitcoin Developer Reference, Web
resource 3, for more comprehensive documentation of Bitcoin.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
However, the Bitcoin Core source code, available on Web
resource 4, is the most accurate source of information. It is the
reference implementation of the Bitcoin protocol, and reading
that source code is sometimes the only way to find answers to
your questions.
If you want to search the contents of this book online, I
recommend searching through the source code available
at Web resource 5. However, this will not be available
immediately when the book is released, but at latest three
months from release.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
About the author
Kalle Rosenbaum has worked as a software developer for 20
years. His passion for Bitcoin began in 2013 and has continued
uninterrupted since then. Kalle started a Bitcoin consultancy
company in 2015 and has worked in the Bitcoin industry since.
He also started a technical blog which explains various
technical Bitcoin topics, such as block propagation
improvements, sidechains and replace-by-fee. The purpose of
the blog was to teach himself and let others benefit too.

Dedication
To the love of my life, my wife, Linnéa. Smart, faithful, real.
And to all awesome Bitcoiners everywhere.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
About the cover illustration

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
1

1
Introduction to Bitcoin

This chapter covers

• Getting to know Bitcoin


• Following a Bitcoin payment
• Problems solved by Bitcoin
This book will hopefully teach you enough about Bitcoin so
that you can make informed decisions on how you can use
Bitcoin to improve your private life or your business. My hope
is that you will learn enough to make up your own mind
whether you trust Bitcoin or not, hopefully the former. In order
to get you off the ground, I’m going to assume that you know
roughly what the following terms mean:
• computer program
• database
• computer network
• web server
If you’re unsure of any of these terms, don’t worry. Either look
them up or just go ahead anyway, I think you’ll manage.

1.1 What is Bitcoin?


Bitcoin is a digital cash system. It allows for people to move Bitcoin or
bitcoins, the currency unit of Bitcoin, between each other bitcoin?
without using a bank or any other trusted third party. It
resembles traditional bank notes and coins in that way, but it
is purely digital and used over the Internet. The Bitcoin The system is named
Bitcoin with capital B. The
currency is not tied to any specific fiat currency like the US currency unit is called
dollar or the Chinese Renminbi; It has free floating exchange bitcoin with lowercase b.
rates against all fiat currencies. You can buy and sell bitcoins Commonly used symbols
bitcoin are ฿, BTC and
for fiat currencies online using one of several exchanges, for for
XBT. We will mostly use BTC
example kraken.com, bitstamp.net and localbitcoins.com. in this book.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
2

No government or company is controlling Bitcoin. Instead,


thousands of computers around the globe, the Bitcoin
network, collectively keep the system working day and night,
seven days a week. You don’t need to register or sign up
anywhere to use Bitcoin, you just need Internet access and a
computer program, like a mobile app to use it.
Anyone can use or participate in the Bitcoin network without
special permission from a bank or similar institution. Thanks to
thispermissionless nature of Bitcoin, a lot of Bitcoin related
technology has emerged over the years. The participants in this
Bitcoin ecosystem can be roughly categorized into several
groups:

Figure 1. 1. The Bitcoin network and its ecosystem.

END USERS Bitcoin


doesn’t care
These are people using Bitcoin for their day-to-day needs.
It can be for example savings, shopping, speculation, or
salary. The Bitcoin network
doesn’t distinguish
CORPORATE USERS between users. No
Companies using Bitcoin to solve their business needs, user is more
for example paying wages internationally, or use cases important than any
similar to those of the end users. other user. It doesn’t
matter who they are
MERCHANTS or what they do,
everyone participate
For example a restaurant or a book store accepting on the same terms.
Bitcoin payments.
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
3

BITCOIN SERVICES
Companies providing Bitcoin related services to its
customers. For example top-up mobile phones,
anonymization services, remittance services or tipping
services.
EXCHANGES
A commercial service people can use to exchange their
local currency to and from bitcoin.
PROTOCOLS ON TOP
Systems can be built on top of bitcoin. Payment network
protocols, specialized tokens and decentralized
exchanges are all examples of protocols that operate "on
top" of Bitcoin to perform certain tasks.
BITCOIN DEVELOPERS
People working, often for free, with the open source
computer programs that the participants of the Bitcoin
network are using.
The Bitcoin network’s job is to process Bitcoin payments, to
secure the ledger of who owns what from unauthorized
modifications, and to get new bitcoins into circulation at the
predetermined rate. The network consists of thousands of
computers around the world. We call those computers Bitcoin
nodes or just nodes. Any of the actors mentioned above can
also participate actively in the Bitcoin network by running their
own Bitcoin node. You must run your own node if you don’t
want to trust others to provide you with correct financial
information.

1.2 The big picture


The Bitcoin network is a network of computers running Bitcoin
software. The Bitcoin network verifies and confirms payments
between Bitcoin users.
Suppose that Alice wants to make a payment of 1 BTC to Bob.
The payment starts with Alice creating a transaction and
sending it to the Bitcoin network. The process goes through
four steps, that we’ll outline here, and explain each step a bit
further in the following subsections.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
4

Figure 1.2. A Bitcoin payment. The payment is processed in 4 steps.

This diagram will follow us in each intro of chapters 2 through I thought


8 where we point out what in this figure we will cover in the Bitcoin was
chapter. Now, let’s follow Alice’s payment from Alice to Bob: anonymous?

1. Alice creates and signs a transaction that moves 1 bitcoin Bitcoin doesn’t use
from her to Bob. She then sends it to the Bitcoin network. names or any other
personal information,
2. The computers in the network, the Bitcoin nodes, check but we use names in
that Alice actually has the money to spend and that the this first example for
transaction is authentic. They then pass the transaction simplicity.
on to their neighbors, called peers.
3. Each computer updates its own copy of the Bitcoin
blockchain, the ledger, with the new payment
information.
4. The network notifies Bob that he has received 1 bitcoin.

Note how Alice does not really send 1 bitcoin to Bob, but asks
the Bitcoin network to move 1 bitcoin from Alice to Bob in the
Bitcoin blockchain.
The Bitcoin blockchain is a database that each computer in
the Bitcoin network has a copy of. Think of the blockchain
as a ledger of all transactions ever made.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
5

We will go through these steps a bit closer in the next four


sections, one step per section.

1.2.1 Step 1 – Transactions


Step 1 of the process is when Alice asks the network to move 1 Transaction
bitcoin to Bob. She asks by sending a Bitcoin transaction to
the Bitcoin network. The transaction contains instructions on
how to move the money and a digital signature that proves A transaction is a payment.
We will use the terms
that it is actually Alice that requests to move the money. interchangeably. We cover
transactions in Chapter 5
and Chapter 9.

Figure 1.3. Step 1: Alice creates a transaction, signs it and sends it to one or more Bitcoin
nodes in the Bitcoin network.

The Bitcoin transaction is a piece of data specifying


• the amount to move (1 bitcoin)
• the Bitcoin address to move the money to (Bob’s Bitcoin
address 15vwoaN74MBeF5nr2BH4DKqndEFjHA6MzT)
• a digital signature (made with Alice’s private key)
The digital signature is created from the transaction itself and Bad
a huge secret number, called a private key, that only Alice has transactions
access to. The result is a digital signature that only the owner
of the private key could have created. We discuss digital
signatures in-depth in
Chapter 2.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
6

Alice’s mobile wallet app is connected to one or more nodes in


the Bitcoin network, and sends the transaction to those nodes.

1.2.2 Step 2 - The Bitcoin network


Alice has sent a transaction to one or more Bitcoin nodes. In
step 2 of the process, each such node checks that the
transaction is valid and passes it on to its peers. It does that by
consulting its local copy of the blockchain and verifying that
• the bitcoin that Alice spends exist and that it is not already
spent
• Alice’s digital signature is valid.

Figure 4. Alice has sent her transaction to a node in the network. The node will verify the
transaction and forward it to other nodes. Eventually the transaction has reached all nodes
in the network.

If all checks pass, a node will forward the transaction to its Bad
peers in the Bitcoin network. This is known as relaying. Alice’s transactions
transaction would shortly have traveled the whole network
while being verified by each node along the way. The Invalid transactions
blockchain has not been updated yet, that’s the next step. are dropped. They
will not reach further
than the first node.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
7

1.2.3 Step 3 - The blockchain


In step 3, nodes update their local copies of the Bitcoin The
blockchain with Alice’s transaction. The blockchain contains blockchain
historic information about all previous transactions, and new
transactions, such as Alice’s, are appended to it every now and The names comes
then. from how the ledger
is structured. It uses
It is not as straightforward as it may seem to update the blocks that are
blockchain with Alice’s transaction. Alice’s transaction is not chained together in
the only transaction that goes on. There are possibly such a way that
thousands of transactions in-flight at the same time in the modifications to the
Bitcoin network. If all nodes would just update their copy of blockchain can be
the blockchain as they receive transactions the copies would detected. More on
not remain copies for long, because the transactions may that in Chapter 6.
come in different order on different nodes:

Figure 5. Transactions arrives in different order at different nodes. If they would all write
the transactions to the blockchain, the different nodes' blockchains would differ.

To coordinate the ordering of transactions, one node takes the


lead saying "I want to add these 2 transactions to the
blockchain in the order B, A!". This message, known as a block,
is sent out on the network by that leader, in the same way as

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
8

the transaction was sent by Alice.

Figure 6. One node takes the lead and tells the others what order to add the transactions
in. The other nodes verify the block and update their blockchain copies accordingly.

As nodes see this block, they update their copy of the The blockchain
blockchain according to the message, and pass the block on is append-only
to its peers. Alice’s transaction was one of the transactions in
the block and is now part of the blockchain. New transactions are added
to the end of the
Why would a node want to take the lead? It’s because the blockchain only. It grows
node that takes the lead is rewarded with newly minted only from the end.
bitcoins and transaction fees payed by the transactions it
includes in the block.

But, wouldn’t every node constantly take the lead to collect the
rewards? No, to take the lead, a node must solve a hard
problem. This takes plenty of time and electricity for the node,
which ensures that leaders don’t pop up very often. It is so hard
that most nodes in the network don’t even try. The nodes that
do try are called miners because they mine new coins, similar
to a gold miner digging for gold. This process is described
in Chapter 7.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
9

1.2.4 Step 4 - Wallets


Bob and Alice are users of the Bitcoin network, and they both
need some computer program to interact with the network.
Such a program is called a Bitcoin wallet. There are several
different types of Bitcoin wallets for several different devices,
like mobile phones and desktop computers, even specialized
hardware wallet devices.
Before step 4 of the payment process, the nodes in the network
have updated their local copy of the blockchain. Now the
network needs to notify Alice and Bob that the transaction
went through.

Figure 7. Bob’s wallet have asked a node to notify the wallet upon activity in his Bitcoin
address. Alice pays to Bob’s address, and the node has just written the transaction to the
blockchain, so it notifies Bob’s wallet.

Bob’s wallet is connected to some of the nodes in the Bitcoin Wallet duties
network. When a transaction concerning Bob is added to the
blockchain, the nodes that Bob’s wallet is connected to will
notify Bob’s wallet. The wallet will then display a message to A typical Bitcoin
Bob that he just received one bitcoin. Alice also use a wallet. wallet will
Her wallet will also be notified of her own transaction.
✔ Manage keys
Besides sending and receiving transactions, Bob’s and Alice’s
wallets also manage their private keys for them. The private ✔ Watch
incoming/outgoing
keys are used to create digital signatures. Alice created her bitcoins
digital signature with one of her private keys. When Bob later
wants to spend the money he received to his Bitcoin address, ✔ Send bitcoins
he needs to create a transaction and digitally sign it with the

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
10

private key corresponding to that Bitcoin address.

1.3 Problems with money today


Bitcoin would not be this widespread if it didn’t solve real
problems for real people. Bitcoin solves several problems of the
traditional financial system. Let us look at some commonly
discussed problem areas.

1.3.1 Segregation
People with bank accounts and access to banking services like
on-line payments or loans are very privileged. About 38% of
the world population don’t have a bank account at all
according to the World Bank, see Web resource 6. The numbers
are slowly improving but still a lot of people are stuck in a cash-
only environment.
Without a bank account and basic bank services like on-line
payments, people can not expand their businesses outside of
their local community. A merchant will not be able to offer
goods or services on the Internet to increase its customer base.
A person living in a rural area may have to travel half a day to
pay a utility bill or top-up their prepaid mobile phone.

This segregation between banked people and unbanked Problems


people is driven by a number of factors:
• Banking services are too expensive for some people.
• In order to use bank services you need documentation,
like an ID card, that many people don’t have. ☐ Segregation
• Banking services may be denied to people with certain
political views or people conducting certain businesses.
People may also be denied service due to their ethnicity,
sexual preferences, or skin color.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
11

1.3.2 Privacy issues


There are several privacy problems with traditional
money, when it comes to electronic payments like
credit cards or bank transfers. States can easily
• trace payments
• censor payments
• freeze funds
• seize funds
You might say, "I have nothing to hide, and the
government need these tools to fight crime". The
problem is that you do not know what your
government looks like in five years and how that
government defines crime. New laws are just an
election away. After next election, your government
may pass a law that allows freezing funds of people
with your political view. There are places in the world
where this is happening.

We have seen lots of examples where these abilities are Problems


abused to disable someone’s ability to transact. For example,
the non-profit organization WikiLeaks was put under a
blockade in 2010, see Web resource 7, where all donations ☐ Segregation
through traditional channels were blocked after pressure
from the US government on the major payment networks, ☐ Privacy issues
like Visa and MasterCard. We have also seen how Cyprus
seized 47.5%, see Web resource 8, of all bank deposits
exceeding 100,000 € as part of a financial rescue program in
2013.

Worth noting here is that bank notes and coins are usually not
affected. As long as there is cash, people can trade freely and
privately. In some parts of the world, for example Sweden, cash
is being phased out, which means that soon you will not be
able to buy a chewing gum without being recorded by
someone.

1.3.3 Inflation
Inflation means that the purchasing power of a currency
decreases.
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
12

Problems

☐ Segregation
Figure 1. 8. Inflation ☐ Privacy issues
☐ Inflation

Most currencies are subject to inflation. Some more than


others. For example the Zimbabwean dollar inflated nearly
1023% during 2007-2008, peaking at 80 billion percent per
month during a few months in 2008. That is an average daily
inflation rate of nearly 100%. Prices roughly doubled every day.
Extreme cases of inflation like this are called hyperinflation.
Hyperinflation is usually driven by a rapid increase in the
money supply. Governments sometimes increase the money
supply as a tool to extract value from its population to pay for
expenses like national debt, warfare or welfare. If this tool is
over-used, the risk of hyperinflation is apparent.
A rapid increase in the money supply will most likely lead to a
depreciation of the currency. This in turn pushes people to
exchange their local currency for goods, or alternative
currencies, that better holds value, which further drives the
value of the currency down. This can spiral down to extremes
like in Zimbabwe. The result is devastating for people as they
see their life savings diminish to virtually nothing.
Table 1.1 Some hyperinflations in modern time. Source: Wikipedia
Country Year Worst monthly inflation [%]
Zimbabwe 2007-2008 4.19*1016
Yugoslavia 1992-1994 313*106
Peru 1990 397
Ukraine 1992-1994 285
Venezuela 2012- 120

Zimbabwe is one of the most extreme cases of inflation


throughout history, but still today some countries suffer from
very high inflation. One of them is Venezuela where its
currency, the bolívar, experienced a 800% inflation during
2016, and during 2017 it suffered from about 4,000% inflation.
A staggering 15,000% inflation is forecast for 2018.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
13

1.3.4 Borders
Moving value across national borders using national, or fiat,
currency is hard, expensive and sometimes even forbidden. If
you want to send 1,000 Swedish crowns (SEK) from Sweden to
a person in the Philippines, you can use a service like Western
Union for the transfer. At the time I investigated this, 1,000 SEK
was worth 5,305 Philippine Pesos (PHP) or 109 US dollars.

Table 1.2 Cost of sending 5305 PHP from Sweden to Philippines


Send from Receive to Received by recipient Fees Fees %
Bank Bank 5,109 PHP 265 PHP 4.9%
Bank Cash 4,810 PHP 564 PHP 10.5%
Credit card Cash 4,498 PHP 876 PHP 16.3%

If the recipient has a bank account with the capability of


receiving international money transfer, we could get away with
a 4.9% fee. But a typical remittance recipient will only be able
to receive cash, which doubles or triples the cost to 10.5% or
16.3% depending on how quick or convenient you want it.

To contrast the above, moving fiat currency within the borders Problems
of a nation state is usually very convenient. For example, you
can hand over cash directly to the recipient, or transfer money
using some mobile app made specifically for the currency. As ☐ Segregation
long as you stay within one country and one currency, fiat ☐ Privacy issues
currencies usually do a pretty good job. ☐ Inflation
☐ Borders

1.4 The Bitcoin approach


Bitcoin offers a fundamentally different model than traditional
financial institutions. Let us explore the major differences one
by one.

1.4.1 Decentralized
Instead of a central organization controlling the currency, like
the US Federal Reserve, the control is distributed among
thousands of computers, called Bitcoin nodes or just nodes. No
single node or group of nodes have more privileges or
obligations than any other node. This equality between nodes
makes Bitcoin decentralized, as opposed to centralized systems
like banks or the Google search engine.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
14

Figure 1.9. Centralized and decentralized services

In a centralized system, the service is controlled by a single


entity like a bank. It implies that this single entity can decide
who gets to use the service and what the user is allowed to do.
For example an on-line video service may chose to provide a
video only to people in a certain geographical location.

With a decentralized system like Bitcoin, with several Fixed


thousands of nodes spread around the globe, it is extremely
hard to control how and by whom the system is used. No
matter where or who they are, or whom they are sending ✔ Segregation
money to, the Bitcoin system will treat all users equally. There
is no central point in the Bitcoin system that can be exploited ✔ Privacy
to censor payments, deny users service or seize funds. ☐ Inflation
Bitcoin is permissionless, which means that you don’t need
☐ Borders
to ask anyone for permission to participate. Anyone with a
computer and an Internet connection can set up a Bitcoin
node and take an active role in the Bitcoin network. No
questions asked. No registration.

It is nearly impossible to change the rules of Bitcoin without


broad consensus. If a node does not obey the rules it will be
ignored by the rest. For example, one rule is that the money
supply of Bitcoin is limited to 21,000,000 bitcoins. That limit is
nearly impossible to change because of decentralization;
There’s no one to thread or bribe into chaning the rules.

1.4.2 Limited supply


A hard promise of Bitcoin is that its money supply will not Fixed
exceed 21 million bitcoins. People can be sure that if they own

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
15

one bitcoin, they will always own at least one 21 millionth of


the total supply of bitcoins. This feature is not found in any fiat
currency, where decisions on the supply is made every so ✔ Segregation
often by a company or a state. Bitcoin is very resistant to high
✔ Privacy
inflation because there is no way to increase the money
supply at will. ✔ Inflation
The money supply of Bitcoin is actually not fixed today. It is ☐ Borders
increasing, at a diminishing rate, according to
a predetermined schedule and will eventually stop increasing
around year 2140.

Figure 1.10. The supply of bitcoins over time

As of writing, the money supply is about 17 million bitcoins


and the current yearly increase in the money supply is about
4%, but the increase is halved every four years.

1.4.3 Borderless
Since Bitcoin is a system run by ordinary computers connected Fixed
to the Internet, the Bitcoin system is as global as the Internet
itself. This means that anyone with an Internet connection can
send money to other people across the world. ✔ Segregation
✔ Privacy

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
16

✔ Inflation
✔ Borders

Figure 1.11. Bitcoin is borderless

There is no difference between sending a bitcoin to someone


in the same room or sending it to someone on another
continent. The experience is the same: Money is sent directly to
the recipient, who will see the payment nearly instantaneously
and within about 60 minutes the recipient can be sure that the
money is hers. Once settled, there is no way of reversing the
transfer without the recipient’s consent.

1.5 How is Bitcoin used?


So far we have touched on a few common use cases for Bitcoin.
This section will dig deeper into those use cases and a few
others. It is hard to predict what use cases we will see in the
future. Let us stick to what we know now.

1.5.1 Savings
One interesting feature of Bitcoin is that you keep your money
safe by storing a set of private keys. Private keys are the secret
pieces of information that you will need when you want to
spend your money. You chose how those private keys are
stored. You can write them on paper, or you can store them
electronically with a mobile app to have easy access to them.
You can also memorize the private keys. The private keys are
also all that is needed to spend your money. Keep them safe.

This makes savings an attractive use case for Bitcoin. A simple


©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
17

way to save is to create a private key and write it down on a


piece of paper that you store in a safe. That piece of paper is
now your savings account, your savings wallet. You can then
send bitcoins to your wallet. As long as your private key is kept
safe, your money is safe. There are a lot of different saving
schemes you can chose from to find the right balance between
security and convenience. For example, you can keep them
unencrypted in your mobile phone for easy access, or store
them encrypted on paper in a vault with armed guards.

1.5.2 Cross-border payments


As noted before, it is very expensive (say 15%) to move money
from one country to another, especially if you move money to
a poor country and the recipient doesn’t have a bank account.
It is becoming increasingly popular to use Bitcoin to
circumvent this expensive and slow legacy system. It is usually
cheaper to exchange SEK for bitcoins in Sweden, and transfer
the bitcoins to your friend in the Philippines. Your friend will
then exchange the bitcoins locally for Philippine Pesos, PHP.
There are also companies offering such services so that you
simply pay SEK to the company and the company pays out PHP
to your friend.

You will not even know that Bitcoin is used under the hood.
They will typically charge a few percent for the service, but it
will still be cheaper than traditional remittance services.
Of course, if the recipient can make good use of Bitcoin where
he lives, there is no need for a middle-man that takes a cut of
the money. You would send bitcoins directly to your friend.
This is what Bitcoin is all about. Exchanges and other such
service companies are just bridges between the old legacy
world and the new Bitcoin world.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
18

1.5.3 Shopping
The most obvious use case for Bitcoin is to use it for shopping.
The borderlessness and security of Bitcoin makes it ideal for on-
line payments for goods and services.
In traditional on-line payments, you send your debit card details
to the merchant, and hope that the merchant will withdraw as
much as you agreed on. You also hope that the merchant
handles your debit card details with great care. They probably
store the details in a database. Think about that; For every debit
card purchase you make, your card details will be stored in that
merchant’s database. It is quite likely that oneof the databases
gets hacked and your card details are stolen. The more
merchants that store your details, the higher the risk.

With Bitcoin, you don’t have that problem, because you don’t
send any sensitive information to the merchant, or anyone
else. You transfer the amount of money that you agreed upon,
and nothing more.

1.5.4 Speculation
The world is full of people wanting to get rich quick. Bitcoin
can be very alluring to them because of the price volatility, or
tendency to change. Looking at the history of the bitcoin price,
it is very tempting to try to buy when it is low and sell when it
is high.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
19

Figure 1.12 Price in USD since beginning of Bitcoin

In November 2013, the price climbed from about $100 (US


dollars) to over $1100 in a few weeks. This was clearly a so
called bubble, where people were afraid of missing out on a
great rise, so they bought in, driving the price further up, until
it eventually started dropping again. The drop to 50% of its
peak value was just as quick as its rise. The same pattern was
repeated late 2017 but on a greater magnitude. This has
happened many times already. Fluctuations like this are rarely
driven by any specific news or technological advancements,
but from speculation.
It does happen that some government or big corporation
makes a negative statement that creates fear in the market, but
those events tend to have a limited effect on the value of
bitcoin.
Speculation can be fun, if you can afford to lose, but it is more
like a lottery than something to make a living from.
The volatility in Bitcoin price seems contradictory to the claims
of non-inflationary property; A 50% drop in market value
seems pretty inflationary. Bitcoin is still relatively new, and lots
of short-term speculation causes this volatility. But as Bitcoin
grows and more people and institutions start using Bitcoin to
store their wealth, it will probably stabilize in the long run. So
the deflationary property of Bitcoin will emerge over time.
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
20

1.5.5 Non-currency uses


Bitcoin is digital cash, but this form of cash can be used for
other things beyond money. This section covers two common
uses, but there are others including not yet invented uses.

OWNERSHIP
Bitcoin allow you to embed small pieces of
data with payments. This data can be for
example a chassis number of a car. When the
car leaves the factory, the manufacturer can
make a small Bitcoin payment, containing the
chassis number, to the new car owner. This
payment will then represent the transfer of
ownership for that car.

Bitcoin payments are public records but they are not tied to
persons in any way. They are tied to long strings of numbers
called public keys, explained in detail in Chapter 2. The car
manufacturer has made its public key publicly available on
their website, in newspapers and advertisement, to tie the
public key to the identity of the manufacturer. Anyone can
then verify that the manufacturer has transferred ownership of
the car to the new owner. The new owner can show that she
owns the car by proving that she owns the private key
belonging to the public key that the manufacturer transferred
ownership to.
The new owner can sell the car to someone else and transfer
ownership by sending the very same bitcoins she got from the
manufacturer to the new owner’s public key. The general
public can follow the ownership of the car from the
manufacturer through every owner’s public key up to the
current owner.
PROOF OF EXISTENCE
Using the same technique to store data in a Bitcoin payment to
transfer ownership of a car, you can prove that a document
existed prior to a certain point in time.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
21

A digital document has a "fingerprint", a


cryptographic hash, that anyone can
calculate from that document. It is practically
impossible to create a different document
with the same fingerprint. This fingerprint
can be attached to a Bitcoin payment. It is
irrelevant where the money goes; The
important thing is that the fingerprint is
recorded in the Bitcoin blockchain. You
"anchor" the document in the blockchain.
Bitcoin payments are public records, so
anyone can verify that the document existed
before the time of the payment by taking the
fingerprint of the document and compare it
to the fingerprint stored in the blockchain.

1.5.6 How is Bitcoin valued?


As you could read in section Section 1.5.4,
the price of a bitcoin can fluctuate quite
dramatically. But where is this price actually
coming from? There are several Bitcoin
exchanges, mostly Internet based. They
resemble stock markets, where users wanting
to sell bitcoins are matched with users
wanting to buy bitcoins.
Different markets can have different market
prices depending on the supply and demand
on that market. For example, in countries like
Venezuela where the government tries to
hinder the Bitcoin market, the supply will be
low. But the demand is high, because people
want to escape from their hyperinflating
currency. These factors drive the Bitcoin price
up in that market compared to for example
the US and European markets where people
can trade more freely.

1.5.7 When not to use Bitcoin


Bitcoin is nice and all, but it’s not suitable for all sorts of
financial activity. At least not yet.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
22

TINY PAYMENTS
Each transaction needs to pay a fee to be processed. The fee is
not related to the amount sent, but to how big the transaction
is in bytes. This is because the Bitcoin network’s cost for
processing a transaction depends mostly on how big (in bytes)
the transaction is. High-value transactions are not bigger (in
bytes) than low-value transactions, so the fee is about the same
for both kinds of transactions. The fee required for a
transaction also depends on supply and demand for available
space in the blockchain. The blockchain can’t handle more
than roughly 12MB of transactions per hour, which means that
miners will sometimes have to prioritize transactions. Paying a
higher fee will probably give your transaction a higher priority.
If the fee is a significant share of the actual payment you want
to make, it is not economically viable to pay with ordinary
Bitcoin transactions.
Amount to transfer Fee Fee % Feasible
2 BTC 0.003 BTC 0.15% Yes
0.002 BTC 0.001 BTC 50% Probably not
0.001 BTC 0.005 BTC 500% No

There are however very promising emerging technologies


being built on top of Bitcoin. One example is the Lightning
Network, that allows for cheap, instantaneous micropayments
of tiny fractions of a bitcoin. Using Lightning Network, you can
pay just 100 satoshis (1 satoshi = 0.000,000,01 BTC) at a fee of 1
satoshi.
INSTANT PAYMENTS
Bitcoin payments take time to confirm. The recipient sees the
payment immediately, but shouldn’t trust the payment until it
is confirmed by the Bitcoin network, which typically happens
within 20 minutes. Trusting an unconfirmed transaction can be
risky, because the sender can make the transaction invalid by
sending the same bitcoins to herself instead. This is known
as double spending.
The confirmation time can add friction in brick and mortar
shops, because the customer don’t want to wait 20 minutes
before getting her coffee. This may not be a big issue in some
on-line shops, where the shop can wait 20 minutes before
sending the goods to the customer, but some on-line services,
for example pay-per-view, could find the confirmation time

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
23

problematic.
This limitation can also be fixed by systems built on top of
Bitcoin, for example the Lightning Network, especially when
the amount to pay is small.
SAVINGS YOU CAN’T AFFORD TO LOSE
Bitcoin is probably the most secure money there is, but it is still
in its infancy. Things could go bad with Bitcoin, for example:

Bitcoin is probably the most secure money there is, but it is Bitcoin
still in its infancy. Things could go bad with Bitcoin, for security
example:
You are in charge of the
• You lose your private keys, the secret you need to spend security of your bitcoins.
your money. Only you. Be careful!
• Your private keys get stolen by some bad guy.
• The government in your location may try to crack down
on Bitcoin users by imprisonment or other means of
force.
• The price of bitcoin can swing down dramatically due to
rumors or speculation.
• There may be software bugs that can make Bitcoin
insecure.
• There may be weaknesses in the cryptography used by
Bitcoin.
While all of the above risks are possible, most of them are
unlikely. The list is somewhat ordered with the most likely at
the top. Always weigh the risks before putting money on the
line and select your security measures accordingly. This book
will help you understand the risks and how to secure your
money.

1.6 Other cryptocurrencies


This book will cover Bitcoin. But there are several other so-
called cryptocurrencies, and new ones pop up all the time.
Cryptocurrencies other than Bitcoin are often referred to as alt-
coins, alternative coins. I will list a few popular alt-coins along
with their purpose and so-called market capitalization, market
cap. The market cap is the product of the money supply
(number of coins) and the current market price per coin. Note
that the market cap will most likely have changed a lot when
you read this. I include it only to give you a glimpse of Bitcoin’s
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
24

position relative to the other cryptocurrencies.


Table 1.3 Market capitalization of a few cryptocurrencies as of 2018-06-13.
Currency Purpose Market cap [billion dollars]
Global money, included for reference 111

Run software on a decentralized 48


abstract computer
Anonymity 1.9

Anonymity 0.8

Naming system, complements domain 0.02


name system, DNS

I encourage you to look up these cryptocurrencies as they all


provide interesting new features beyond Bitcoin. There are
hundreds of other alt-coins. Some alt-coins, for example the
ones above, provide some unique features that are not
available in Bitcoin, and some provide little to nothing
innovative. Some alt-coins may even be outright scams. Stay
vigilant.
Anyone can create an alt-coin by taking any existing
cryptocurrency software and modify it to her needs.

Let’s say that Sheila wants to start an alt- Network effect


coin, Wowcoin. She takes the Bitcoin
software and changes the maximum
money supply to 11,000,000, instead of
Bitcoin’s 21,000,000, coins and starts.
When Wowcoin is started she will be
very lonely, because no one else is using
her alt-coin. If she wants Wowcoin to
have some real value, she has got to
convince other people to start using her
alt-coin. If she’s not providing anything
innovative, she’s going to have a hard
time getting other people on-board,
since they are pretty happy with what
Bitcoin is already providing. Everybody
else is using Bitcoin, so why would you
use Wowcoin? Think of it as starting a
new internet, that you call Wownet.
People on Wownet will not be able to
use services on the Internet. Conversely,
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin
25

people on the Internet will not be able


to use your service if you are on
Wownet. So why would anyone use
Wownet? We call it the network effect;
People tend to go where other people
are.

While there are some interesting alt-coins out there, it’s really
hard to tell which of these will survive long-term. Also picking
one or a few alt-coins to cover in this book would seem like an
arbitrary choice. Consequently, I focus solely on Bitcoin in this
book.

1.7 Recap
In this chapter you learned that
• Bitcoin is global, borderless money, that anyone with an
internet connection can use.
• Bitcoin is used by many different actors, like savers,
merchants, traders for many different purposes like
payments, remittances and savings.
• A network of computers, the Bitcoin network, verifies and
keeps records of all payments.
• A transaction goes through the steps: Send transaction,
verify transaction, add transaction to the blockchain,
notify recipient and sender wallet.
• It solves problems with inflation, borders, segregation and
privacy by providing limited supply, decentralization and
borderlessness.
• There are several alternative cryptocurrencies apart from
Bitcoin, for example Ethereum, Zcash and Namecoin.
• A (crypto)currency needs to have enough users and
activity to be useful. It’s called network effect.

©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/grokking-bitcoin

You might also like