The distributed ledger
At a financial institution, the ledger is the principal book for recording all financial transactions. Bitcoin maintains a ledger for bookkeeping transactions of coins and other transactions. The difference is that a bank's ledger is centralized, and bitcoin's ledger is distributed. Consequently, a bank's ledger is at risk of being manipulated for nefarious purposes, that is, cooking the book. On the other hand, bitcoin's ledger is very difficult to be changed.
Blockchain's ledger consists of entries resulting from transactions entered by users, where users submit transactions. Each transaction contains the following information:
- Sources (from the address) of the coins to be transferred from
- The number of coins to be transferred
- Destinations (send-to address) where coins should be transferred to
Both source and destination addresses are 64-character hashes. Here is an example:
979e6b063b436438105895939f4ff13d068428d2f71312cf5594c132905bfxy1
An address is like a customer's bank account number. However, there are fundamental differences between them. For example, a bank has a centralized place for saving metadata on an account, for example, the customer name, account open date, and account type, and so on. Also, the balance of an account is calculated and saved. A bitcoin address does not have metadata and maintains no balance. Addresses are referred to only in bitcoin transactions. When an address does not contain any unused coins, a new request for transferring a coin from the address will fail a transaction validation due to an insufficient fund error.
A bitcoin coin does not associate with a physical object such as a file or a physical coin. Only transactions and addresses support its existence. For example, if you want to know the total number of coins that have been minted so far, you have to go through all addresses with unused coins and add them up.
When a user enters a transaction request at a node, bitcoin software installed at the node broadcasts the transaction to all nodes. Nodes on the network will validate the transaction by retrieving all historical transactions containing the input addresses and ensuring that coins that are transferred out from these addresses are legitimate and sufficient. After that, the mining nodes start to construct a block by collecting the validated transactions. Normally, one block contains between 1,500 and 2,000 transactions. If a miner wins a race for resolving a difficult puzzle, the miner gets the role for adding the new block to the blockchain. Bitcoin takes approximately every 10 minutes to add a new block.
A bitcoin blockchain can diverge due to protocol change, software upgrade, or fixing hacked blocks. The splitting point where the divergence starts is called a fork. There are temporary forks and permanent forks. If a permanent fork occurs due to, for example, malicious attacks, it is called a hard fork. If a permanent fork occurs due to configuration or a software upgrade, it is called a soft fork. A hard fork makes previously invalid blocks/transactions valid, and a soft fork makes previously valid blocks/transactions invalid.