How Bitcoin Works

Mario Dian Sep 27, 2016 7 min read

The Bitcoin network operates on a decentralized infrastructure, where every participant plays a vital role in facilitating these transactions. These participants, known as nodes, are individuals or entities that maintain a copy of the blockchain, a digital ledger that records all transactions ever made in the network.

To initiate a bitcoin transaction, the sender creates a digital document known as a transaction message. This document includes the recipient's bitcoin address, the amount being sent, and other relevant details. The sender then broadcasts this transaction message to the network.

Once the transaction message reaches the network, the nodes within it begin a process called validation. They verify the validity of the transaction by checking various factors, such as whether the sender has sufficient funds and whether the transaction adheres to all the network's rules and protocols.

After the validation process, the transaction is added to a pool of unconfirmed transactions known as the mempool. Miners, which are specialized nodes in the network, select transactions from the mempool and include them in a new block. Miners compete to solve a complex mathematical puzzle in order to earn the right to add their block to the blockchain.

Once a miner successfully adds a block to the blockchain, the transactions contained within it are considered confirmed. At this point, the bitcoins sent from the sender's address are deducted and added to the recipient's address, effectively completing the chain of reaction.

It is important to note that while all participants in the network are involved in the transaction process, individual users typically interact with a software interface, such as a digital wallet, that handles the complexity of interacting with the network. This interface allows users to easily send and receive bitcoins without needing to understand the intricate workings of the network.

Overall, the chain of reaction involved in sending bitcoins ensures the integrity and security of transactions within the Bitcoin network, allowing users to transfer value across the globe with trust and transparency.

Send bitcoins

Sending bitcoins on the network is a process that involves constructing a Bitcoin transaction (TX) and digitally signing inputs. Each transaction, except for the first one called coinbase, consists of one or more inputs that represent unspent outputs (UTXO set) from previous transactions.

To illustrate this process, let's consider the scenario where Bob wants to send 0.5 BTC to his friend Alice. Bob starts by constructing a transaction using the unspent output of 50 BTC that he possesses. This unspent output serves as the input for the transaction, representing the value being spent.

Bob pays 0.5 BTC to Alice

Bob then signs this input with his private key to verify his ownership and authorizes the transfer. Once the input is signed, Bob broadcasts the transaction (TX A) onto the Bitcoin network, making it visible to other participants.

Now, since Bob doesn't want to send the entire 50 BTC output to Alice, he includes a change address in the transaction. This change address is where the remaining 49.5 BTC will be sent, instead of going towards transaction fees paid to miners.

To draw an analogy, think of the change address as the money returned to you when you pay $5 for a $20 product with a $20 bill. Instead of tearing the bill into two parts, you hand over the $20 bill and receive $15 as change.

Once the transaction is confirmed on the network, Alice receives the 0.5 BTC from Bob, along with other amounts she has received from different individuals in various transactions. These amounts form her unspent outputs, representing the value she currently possesses.

At a later point, Alice decides to spend all her accumulated bitcoins at once by sending them to her employee. To accomplish this, she creates a new transaction (TX B) that includes one input referencing all three of her unspent outputs. She signs this input using her private keys and broadcasts the transaction onto the network.

By constructing a transaction with multiple inputs and outputs, Alice is able to combine her unspent outputs and transfer them to her employee in a single transaction, simplifying the process and reducing transaction fees.

Overall, the process of sending bitcoins involves constructing transactions with signed inputs and utilizing change addresses, allowing users to manage their digital currency efficiently while ensuring secure and transparent transactions on the Bitcoin network.

Confirm the Transaction

Once a transaction (TX) is broadcasted on the network, it enters some/most nodes' "mempool", which can be thought of as a waiting area in the system's memory. Mempool contains a list of all unconfirmed transactions that have been submitted and are awaiting verification by miners.

Miners play a crucial role in the cryptocurrency ecosystem. They are individuals or companies who actively participate in the process of maintaining and securing the network. One of their primary tasks is to pick up transactions from mempool and include them in a new block of transactions, which will then be added to the blockchain. In order to do this, miners compete with each other by solving complex mathematical problems.

Mining is a computationally intensive and expensive process. Miners utilize significant computational power to solve these problems, aiming to find a specific hash value that meets certain criteria. The first miner to solve the problem is rewarded with newly created bitcoin and transaction fees associated with the transactions included in the block. This incentivizes miners to dedicate computational resources and compete with others to process transactions and maintain the security of the network.

Due to the competitive nature of mining and the limited capacity of each block, not all transactions in mempool can be immediately included. Miners typically prioritize transactions with higher fees attached to incentivize faster processing. As a result, some transactions may wait in mempool for a certain period until they are chosen by a miner for processing.

How Mining Works

Upon selecting transactions from the mempool based on their own specific criteria, a miner incorporates the transactions into a new block. They then combine the block's data with the header of the previous block.

Following this, a nonce, which is an arbitrary and unique number, is added to the block header and hashed. In order to achieve the desired outcome, the miner repeatedly applies this hashing operation while incrementing the nonce, generating a completely new hash each time. The process continues until the resulting hash is equal to or below the mining target.

The mining target is a large 256-bit string, serving as a benchmark for the difficulty level of finding the correct hash. As the value of the target decreases, it becomes increasingly challenging to find a hash that satisfies the requirement.

To illustrate, let's consider a random number generator that produces a fixed set of numbers from 0 to 100. It is easy to generate a number that is less than or equal to 100, with a probability of 100%. Any number produced would fulfill the condition. However, if we lower the threshold, the likelihood of generating a number that meets the requirement diminishes significantly.

Cryptocurrencies – Hack your way to a better life

"In a world of centralized currency, new coins go to whoever the money printer (central bank, commercial banks or the state) choses as a recipient of those coins. In a world of decentralized currency, we want the distribution to be fair, so Satoshi Nakamoto, the creator of Bitcoin, invented mining."

Order Now Order on Amazon

To maintain the desired rate of approximately one block being mined every 10 minutes, the mining target must be periodically adjusted. This adjustment occurs after every 2016 blocks, corresponding to roughly two weeks. Given that miners enter and exit the network over time, this readjustment is necessary to ensure that the difficulty remains appropriate for the computational power dedicated to mining.

When a miner successfully discovers the correct hash, they announce it to the network. Additionally, this miner is rewarded for their efforts. They receive the entirety of the fees included in the block, which are payments made by users for their transactions to be prioritized, as well as the block reward. Currently, the block reward stands at 12.5 BTC per block.

Verify the New Block

After a newly created block is broadcasted on the network, it undergoes a crucial process of verification conducted by full nodes. In the realm of the Bitcoin network, a full node refers to a computer running Bitcoin software that enforces specific network rules, known as "consensus rules," which are explicitly outlined in a bitcoin-core client.

Each newly generated block must go through the scrutiny of these full nodes, which meticulously examine the included transactions and the block itself to ensure compliance with the consensus rules. Should any discrepancies or violations be detected, the block is unequivocally rejected by the client, thus preventing its inclusion in the blockchain.

This meticulous design serves a vital purpose in the Bitcoin ecosystem by holding miners accountable. Miners, individuals or organizations that dedicate computational power to solve complex mathematical puzzles and add blocks to the blockchain, are motivated by the possibility of receiving rewards for their efforts. However, these rewards come at a cost in the form of electricity consumption.

By subjecting every block to examination against the consensus rules, the network ensures that miners adhere to the prescribed guidelines. If a miner attempts to include transactions or employ block properties that violate these rules, their block will be deemed invalid. Consequently, the expended electricity and computational resources invested in that block would go to waste, serving as a powerful deterrent against non-compliance.

In essence, the comprehensive verification process carried out by full nodes establishes a robust system where miners are incentivized to follow the rules. This mechanism aligns the interests of participants in the network, reinforcing the integrity and security of the blockchain.

If you are interested in delving further into the intricate details of the Bitcoin protocol, I highly recommend reading the original Bitcoin Whitepaper, authored by Satoshi Nakamoto. This seminal document lays the foundation of the Bitcoin network and provides vital insights into its inner workings, making it an invaluable resource for understanding the principles and mechanisms behind the world's first cryptocurrency.

Found this valuable?

Please consider supporting us. Thank you!

Support us