How To Bitcoin (1) (001-050)
How To Bitcoin (1) (001-050)
How To Bitcoin (1) (001-050)
teaspoonpublishing.com.my
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or
transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or
otherwise, except brief extracts for the purpose of review, without the prior permission in writing of
the publisher and copyright owners. It is also advisable to consult the publisher if in any doubt as to
the legality of any copying which is to be undertaken.
“Bitcoin might seem very complicated to the uninitiated and it is, but this book really simplifies it.”
– Mati Greenspan, Founder & CEO of Quantum Economics
“It’s not too late to be early to bitcoin. How to Bitcoin is a great introduction that anyone can learn
from whether you’re a beginner or financial professional. Find out why crypto is the fastest growing
asset class in the world.”
– Nicolas Cary, Co-Founder of Blockchain.com and Co-Founder & Chairman of SkysTheLimit.org
“Education ensures that everyone can benefit from the Bitcoin revolution.”
– Dan Held, Business Development Manager of Kraken
CONTENTS
INTRODUCTION
PART 1: WHAT IS BITCOIN?
CHAPTER 1: BITCOIN AND MONEY
Government Money
2008 Financial Crisis
The Birth of a Financial Alternative
Characteristics of Bitcoin
1. Clearly Defined Monetary Policy
2. Permissionless, Peer-to-Peer System
3. Open-Source, Transparent and Decentralized Ledger
4. Highly Fungible, Durable, Portable, and Divisible
5. Digital Money
Bitcoin vs Gold vs Fiat Currencies
Use Cases of Bitcoin – Can bitcoin be our new money?
Medium of Exchange
Store of Value
Unit of Account
Closing Thoughts
CHAPTER 2: ANATOMY OF BITCOIN
The Bitcoin Ledger
Start of the Monopoly Game
How are the Pages Generated?
Understanding the Blockchain Structure
The Chains of a Blockchain – Hash Functions
The Blocks in a Blockchain
Putting it All Together
Mining on the Blockchain
What exactly does a miner do?
Bitcoin Mining Difficulty
What if two miners find the answers at the same time?
Bitcoin Transactions
Unspent Transaction Output (UTXO)
How does Bitcoin Prevent Double-Spending?
What if Miners Collude to Double-Spend?
CHAPTER 3: THE HISTORY OF BITCOIN
Bitcoin Key Events
The Mt. Gox Hacking
Silk Road Shutdown
Block Reward Halving
New York Agreement (NYA)
Lightning Network
Bugs
Value Overflow Incident (15 August 2010)
Chain Fork Incident (20 March 2013)
PART 2: BITCOIN & YOU
CHAPTER 4: KEEPING YOUR BITCOINS SAFE
Private Key
Public Key and Bitcoin Address
Wallets
Hot Wallets
Desktop Wallets
Full Node Wallets
Simple Payment Verification (SPV) Wallets
Mobile Wallets
Cold Wallets
Hardware Wallets
Paper Wallets
Common Bitcoin Risks
Centralized Exchange Hack
Phishing
The Basics of Bitcoin Security
Password Manager
Two-Factor Authentication (2FA)
Remove Unused Browser Extensions
Do Not Click on Ads
Metal Storage Backup Tools
Summary
CHAPTER 5: GETTING YOUR FIRST BITCOIN
Buying Bitcoins
Cryptocurrency Brokerages
Coinbase
Cryptocurrency Exchanges
Kraken
Peer-to-Peer (P2P) Marketplaces
LocalBitcoins
Earning Bitcoin
Earn bitcoin cashback using Lolli
Provide services in exchange for bitcoin
Play to earn via bitcoin faucets
Mining Bitcoin
CHAPTER 6: STORING YOUR BITCOIN SAFELY
Hardware Wallet: Trezor One
Blockchain.com Mobile Wallet
Blockchain.com Browser Wallet
Lightning Network Wallets
Phoenix Wallet
Alternative Lightning Wallets
CHAPTER 7: ADVANCED BITCOIN WALLETS
Bitcoin Core Full Node
Full Node Requirements
Download
Installation
Downloading the Bitcoin Blockchain
Network Traffic Chart
Using Bitcoin Core Full Node as a Wallet
Receiving Bitcoin
Sending Bitcoin
Using the Bitcoin Full Node Console
Samourai Mobile Wallet
Installation
Setting Up
Receiving Bitcoin
Sending Bitcoin
Samourai Whirlpool (CoinJoin)
PART 3: THE FUTURE OF BITCOIN
CHAPTER 8: BITCOIN’S IMPROVEMENTS
Scalability
Segregated Witness (SegWit)
Lightning Network (LN)
Privacy
CoinJoin
JoinMarket
Taproot
What’s Next?
CHAPTER 9: BEYOND BITCOIN
Bitcoin Forks
Bitcoin Cash
Bitcoin SV
Smart Contract Platforms
Ethereum
Polkadot
Stablecoins
Tether
Dai
Privacy Coins
Dash
Monero
CLOSING REMARKS
APPENDIX
CoinGecko’s Recommended Bitcoin Resources
Reads
Newsletters
Podcast
Videos
Other Books We Recommend
References
Chapter 1: Bitcoin and Money
Chapter 2: Anatomy of Bitcoin
Chapter 3: The History of Bitcoin
Chapter 4: Keeping your Bitcoin Safe
Chapter 5: Getting your First Bitcoin
Chapter 6: Storing your Bitcoin Safely
Chapter 7: Advanced Bitcoin Wallets
Chapter 8: Bitcoin’s Improvements
GLOSSARY
INTRODUCTION
Welcome to CoinGecko’s second book, How to Bitcoin! We received so
much positive feedback on our first book, How to DeFi, that we decided to
write this one!
Bitcoin was the first cryptocurrency that got us started on our journey. Our
understanding of Bitcoin has opened up many opportunities for us, and in
these pages, we hope to share our collective knowledge with you. In How to
Bitcoin, you will learn of Bitcoin’s transformative aspects and how it can
open new opportunities for you too.
Bitcoin is not new. As we write this, it is 12 years old. That being said, it is
still early and not too late to learn about Bitcoin and its implications for the
future. Perhaps you would have heard of Bitcoin as this “magic Internet
money” with revolutionary potential. We hope to debunk that and put
together what makes Bitcoin revolutionary other than just “magic.”
How to Bitcoin is written for beginners with simple analogies to help you
understand how it works. There are step-by-step guides to show you how to
buy and secure your first bitcoin. It will be a relatively light read if you
already have a deep understanding of Bitcoin. If so, we would be honored
to receive your suggestions on improving this book.
Lastly, we see a future where owning a bitcoin is a matter of choice and
foresight rather than ignorance. We hope this book can contribute to making
that a reality.
CoinGecko Research Team
Kristian Kho, Khor Win Win, Crystaline Loo, Lee Shu Wei, Shaun Paul
Lee, Teh Sze Jin, Bobby Ong
1 January 2021
PART 1: WHAT IS BITCOIN?
CHAPTER 1: BITCOIN AND MONEY
Bitcoin is a peer-to-peer electronic payment system that allows parties to
transact with each other without the need to use any trusted third-party
intermediaries. It is an alternative to our traditional financial system, where
payments need to be routed through financial institutions.
When you use Bitcoin, you do not need to trust a centralised entity such as a
government, a bank, or a financial institution. For example, in the traditional
financial system, using PayPal requires that you trust PayPal’s ability to make
transactions. Paying with your Mastercard requires that you trust Mastercard,
your bank, your merchant's bank, and other payment processors to clear your
transaction.
Even using cash requires you and your counterparty to trust your government
officials. As recently as 2016 the Prime Minister of India demonetized the 500
and 1,000 rupee notes causing significant immediate volatility.1
Bitcoin is a payment protocol and a cryptocurrency itself. This protocol is a
payment network that allows for transactions to be routed without relying on
any third parties. It is powered by a new technology known as the blockchain.
Bitcoin is also known as a cryptocurrency, a type of virtual currency, because
transactions are secured using cryptography.
For the purposes of this book, we will be representing ‘Bitcoin’ with a
capitalized ‘B’ whenever we refer to the Bitcoin protocol and ‘bitcoin’ with a
lowercase ‘b’ when we refer to the bitcoin cryptocurrency.
Bitcoin distinguishes itself from traditional fiat currencies as it is not backed by
any government, central bank, or centralized authority. Instead, it is created,
stored, and distributed digitally on a public, decentralized ledger that follows a
strict set of simple rules.
This is the philosophy that created Bitcoin—the ability to operate a financial
system in a decentralized manner without the need to trust any centralized
intermediary.
Government Money
Before we continue with bitcoin itself, it may be worth revisiting the money
that we use on a day-to-day basis.
For something that almost everyone on Earth labors for and cherishes after, few
understand how money functions and even less comprehend the intricacies of
the fiat monetary system.
“It is well enough that people of the nation do not understand
our banking and monetary system, for if they did, I believe there
would be a revolution before tomorrow morning.”
—Quote attributed to Henry Ford
“Government Money” is what is known as fiat currency, or in simple English,
“Money by Decree”.
Fiat is derived from the Latin word “fiat”, which essentially means “let it be
done”. Fiat has been deemed as money because it is mandated by governments
as being legal tender by law and thus must be accepted as a valid form of
payment under the scrutiny of our legal jurisdiction.
With most things in government, money is handled with a top-down approach.
National leaders decide every facet of the monetary system and regular folks
follow the rules that have been set.
Fiat’s layered bureaucratic system vs. Bitcoin’s peer-to-peer system.
In an ideal world, a top-down fiat monetary system isn’t all that bad. After all,
not everyone is an expert in economics and finance; it is perfectly acceptable to
just use a robust value-transfer system without needing to worry about anything
as one goes on with their daily lives.
However, for the past century or so, this has not been the case.
Without going into too much detail, the rules governing paper money, more
specifically the US Dollar, changed in 1913.2 Paper money that used to be
“backed by gold” became paper money “backed by the government”. During
this period, the Federal Reserve (Fed) at least tried to tie the value of the dollar
with gold. Things took a turn for the worse in 1971 when the Fed stopped
trying and decided that the Dollar was worth whatever it says it was worth.3
Data from St. Louis Federal Reserve
2008 Financial Crisis
The above sets the scene for what was about to happen when the whole world
economy crashed down during the 2008 Financial Crisis.
The 2008 Financial Crisis in the United States was one of the worst economic
disasters in history, crumbling the world’s financial and banking system.4 Many
large financial institutions and banks tragically fell apart. Amongst the fallen
were Lehman Brothers and Bear Stearns.
This crisis stemmed from subprime mortgage loans, which in simple terms
were loans issued to high-risk borrowers who do not qualify for conventional
loans.5 These loans were then repackaged multiple times into complex
derivatives. Bad loans combined with widespread fraudulent practices across
various financial institutions exacerbated the housing bubble. It created a
ticking time bomb that ultimately blew up into the 2008 Financial Crisis.
The main reason which caused the credit crisis was the naïve assumption that
interest rates will continuously stay low and residential home prices will
continually increase in price. When both these assumptions broke, many of the
subprime borrowers could not repay their home loans and had their homes
repossessed by the banks.
This caused a devastating ripple effect to the economy. To salvage the economy,
the U.S Treasury bailed out ‘too big to fail’ banks.6
The 2008 financial crisis highlighted the fragility of our traditional financial
and banking system. Banks were supposed to be the central trustworthy
authorities safeguarding the money we deposit and governing our monetary
system’s health. However, they have failed miserably to do so.
The Birth of a Financial Alternative
It is against this backdrop of the global monetary crisis that the Bitcoin
whitepaper was published pseudonymously by an entity known as “Satoshi
Nakamoto”. Satoshi released the Bitcoin whitepaper on a cryptography-focused
mailing list on 31st October 2008.7 The 9-page whitepaper outlines a new
financial system with a new cryptocurrency called bitcoin.
The sudden appearance of Bitcoin’s whitepaper during this period is almost too
good of a coincidence. Compounded by the growing distrust of the fiat financial
system at that time, Bitcoin grew in popularity from an obscure online forum
into a viable financial alternative now.
On 3rd January 2009, The Genesis Block started the Bitcoin Network, bringing
the world’s first decentralized payment system to life.8 The resulting alternative
payment network allows for the transfer of value over the Internet electronically
in a peer-to-peer manner, without the need for a centralized authority
overseeing the transaction.
Being the first block on the Bitcoin blockchain, the Genesis Block is unique as
it does not contain a previous block reference compared to the subsequent
blocks mined. It may seem that Satoshi was fully aware of the financial failures
of the time and understood the invention of Bitcoin is an apparent challenge to
the financial and monetary institutions. Within the Genesis Block, Satoshi left a
string of characters that may have served as the call to Bitcoin’s purpose as well
as a timestamp to prove that Bitcoin started on the day itself.
The words “The Times 03/Jan/2009 Chancellor on brink of second bailout for
banks” were etched on the Bitcoin blockchain to be seen by all for eternity.
This Easter egg is a direct copy of The Times headline of the same date.
Digitized copy of The Times article, “Chancellor on brink of second bailout for banks” from January 3,
2009
Fun Fact
The first 50 BTC block reward in the Genesis Block is
unspendable. Till this day, it remains a mystery if Satoshi
Nakamoto deliberately coded it to be non-transferable or if it
was a mistake.
The Genesis Block’s reward recipient address
1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, suspected to be
owned by Satoshi, has been receiving donations from fans.9 At
the time of writing, it has accumulated a total of 68.3 BTC.
Characteristics of Bitcoin
These are some of the core characteristics of Bitcoin which makes it unique:
1. Clearly-defined monetary policy
2. Permissionless, peer-to-peer system
3. Open-source, transparent, and decentralized ledger
4. Highly fungible, durable, portable, and divisible
5. Digital money
1. Clearly Defined Monetary Policy
A crucial characteristic of bitcoin is that it is a decentralized currency, unlike
fiat currency which is controlled by a centralized authority such as a central
bank.10
Central banks have the ability to issue new money at their will. According to
the European Central Bank, “Central banks are protected from insolvency
due to their ability to create money and can therefore operate with negative
equity.”11
Recall the 2008 Financial Crisis that was mentioned earlier. With the aid of
the Fed, Quantitative Easing (QE) was used to salvage the crisis. This
highlights the immense control that central banks have with regards to
monetary policy.
A key feature of Bitcoin is its scarcity—there will only ever be 21 million
bitcoins in circulation. This cap is final and cannot be altered. Bitcoin
differentiates itself from traditional fiat currency with its limitless supply.
Bitcoin is also similar to gold in the sense that it has to be mined into
circulation. However, unlike gold, which needs to be mined physically in
actual ores, bitcoin is mined digitally.12 This is why bitcoin has often been
referred to as “digital gold”.
For every block created, new bitcoins will be mined as block rewards to
Bitcoin miners. This will be explained in detail in the coming chapters. At
the time of writing, 18.5 million bitcoins, or more than two-thirds of all
bitcoins have already been mined.
2. Permissionless, Peer-to-Peer System
Let’s say Alice wants to send $1,000 to Bob. Traditionally, the pathway
taken to do so would look something like this:
Alice would have to not only rely on Alice’s and Bob’s banks, but also a
slew of intermediaries and third party financial institutions and service
providers depending on the requirements of Alice’s and Bob’s banks.
This system of sending money presents inefficiencies and bureaucracy. Each
of the companies may charge a fee, making the transaction expensive. There
are also various money transfer laws that need to be followed.
For example, if Alice is a US citizen and Bob is an Iranian, the transaction
will never happen due to international sanction laws.13
Even if a transaction happens locally, governments can arbitrarily cancel the
transaction or even confiscate the money altogether.
In July 2020, Hong Kong passed legislation allowing the government to
freeze bank accounts and assets of people who have been deemed to
“endanger national security”.14 This threat may be used as a tool to suppress
the freedom of speech of the people amidst the ongoing political turmoil.
Using Bitcoin, intermediaries like banks or payment processors are no
longer needed to oversee transactions. Let’s take a look at the scenario if
Alice were to transfer $1,000 worth of bitcoin to Bob:
Using the Bitcoin network, Alice directly transfers value over to Bob
without any authorization from anyone, hence the term “peer-to-peer”. The
removal of the middlemen like the bank is profound as this bypasses the
many potential issues associated with central authorities and third parties.
By removing third parties from the transfer of value, we remove the ability
for these middlemen to exert authority over our financial transactions.
PayPal is famous for freezing users’ accounts for various reasons; you can
find many people complaining about this issue online.15
Bitcoin allows us to have full control of our own assets without the need to
trust any institutions or third parties. With this control, no one can
unilaterally freeze or revoke our assets without our permission.
The power now goes back to individuals. Anyone, no matter who or where
they are, can now directly engage in the transfer of value and economic
activity with another person without any third-party's permission.
3. Open-Source, Transparent and Decentralized Ledger
The Bitcoin protocol, the set of code that powers the Bitcoin network, is
released under the MIT License more popularly known as open-source
software.16 17 This means that the code is open for everyone to see, inspect,
copy, and propose improvements. Anyone is free to suggest improvements to
Bitcoin, thereby aligning incentives amongst the Bitcoin community.18
The Bitcoin ledger is distributed globally. It is decentralized and no single
entity is able to tamper or manipulate the data contained in the blockchain.
Anyone who tries to unilaterally manipulate the data on their ledger will be
known immediately because their ledger will not be similar to the ledger
maintained by everyone else.
This means that no one fully owns or controls Bitcoin. No entity—not even
governments—can annihilate Bitcoin’s existence.
To give a simple analogy to explain this concept of a decentralized ledger,
let’s take a look at a game of Monopoly played between 4 friends. Instead of
distributing Monopoly paper money to all 4 players during the game, a blank
notebook and a pen is given to each player. Each player will record the
amount of money that all 4 players have at each turn during the game.
After every turn, everyone pauses to check each other’s notebooks to ensure
that it tallies with everyone else’s records. This way, any player who tries to
cheat will have the discrepancy caught immediately and can be easily
disqualified from the game.
4. Highly Fungible, Durable, Portable, and Divisible
Bitcoin is also a type of money that is highly fungible, durable, portable and
divisible.
Fungibility is a concept where things are mutually interchangeable. Bitcoin
is fungible because each bitcoin can be easily replaceable with another
bitcoin.
Bitcoin is also highly durable because it cannot be easily destroyed by
natural elements unlike paper money. So long as the private keys to your
bitcoin are stored safely and are not lost, you will have access to your
bitcoin.
Because bitcoin is a form of digital money, it is incredibly portable. You can
bring your entire net wealth with you wherever you go with just the private
keys. This is significant especially to people who live in countries without a
stable government. With bitcoin, these people can pack their bags and move
to a stable country while still retaining their wealth.
Bitcoin is also divisible to 8 decimal places. The smallest unit for bitcoin is
0.00000001 BTC, also known as a satoshi. This was named as a tribute to
the creator of Bitcoin, Satoshi Nakamoto. This means that you do not need
to send or own 1 whole bitcoin but can send small fractions of bitcoin to pay
for goods and services.
5. Digital Money
Being a digital currency is important because it means that the money we
use can be easily programmed to do highly customizable things.
Antony Lewis mentioned in his writing that money in your bank accounts
are not really programmable because the money in each bank is technically
different. Dollars in Citibank and JP Morgan have different legal agreements
and have different logic and constraints.19
Because there is no ledger referencing the money stored in different bank
accounts, this makes it hard for money to be programmed to follow certain
rules.
With Bitcoin, there is the bitcoin ledger where programmers can set rules to
program escrow, notaries, design payouts and dividends.20 This concept of
universal cash will become increasingly important as we move towards
machine-to-machine payments in the future.
Bitcoin vs Gold vs Fiat Currencies
Bitcoin has often been compared to gold and fiat currencies like the US Dollar.
There are several similarities and differences between these various forms of
asset classes. This table here provides a summary of the various characteristics
of bitcoin relative to gold and fiat currencies:
Fiat
Traits of Money Gold Bitcoin
Currencies
Fungible
High High High
(Interchangeable)
In each block, the list of transactions are all hashed indirectly through the
Merkle Root, and included in the block header, such that even 1,000
transactions in the entire body can be represented as a single line of hash.
The block header is essentially the “summary” of an entire block, plus a
reference to the previous block.
Merkle Root
The merkle root is effectively the hash of all the hashes of all
the transactions in a block. In each block, there can be
thousands of transactions—the Merkle Root is the hash of all
these transactions.
This is an extremely efficient method of storing and verifying
transaction data. Merkle root allows one to easily check that a
transaction has indeed been verified without needing to go
through the entire list of transactions.
Since the Merkle Root is contained in the block header, the
block header then effectively contains all information that is
required to:
1. Summarize the entire block’s transactions (Merkle Root)
2. Link to previous block (contains previous block header’s
hash)
In the subsequent block, the header of the previous block is hashed, and
stored as part of the header of the current block. In this fashion, each block
references the previous block using a hash, including the list of all
transactions. To change any part of the information in previous blocks, you
will have to change everything moving forward as even the most minor
change will result in a completely random change of the hash.
Putting it All Together
The Bitcoin ledger makes use of the blockchain technology very effectively.
It is a transparent database of transactions distributed globally (the blocks)
with tamper-proof features made possible through the use of cryptographic
hashing functions (the chain).
So far, we have gone through what makes up a blockchain, but some key
details remain missing:
1. What is preventing someone from creating a different version of the
entire Bitcoin ledger, and then distributing it as the valid one?
2. What is stopping someone from printing more bitcoin?
3. How do all participants agree on a particular version of the bitcoin
ledger at any given time?
4. How are conflicts resolved in the event there are conflicting and
different bitcoin ledger versions?
That is where miners come into play. Miners effectively provide security to
the Bitcoin network and verify transactions using computers to perform
complex mathematical calculations.
Mining on the Blockchain
Before Bitcoin came along, you would basically picture giant tractors, dusty
tracks and huge piles of rocks when the term “mining” was mentioned. With
the advent of Bitcoin, the term “mining” took a whole new meaning where it
refers to the act of solving complex, repetitive computational math problems
that can only be effectively done by specialized computers.
The main reason why miners are interested in participating in the Bitcoin
mining process is because they are interested in earning the Bitcoin block
reward given out to the producer of the next block.
Miners keep the Bitcoin network secure and help everyone stay in sync with
one version. They invest electrical energy in the form of computational
power to solve complex mathematical problems and are rewarded for their
efforts in the form of block rewards. The block reward that miners earn is
effectively the fee which the Bitcoin network pays for network security. This
method ensures that the Bitcoin blockchain cannot be easily tampered with.
In Bitcoin’s case, each block is produced roughly every 10 minutes. In this
10-minute period, miners pick out transactions to be verified, prioritizing the
ones with the highest fees. Once a new block is “mined”, transactions that
are included are added to the blockchain and broadcasted to participants
worldwide—similar to how a new page is used in our Monopoly notebook
example earlier.
Here’s a handy illustration to showcase the process:
What exactly does a miner do?
In the case of Bitcoin, a miner competes with other miners to find the nonce
which gives the correct answer by repeatedly performing SHA-256 hashing
calculation. The work done by a miner in finding the solution to this puzzle
is also known as the Proof of Work.
For each new block, a miner needs to guess an output hash that fulfills a very
specific condition—the number of leading zeros. Roughly, the equation is:
Hash output = Hash of (previous block header + merkle root hash + nonce)
The previous block header and Merkle Root hash are known, so miners are
effectively guessing the nonce value that will give the correct output hash
with a specific number of leading zeros. This is the hash for block number
647,729:
000000000000000000064b9fcad14d747b725552005db1a77e6344a7c672a9
bf
Arriving at the solution above likely requires many iterations and is what
makes the mining process computationally expensive. However, one elegant
aspect to hashing is that once the input parameters are known, it becomes
fairly trivial and easy to verify that it leads to the correct solution. This can
be likened to a Sudoku puzzle, whereby it is difficult to solve, but very easy
to verify if it is solved correctly.
Bitcoin Mining Machine (or commonly called ASIC)
Bitcoin mining rig is also known as an Application Specific
Integrated Circuit (ASIC) machine as it excels at only one thing
—calculating SHA-256 hashes for Bitcoin and nothing else.
The power of an ASIC is measured by its hash rate. Hash rate is
a measure of how many hashes a machine can compute every
second. As of 2020, a retail Bitcoin ASIC can compute around
100 TH/s (12 zeros —that’s 100,000,000,000,000 hashes per
second). In comparison, a desktop CPU can only calculate in
terms of MH/s (6 zeros), orders of magnitude smaller.
Bitcoin Mining Difficulty
Bitcoin mining is often compared to a lottery because it involves luck where
miners are required to repetitively guess the solution to a mathematical
problem. In Bitcoin’s case, miners need to find the nonce as an input to the
hash input to guess an output that starts with a required number of zeros (the
difficulty).
In a lottery, if you would like to increase your chances of winning, you can
buy more lottery tickets. In a similar fashion, miners who want to increase
their odds of solving the mathematical puzzle will need to acquire more or
faster mining machines.
Miners are granted the block reward when they solve the puzzle for their
contribution in securing the network.
As more miners join the network, the likelihood for the network to
collectively solve the puzzle and find a block would increase as well. This
creates a situation where the solution to the puzzle (and thus a new block)
can be found much quicker than 10 minutes.
By design, Bitcoin maintains its 10 minutes block time by maintaining a
difficulty level—which is the number of zeros required for a solution to be
considered valid.
The Bitcoin protocol adjusts the difficulty level every 2,016 blocks (~2
weeks). If the previous 2,016 blocks took less than two weeks to be found,
then the difficulty will be increased. If it took more than two weeks, then the
difficulty will be reduced. This dynamic adjustment of difficulty ensures that
Bitcoin blocks are mined on average once every 10 minutes.
What if two miners find the answers at the same time?
For any given block, the correct nonce that will satisfy the difficulty
condition is not limited to just a specific nonce—there are multiple answers.
Miners compete with one another to be the first.
This may lead to a situation where two miners find the solution to this
mathematical puzzle at the same time. Both miners will broadcast their
solutions to the Bitcoin network at the same time where their solutions are
considered equally valid by all participants.
In this section, we will go through this scenario briefly to showcase how the
Bitcoin protocol handles this situation.
Let’s call the two miners Miner A and Miner B. When Miner A and Miner B
both discover their respective valid blocks, both miners will announce and
propagate their results to the network. Nodes in the network will incorporate
the version of the block that they receive first into their blockchain,
extending it by one block.
As such nodes that are closest to Miner A will update their blockchain with
the latest block being the one announced by Miner A, while nodes that are
closest to Miner B will update their blockchain with the latest block being
the one announced by Miner B.
Each node will then continue propagating their version of the blockchain to
their neighbouring nodes. In this example we have two competing versions
of the blockchain that have emerged and we will need a way to resolve this
conflict.
Blockchain Version A
Blockchain Version B
To resolve this conflict and ensure that the blockchain’s state remains
consistent across all participants in the Bitcoin network, each node will
select the blockchain that represents the most Proof of Work, otherwise
known as the longest chain.28
In this case, miners who added Block A to their blockchain will attempt to
find the solution to the next block and build on top of their state of the
blockchain. Miners who added Block B to their blockchain will also attempt
to find the solution to the next block and build on top of their state of the
blockchain.
Eventually, a miner will find a solution and extend the blockchain on either
Block A or B. Let’s say Miner X next found a solution extending Block B;
let’s call this Block X. Immediately, Block X forms the longest chain and is
thus regarded as the correct state of the blockchain.
All miners working on finding a solution on top of Block A will stop their
work and move on to find a solution to the next puzzle building on top of
Block X. Block A is now known as an orphan block. Any transactions in
Block A that have not been included in Block B or Block X will now be
queued for addition onto the next block on top of Block X.
This is how the Bitcoin protocol deals with the issue of potentially having
multiple “versions” of the blockchain.
Bitcoin Transactions
Bitcoin transactions are effectively inputs and outputs on a ledger that is the
blockchain. Here’s a quick visualization of two common types of
transactions:
1. Payment with change – Bob has a single address that contains 0.5
BTC. Bob sends 0.1 BTC to Alice, and receives 0.4 BTC as change.
This is like paying for coffee with cash using a large banknote and
receiving change on it.
There are many more ways transactions can happen on the Bitcoin
blockchain, but the examples above are the most common form of
transactions. Knowing how it works will be instrumental in understanding
how the Bitcoin protocol handles balances on its ledger.
Note that in the examples above, fees paid to the miners to process the
transaction is omitted for simplicity. The fees will go to a different address
owned by the miner.
Unspent Transaction Output (UTXO)
Bitcoin transactions are made of inputs and outputs. Unspent transaction
outputs, or UTXOs, are exactly what they sound like—they are outputs of
blockchain transactions that have not been spent and can be used as inputs
for new transactions.
On a fundamental level, UTXOs dictate the beginning and end of each
transaction.29 Whenever a transaction is made, users make use of the balance
of UTXOs that they have as inputs. Their digital signature is required to
verify that they are the real owners of the inputs, before they are converted
into outputs.30
After the transaction is completed and added to the blockchain, the UTXOs
used as inputs are now considered ‘spent’, and cannot be used for further
actions. However, the transactions create new UTXOs from the resulting
outputs, which can be spent later.
How does Bitcoin Prevent Double-Spending?
Double-spending occurs when a malicious user is able to send their bitcoin
to two different recipients at the same time.31 This means the second
transaction uses the same input as another transaction and both transactions
are relayed to the Bitcoin network at the same time.
Double-spending is a problem unique to digital currencies because digital
information can be easily replicated similar to how music and movies can be
easily pirated.
Double-spending is not possible when it comes to physical currencies. If you
purchase a doughnut for $1, you will have to give that $1 note away to the
cashier to receive the doughnut. It is not possible to simultaneously use the
same $1 note a second time to purchase coffee too. If you tried to replicate
the same $1 note using a photocopy machine, the cashier will immediately
be able to know that the photocopied $1 note is not authentic and is able to
reject it too.
There are two primary ways to solve the double-spending problem for digital
currencies—central clearing counterparty and blockchain.32 A central
clearing counterparty requires trust in a third-party and is the primary way
how our traditional financial system works. Bitcoin relies on a blockchain to
prevent double-spending from occurring without the need for any centralized
authority.
When it comes to people trying to spent bitcoin in a UTXO that has already
been spent, say 1 day ago, it is fairly trivial for a miner to check that this is
not a valid transaction because this UTXO has already been used as an input
to another transaction that has been included in a previous block. As the
UTXO was spent 1 day ago, this UTXO would have been included roughly
144 blocks previously.
If the miner insists on allowing this UTXO to be spent and wants to
invalidate the earlier transaction, the miner will need to redo all the Proof of
Work that has been done for all the previous 144 blocks and race against
time to compete against all other miners to create the longest chain. This is
computationally very expensive and is thus very improbable.
What if Miners Collude to Double-Spend?
Technically this can happen. Double-spending can occur if a majority of the
miners are dishonest. This is known as a 51% attack. This occurs when a
single entity is able to control more than 50% of the entire Bitcoin mining
capacity. When this occurs, the entity will have enough mining power to
modify the ordering of transactions and even exclude certain transactions.
An attacker that has 51% control of a blockchain may double-spend a bitcoin
by sending two transactions at the same time to two different addresses. This
attack usually targets cryptocurrency exchanges as the value of the attack is
the highest. To execute this attack, the first transaction is sent to a merchant
to purchase an item and this transaction is broadcasted to the broader Bitcoin
network.
The second transaction is sent to the attacker’s own address and the attacker
will secretly mine another branch of the blockchain that includes the second
transaction but not the first transaction. The attacker will continue mining
the secret chain for a few blocks until it is longer than the public chain and
the first transaction has been accepted by the merchant.
Once this has been done, the secret chain will be broadcasted to the network.
As the secret chain is now longer than the public chain, the network will
regard the secret chain to be the legitimate chain of the network. The first
payment to the merchant will thus be invalidated.
This is one of the reasons why Bitcoin transactions usually require 3 to 6
confirmations by merchants before it is accepted as a valid transaction. The
more blocks that have been mined on top of the existing blockchain (each
block represents one confirmation), the higher the likelihood that the
transaction would not be reversed as more computational power will be
needed to complete the Proof of Work needed in adding blocks to the
blockchain.
As long as a majority of miners are honest, it will be impossible for any one
entity to accumulate 51% of the hashrate and execute this double-spend
attack. Bitcoin’s network is sufficiently decentralized that no single entity
controls 51% of the hashrate.
CHAPTER 3: THE HISTORY OF BITCOIN
Since the inception of the Bitcoin blockchain on 3 Jan 2009, Bitcoin has
gone through numerous notable events.
This chapter will discuss several of those events and how they played a role
in Bitcoin’s developments. A lot has happened, so we will be narrowing it
down to some of the most important ones to get you up to speed quickly.
Bitcoin Key Events
Timeline Key Events
18 Aug 2008 The bitcoin.org domain was registered
18 May 2010 Bitcoin Pizza Day (10,000 BTC exchanged for 1 pizza)
14 Feb 2011 SilkRoad, the first Tor darknet market with Bitcoin escrow was
launched
19 Jun 2011 Mt. Gox was hacked. Bitcoin price dropped from $17 to $0.01
15 May 2014 The digital signature of Stoned, an ancient computer virus, was
inserted into the Bitcoin blockchain leading to false positives
from anti-virus programs
14 Jan 2016 Bitcoin Lightning Network whitepaper was released
23 May 2017 New York Agreement was reached to help with Bitcoin
scalability
1 Aug 2017 Bitcoin Cash was forked from Bitcoin
11 May 2020 Third Bitcoin Halving—Bitcoin block reward reduced from 12.5
BTC to 6.25 BTC per block
12 Nov 2020 PayPal enabled cryptocurrencies trade