Bitcoin technology primer
It can take many years to understand bitcoin in every detail, but luckily you don’t need to know everything to design great products. Let’s look at the most important ideas and technologies behind bitcoin by answering some basic questions.
Bitcoin, the currency #
You can own fractions of 1 bitcoin. They are just numbers in a digital ledger of transactions. We call that ledger the bitcoin blockchain. Transactions are used to assign bitcoin from one address to another. This process reduces the available balance of the sending address and increases the balance of the receiving address. A small amount has to be added as the fee to pay for the verification.
Therefore, owning a bitcoin means being in control of one or more addresses that have received bitcoin.
Bitcoin, the network #
Just as the internet allows computers to exchange information, the bitcoin network enables participants to exchange value. By running the bitcoin software, you are running a node connected to the bitcoin network. Some nodes use powerful computers that compete to verify transactions and update the blockchain for a reward. These nodes are called miners. Others are run by businesses like exchanges or merchants. They are also used by individuals making payments from mobile applications. Since January 3rd, 2009, every transfer of bitcoin has been permanently recorded in its shared global ledger.
What are the benefits of this ledger? #
Imagine a global spreadsheet where all transactions get recorded and all entries are publicly accessible. With bitcoin, each participant can verify a transaction for themselves in their copy of the spreadsheet. In comparison, traditional banks keep their spreadsheets private from each other and their customers. Besides opportunities for fraud, there are many points of failure due to this, so you can’t guarantee a payment will always happen. Even though all transactions are stored publicly on bitcoin, there is no personally identifiable information attached to them.
With thousands of nodes and tens of millions of users worldwide, it becomes implausible to manipulate or corrupt the previously agreed-upon transactions stored in the blockchain. Doing so would require a majority of nodes to accept such a change.
What is a blockchain? #
Instead of processing each transaction individually, the bitcoin network bundles them into blocks. A new block is created roughly every 10 minutes. A strict file size limit results in the transactions with the highest fees typically getting chosen first. Every new block must link to the one before it. Since this is a continuous process, a chain of blocks forms, hence the name blockchain.
Once a transaction is in a block that the network has accepted, it is considered to have one confirmation. With every new block created, the number of confirmations increases.
How is the blockchain secured? #
While miners check that the transactions included in the block are valid, they must also be kept accountable that they are submitting correct information. After a miner constructs a block of transactions, it must race against other miners to solve a cryptographic puzzle, incentivizing them to only include valid transactions in the block. This process is called Proof of Work, and it is fundamental to the security of the blockchain. The first miner to solve the puzzle and submit a valid block to the network will earn all the fees from the transactions in the block and a block reward as compensation; however, if they submit an invalid block, it will be rejected by the network.
We also call the bitcoin blockchain “base layer” as it provides strong security, and is the foundation for other things to be built on top.
Do all transactions have to be this secure? #
Layers in bitcoin serve to provide alternative settlement rules. Bitcoin’s block generation time of 10 minutes and the 1 MB size means that the blockchain can handle around 300 000 transactions per day or 4.6 transactions per second. Layer 1, the base layer, is the most secure, so it has the most time-consuming verification process.
In order to scale as a currency of the internet and meet the demands of the global economy, bitcoin needs a way to handle fast and frequent payments. Such payments don’t all need to be secured by every node and be added to the blockchain immediately. That is why a second layer is necessary to allow the delay of the base layer settlement.
How can you build on the base layer? #
Transactions get verified and stored by the entire network of nodes and miners who must constantly verify, exchange, and secure transactions they receive from wallets and other services.
While creating a transaction to move your funds from one address to another is common, setting up more complex spending rules is also possible. Such rules could require multiple parties to agree before moving funds, how much each is entitled to, and even the amount of time that must pass before a transfer. These transaction features make bitcoin customizable so that it’s possible to build other applications and even networks on top of the base layer.
There are multiple scaling solutions built on top of bitcoin’s base layer, but we will be focusing on the lightning network in this guide.
What is a payment channel? #
A payment channel is a joint account where two parties agree to bypass recording their payments on the blockchain. Opening a payment channel involves them locking up funds in a transaction. This enables faster and cheaper subsequent payments between the two parties as they only update their balances in the payment channel. A new transaction is created for each update, but it is only published when the parties agree to close the channel.
The lightning payment network #
The lightning network is a network of payment channels. Lightning nodes allow you to have multiple channels with different parties to route payments through. This new network forms a second layer on top of bitcoin. This has some privacy benefits, too: payment information is only recorded to the blockchain when the payment channel is opened and closed. Every payment that happens in between the opening and closing is not stored “on-chain”.
What are ways to receive bitcoin? #
To transfer bitcoin, the recipient needs to provide the sender with the destination for the payment. On the base layer, this is typically done in the recipient’s wallet application by generating and sharing an address. For lightning payments, an invoice is used. While base layer transactions update balances on the public ledger, lightning invoices contain information for a payment to be routed through the network of payment channels.
How are payments routed? #
To make a lightning payment, you don’t need to open a channel with everyone you transact with. Lightning nodes talk to one another and declare their payment channels. It’s typical for nodes to have multiple channels to access different parts of the network for better routing. With an invoice, the sender finds a path to the receiver, and the payment hops from channel to channel until it reaches the destination.
What are hot and cold private keys? #
Just like a key for a door, a private key gives you access to your bitcoin. Private keys authorize the movement of bitcoin on the base layer as well as lightning.
Lightning node private keys are referred to as hot as they are stored on a device that is connected to the internet. This is not typically advised for storing large amounts as it is possible for a remote attacker to get access to that device. A more secure way to store private keys is cold storage, which is not connected to the internet.
There’s a lot more #
These are some of the basic technical concepts that make bitcoin work. Each one individually is complex, and the interplay between them is a whole other area of interest. Dive into the other chapters in this guide to explore the technology and its applications in more detail.
Now, if you’d like to go all the way to the beginning of bitcoin, the most fundamental read is the bitcoin whitepaper. Published on October 31, 2008, by the mysterious Satoshi Nakamoto, it lays out the fundamental system design in only nine short pages. It is not necessarily an easy read, but still highly recommended reading.
A good bitcoin product isn’t just about using specific technologies: it should also be shaped by specific design principles.