Navigating Bitcoin Transaction from “Send” to “Receive” — Visualizing its System Design and Core Components

Akshay Arora
Coinmonks
19 min readSep 11, 2023

--

Bitcoin’s design has enabled it to become a global digital asset, with a harmonious blend of cryptography and Peer-to-peer (P2P) architecture playing a crucial role in its making.

What exactly does it mean to be a global digital asset?

The illustration below presents questions for reflection, allowing you to form your views on Bitcoin as an asset.

The primary focus of this post is to explore the inner workings of a Bitcoin transaction while covering the essential components and concepts involved in the process. Let's describe the Bitcoin network’s architectural style and core components.

Let’s go!

Bitcoin’s architectural style

Bitcoin’s decentralized P2P architecture is the foundation of its existence. Nodes operate as equal peers with equal voting rights to choose which protocol version to run locally, directly exchanging information without relying on a central authority.

The outcome of block-size wars further cemented that no node or participant is above another in the network. This robust design ensures the network’s security and fault tolerance and prevents a single entity from controlling the entire network. The elegance of this architecture lies in its ability to foster a self-sustained, distributed network.

Core components

Bitcoin network is permissionless. Anyone is free to join it by running Bitcoin software locally. Bitcoin software comprises some core components.

In the Bitcoin network, participants range from retail users and investors to institutions such as exchanges, custodians, brokerages, payment providers, and energy companies. Additionally, many businesses have incorporated Bitcoin protocol into their products and services. The services created using Bitcoin use the core components that work together to facilitate the transfer of value across the network.

Let’s look at the core components.

  1. Wallets — Managing bitcoin is made easy with wallets, which are end-user applications. These apps provide a user-friendly interface to manage, send, and receive bitcoin. User onboarding happens on wallets. Wallets come in different forms, such as desktop applications, Android or Apple store apps, or hardware devices that store bitcoin offline. Some popular software bitcoin wallets are Trust Wallet, Coinbase Wallet, and Blue Wallet. Meanwhile, Trezor and Coldcard are among the popular hardware wallet devices out there. It’s important to note that we only provide examples for information purposes and do not promote these products.
  2. Nodes — Bitcoin nodes are software programs that speak the language of the Bitcoin protocol. They can download and verify Bitcoin transactions and blocks, as well as distribute them to other nodes in the P2P network. Nodes are responsible for connecting wallets to the Bitcoin network. The most widely used Bitcoin node implementation, Bitcoin Core, has an embedded wallet. Wallet applications, crypto exchanges, and web stores can connect to third-party services that manage a Bitcoin node. They can also choose to operate their nodes. Full nodes store a local copy of the Bitcoin blockchain and participate in block and transaction verification. On the other hand, some lightweight nodes only store limited data and query full nodes when they need to extract information for specific transactions.
  3. Miners — Full nodes, known as miners, utilize specialized mining software and hardware to discover and add new blocks to the blockchain. They also ensure that transactions are included in the blocks and contribute to the final settlement of transactions. Miners receive rewards in the form of new bitcoin and transaction fees when they successfully find a new block.

Now that we have introduced the main components involved, let us uncover the technical intricacies of a Bitcoin transaction.

Let’s go!

Bitcoin Transaction Lifecycle

A Bitcoin transaction involves transferring ownership of bitcoin from one party to another. In Figure 1 below, both the sender and receiver have set up their wallets. The illustration depicts how the receiver’s wallet generates a Bitcoin address to receive the currency and then shares it with the sender.

To send bitcoin, the sender receives the recipient’s Bitcoin address and enters the amount to be sent. The sender’s wallet calculates the fees and creates the transaction.

When a Bitcoin transaction is sent from the sender’s wallet through a connected node, that node shares it with its peer nodes for verification and broadcasting to the broader network. These nodes then share the transaction with their peers, and the process continues by propagating the transaction across the network.

In addition, Figure 1 illustrates a miner node mining a block that includes our transaction from sender to receiver. The figure also depicts how one of the full nodes validates the blocks by listening to incoming blocks on the Bitcoin network.

It’s important to understand that thousands of full nodes and miners operate simultaneously on the Bitcoin network. While we may have shown one node validating transactions and blocks for simplicity, in reality, every node is responsible for validating the transactions and blocks.

The diagram below illustrates the process of Bitcoin transactions from “send” to “receive” and the functioning of its core components, such as wallets, full nodes, and miners.
Figure 1 — Bitcoin transaction lifecycle in 21 steps

These are the five high-level steps in the transaction lifecycle:

  1. Bitcoin address generation
  2. Transaction construction and propagation
  3. Transaction validation
  4. Mining the block
  5. Block validation and consensus

The diagram presents a smooth and uninterrupted transaction lifecycle to make it easier to comprehend. However, in actuality, blocks and transactions may get rejected or dropped by nodes if they do not follow the consensus rules of the Bitcoin protocol. Later in the post, we will explore the consensus rules in more detail.

In the upcoming sections, we will break down the five high-level steps of the transaction lifecycle. Refer to the bottom left of Figure 1 for an overview of how these steps fit into the process.

Before we move forward, it’s important to note that the diagram above is meant to be used as a reference for the overall transaction process flow. Our goal in the following sections is to sift through these five steps by zooming in to get the finer details. This can be achieved by adding more specific information to each component.

Examining each step thoroughly can provide a clearer picture of the overall process.

Let’s get started!

1. Bitcoin address generation

The first step is Bitcoin address generation. It involves creating digital private and public keys offline within a user’s wallet rather than on the Bitcoin network. In this way, address generation is decoupled from the network itself, allowing privacy and security enhancement to be pursued at the wallet level.

Modern Hierarchical Deterministic (HD) wallets are often used when generating a Bitcoin address. HD wallets use a single master seed (a random value) from which an entire tree of key pairs can be derived.

What’s fascinating about HD wallets is that they provide a hierarchical tree structure that enables the creation of an unlimited number of addresses without needing to store their public and private keys separately. This enhances security by allowing users to generate new addresses for each transaction, reducing the risk of address reuse and potential exposure of private keys.

  • The public key (Bitcoin address derived from public key hash) is used to receive funds.
  • The private key ( the signature derived from the private key ) confirms ownership when spending bitcoin, ensuring the transaction’s safety and authenticity.
  • This public-private key duo operates through an irreversible cryptographic operation called one-way hashing.

Non-custodial wallets, such as those found in app stores or reputable hardware wallets, are easily synced with Bitcoin’s network nodes for transaction relaying through the wallet provider’s Bitcoin nodes.

These wallets require users to back up their keys and take ownership of funds.

For those seeking even more autonomy, running their node and then connecting a wallet to it is also possible for sending and receiving transactions.

Bitcoin address generation has two parts to it :

  • Wallet setup (Refer to Steps 1 to 4 in Figure 2 )
  • Bitcoin address generation (Refer to Steps 5 to 10 in Figure 2 )

Let’s explore each part separately.

Figure 2 — Bitcoin address generation

Wallet setup

To generate Bitcoin addresses, non-custodial wallets must first generate their mnemonic, seed, master public, and private keys. These master keys are then utilized to create child public and private keys for sending and receiving bitcoin. The seed and master keys themselves are not used to transact bitcoin.

  • A mnemonic is a randomly generated set of English words used as a password to access bitcoin. The phrase ‘Not your key, not your coins’ is commonly used in the Bitcoin community. It refers to a mnemonic phrase that should always be kept secret and can be used to recover bitcoin if the keys are lost or stolen. It’s common practice to back up the mnemonic. Random number generation algorithms create the mnemonic. This method was introduced in BIP-39.
Remember to back up your mnemonic.
  • A one-way hash of the mnemonic generates a seed.
  • Master Private key is, in turn, derived by a one-way hash of the seed. The master private key then uses ECDSA (‘Elliptical Curve Digital Signature Algorithm’) maths to generate a Master public key. To know more, refer to the post How does ECDSA work in Bitcoin by Blair Marshall.

Bitcoin address generation

Once the master keys are set up, they can now be used to generate as many child public and private key pairs as required.

The receiver’s public key generates a public key hash. The public key hash is then encoded using a base58 check, resulting in the final Bitcoin address that is user-friendly and easy to share.

It is important to note that this process ensures the privacy of the receiver’s public key, as it remains hidden in the background while the Bitcoin address is used for transactions. Using Bitcoin addresses simplifies sending and receiving bitcoin, making it accessible to more users.

Once the address is created, it is shared with the sender, who constructs the Bitcoin transaction and broadcasts it to the network.

Let’s see how that works in the next section!

2. Transaction construction and propagation

Constructing and transmitting Bitcoin transactions is a critical aspect of the Bitcoin protocol, as this step is directly responsible for transferring value across the network.

Transactions need not be constructed and signed while connected to the Bitcoin network. Instead, they can be constructed within wallet software without being connected to the Bitcoin network.

Once constructed, a valid transaction is promptly forwarded to all connected nodes using a technique known as flooding. Flooding simplistically means nodes share the transactions with whichever peer they are connected to in the network as they receive them. This method ensures that transactions are efficiently disseminated across the network, contributing to the decentralized nature of Bitcoin.

Transaction construction and propagation can be further divided into three steps:

  • Decoding the receiver’s address ( Refer to Steps 1 to 3 in Figure 3)
  • Constructing transaction( Refer to Steps 4 to 7 in Figure 3)
  • Transaction signing and broadcasting( Refer to Steps 6 to 9 in Figure 3)

Let’s examine the steps mentioned above in greater detail.

Figure 3— Transaction construction and propagation

Decoding the receiver’s address

When sending bitcoin, the sender’s wallet decodes the public key hash from the receiver’s address using Base58 decoding (the reverse of Base 58 encoding that was done to create a Bitcoin address earlier).

Constructing transaction

The amount of bitcoin balance to be spent is gathered and put together by selecting appropriate Unspent Transaction Outputs (UTXO) from the sender’s wallet to assemble the amount for sending to the receiver.

Let’s break down what’s inside a transaction:

  • Bitcoin transactions consist of two parts, i.e., INPUTS and OUTPUTS.
  • INPUTS are bitcoin already held in the sender’s public key hashes, which can be unlocked by the sender using their private key. These inputs are unspent outputs (UTXO) of a previous transaction that the sender has control over since receiving them.
  • Current transaction consumes these INPUTS (UTXOs) to generate new OUTPUTS (UTXOs) by getting inputs unlocked and spent. Refer to all the steps in Figure 3 for a visual perspective.
  • So, are both INPUTS and OUTPUTS called UTXOs? Correct, Both inputs and outputs in Bitcoin transactions are called UTXOs. Once the sender signs the INPUTS with a private key, they lose their ‘unspent’ status and become ‘spent.’ Understanding this is crucial for appreciating Bitcoin’s inner workings.
  • Notice how, in Figure 3, UTXO 1 and UTXO 3 are consumed as INPUTS to create UTXO A and UTXO B as transaction OUTPUTS. Also, notice that UTXO 2 and UTXO 4 have already been spent and hence not used in our transaction.
  • The recipient receives OUTPUTS in locked status, consisting of the receiver’s public key hash derived earlier and newly locked funds released by the sender’s INPUTS.

The transaction is constructed using the Bitcoin scripting language with INPUTS and OUTPUTS combined.

Next, let's dive into how the sender signs the transaction.

Transaction signing and broadcasting

Before sending a transaction, the sender’s wallet must sign it to prove that they have the funds and authorization.

  • The sender unlocks INPUTS with a script to spend UTXOs it currently holds. Signing uses the sender’s private key to create the digital signature used in the unlocking script.
  • After being signed, the transaction is broadcasted to the Bitcoin network via the wallet application.
  • The transaction quickly propagates across the nodes as it is a peer-to-peer (P2P) network.

Additional perspective on transaction construction

Transaction construction is one of the most crucial topics to understand to appreciate the inner workings of Bitcoin from a technical standpoint. However, it can be tricky to have a grasp of.

As we previously discussed, transactions in this system operate through INPUTS and OUTPUTS. INPUTS are unlocked and used up by new OUTPUTS, a unique concept compared to traditional payment systems that rely on simple debit and credit entries for balance adjustments.

Below is the diagram of transactions taken from the Bitcoin whitepaper, which shows the transaction construction.

The diagram shows Owner 1, who owns the bitcoin locked in the first transaction. Owner 1 then uses its private key to unlock its funds and release it to Owner 2 when the second transaction ( the middlebox) occurs.

Transactions diagram from Bitcoin whitepaper — page 2

To gain clarity on transaction construction, let’s overlay the components used in our diagrams onto the transactions diagram from the whitepaper (refer to Figure 4 below).

Figure 4 — Transaction construction and signing (Transactions diagram edit)

With the transaction now constructed and propagated across the network, each node’s job is to validate the transaction before sharing it with its peers.

Let's explore transaction validation in the next section!

3. Transaction Validation

We have learned that when signed INPUTS and newly created OUTPUTS are combined, they form a new transaction. However, for the transaction to be accepted by the network, it must be validated by all other nodes. The transaction is examined against a comprehensive list of criteria before it can be included in future blocks. Here are the most crucial rules a transaction is verified against at a high level.

  • The transaction is validated for the correctness of its syntax and structure.
  • Checking if INPUTS to the transaction are not already used elsewhere to avoid double-spending attempts.
  • Checking if the locking and unlocking scripts used to construct the transaction are valid.
  • Checking if INPUTS used can be traced back to some previous transactions.

If the rules are met, the transaction is accepted.

Refer to steps 1 to 3 in Figure 5 for transaction validation.

Figure 5 — Transaction validation and block construction (Mining)

A valid transaction gets added to the memory pool, a.k.a. mempool, a collection of unconfirmed transactions waiting to be included in a block. A memory pool is nothing but a storage area that keeps unconfirmed transactions. Each full node has its dedicated memory pool. During this stage, multiple transactions compete for inclusion in the next block by adding fees. Transactions with higher fees are prioritized.

Sometimes, a transaction may arrive at a node without any record of its parent transaction, which is the transaction used to consume INPUTS. This can happen because the Bitcoin network is a peer-to-peer(P2P) network where nodes share information asynchronously, resulting in delays in receiving information. In such cases, the transaction is considered an orphan and is temporarily held in the orphan transaction pool until the parent transaction arrives. Once the node receives the parent transaction, the orphan transaction is moved to the unconfirmed transaction pool.

Next, we will discuss how mining confirms the ‘unconfirmed’ transactions and contributes to their final settlement on the blockchain.

Let's go!

4. Mining

Mining secures the Bitcoin network and forms the foundation of its consensus mechanism. Refer to steps 4 to 10 in Figure 5.

Miners are full nodes using powerful hardware, often specialized circuits, to solve complex mathematical problems. Successful miners are rewarded with newly created bitcoin and transaction fees. This intricate process highlights Bitcoin’s decentralized nature, where nodes independently verify transactions, verify new blocks, and contribute to the consensus mechanism.

Miners are responsible for processing transactions by creating blocks and are rewarded with new bitcoin if they win the competition every ten minutes. Below are the steps involved in the mining process:

  • Candidate block construction
  • Mining the block — the competition!
  • Propagating the winning block

Let’s dive to the steps one by one.

Candidate block construction

As a first step, the miner picks the transactions from the mempool and assembles them into a candidate block. As the name suggests, a candidate block is a block that a miner has constructed to participate in the competition. Miner decides to put in a bunch of transactions by bundling them together and then packaging them with other block-level data attributes that make up a block header.

Remember, a block is just a data structure, like several data structures with header information and transaction data. Linked lists are the data structures most closely related to the concept of blockchain, which is essentially a chain of blocks containing data.

Refer to You don’t understand blockchain unless you know this simple data structure by Brandon Skerritt for perspective.

Mining the block — the competition!

Mining aims to clear and settle transactions to finality and achieve decentralized security.

When it comes to transactions other than Bitcoin, such as interbank transfers, account transfers, or payments through platforms like Paypal, Visa, and Mastercard, they need to go through third-party systems that can be trusted to ensure the final settlement of funds. However, the Bitcoin network has a unique feature of trustless clearing and settlement, meaning no trusted third party is needed for the final settlement. This is enabled through mining, which helps achieve decentralized and trustless settlement. Similar to how Visa and Mastercard collect their network fees, miners must also be incentivized to participate.

Companies such as Visa and Mastercard operate around the clock to process and reconcile transactions with institutions globally. Similarly, miners contribute their computing power to mine a block and receive new bitcoin as a reward. This is achieved by demonstrating proof of work through their commitment to hashing power and compilation resources.

What is proof of work?

Proof of work is an algorithm that mainly uses SHA256 to do a one-way hash of the block header and find a value less than the target value set by the network. Many online resources are available to understand one-way hashing and SHA256, so we won’t cover them here.

Refer to Figure 6 below, which demonstrates the continuous hashing of a block header and nonce by mining hardware to determine the winning block hash value.

Figure 6 — Proof of work in action

Miners compete to find a valid block hash that meets the difficulty requirement (Proof of Work). The difficulty requirement is represented by something called a target value.

  • The network sets a target difficulty level value, which the network also maintains and adjusts over time.
  • A long number in hexadecimal format represents the target value. Hexadecimal numbering uses 0–9 and A-F for its number system. For instance, the letter ‘C’ represents the hexadecimal version of the number 12.
  • Let’s assume the current target value set by the network is 0000000000A1B2C3D4E5F67890ABCDEF0123456789ABCDEF0123456789ABCDEF, which is preceded by many zeros, as we can see.
  • The miner aims to find a value less than this target by compiling the candidate block’s header and a random number (nonce). Whoever finds it first wins the competition.
keep hashing until a valid candidate block found with the condition:
{
while True:
if hash(block header + nonce) < target:
print("Block found!")
break
nonce += 1
}
  • Why is it more challenging than it seems? The reason is that the one-way SHA256 hash results cannot be reverse-engineered. Finding the winning combination of nonce and block header requires continuous trial and error with different nonce values. Miners spend their energy and resources in this hashing process, ultimately providing proof of work.
  • After successfully creating a block, the miner notifies the network of its win. However, other peers in the network must verify the block before it can be accepted, and the miner can be declared the winner.
  • It’s worth noting that the network adjusts its target value after every 2016 blocks.
  • When a block is discovered, the network awards the miner with new bitcoin via a coinbase transaction. This type of transaction occurs immediately after the block is mined and differs from standard transactions as it has no INPUTS and only an OUTPUT. The Bitcoin network directly allocates the bitcoin to the coinbase transaction as an OUTPUT, rewarding the miner for their assistance in mining the new block. This is how new bitcoin comes into existence and circulation.

When a new block is mined, the following network properties are enforced simultaneously -

  • Network security is increased — As the blockchain gets longer with every incremental block, network security increases because it becomes harder to reverse transactions due to the amount of cryptography involved, as explained in the previous section.
  • Final settlement of transactions is achieved — All transactions within the newly mined block are final settlements.
  • Bitcoin’s monetary policy is enforced in real-time — Every ten minutes, Bitcoin’s monetary policy is implemented in real-time, which includes creating currency with a set issuance rate. This removes any uncertainty about the amount of bitcoin in circulation. Newly created bitcoin is rewarded according to the current issuance schedule, ensuring the correct amount is produced — no more and no less.

Propagating the winning block

The miner writes the winning block to its blockchain data and instantaneously propagates it to the peers in the network to send a message that the miner has won the competition.

Remember that all peer nodes, even if they are not a miner, are always looking for new transactions and valid blocks to expand their version of the blockchain, thus contributing to the decentralized fact-checking nature of the Bitcoin protocol.

The following section will learn how peer nodes validate blocks according to consensus rules.

Let’’s get started!

5. Block Validation and Consensus

It is not sufficient for a miner to declare the win once a valid block is found. Just like transactions, blocks are also validated by nodes in the network. The winning block must be validated by network nodes and accepted by the network.

Validation occurs against consensus rules, which adds the block to the local blockchain. This process confirms all transactions within the block, enhances blockchain security, and expands the chain every 10 minutes. It also serves the purpose of final settlement of transactions within the block.

Nodes reach a consensus on the validity of a new block and add it to their copy of the blockchain if the block is valid. They do so by independently and locally validating the blocks.

As more blocks are mined on top of the block containing the transaction, the number of confirmations for the transaction increases. With every new block on top of the winning block, the transaction receives additional confirmation from the network. Refer to steps 1 to 5 in Figure 7 below.

The more confirmations a transaction has, the higher the confidence level that the transaction is irreversible.

Most applications widely consider that a transaction with six confirmations is settled and won’t be reversed.

Figure 7 — Block validation & consensus by full node

What happens when two miners find winning blocks simultaneously?

At times, temporary forks may occur due to more than one valid block being mined at once by two miners. Nodes take care of this phenomenon by maintaining two copies of the blockchain, i.e., a primary chain, which is the winning chain at any given time, and a secondary chain.

  • Nodes maintain a secondary chain where they add the second valid block, which is also a winning block but found around the same time as the first one. In the long run, only one block is considered as the chains progress to add more blocks on top every 10 minutes. Nodes resolve forks by choosing the longest valid chain, representing the most significant amount of Proof of Work.
  • The blockchain eventually converges to a single valid chain. As the network grows, it becomes clear which chain is the main one to be used. The longest chain always wins.

Block Validation and Consensus

To summarize, within the decentralized governance of the Bitcoin network, a node stands as the smallest autonomous unit. As previously mentioned, a node can execute essential functions of the Bitcoin protocol on a local level. It also has the power to partake in the decision-making process concerning the network’s status, given that it follows the consensus rules that oversee the validation of transactions and blocks. Below are the primary functions of a node :

  1. Node is accountable for independently verifying all transactions.
  2. Node with mining abilities can compile a collection of transactions to create a candidate block independently.
  3. Node is responsible for validating and incorporating new blocks into its local blockchain.
  4. A node can choose between its primary and secondary blockchain, representing its version of the truth and ultimately converging with reality over time.

Bitcoin’s intelligent structures are formed when independent nodes perform their specialized functions. This is how Bitcoin becomes the remarkable internet currency it is, as the collective output exceeds the sum of the individual parts.

As we end the post, I want to share a short text from the book “Mastering Bitcoin.”

Satoshi Nakamoto’s main invention is the decentralized mechanism for emergent consensus. Emergent, because consensus is not achieved explicitly — there is no election or fixed moment when consensus occurs. Instead, consensus is an emergent artifact of the asynchronous interaction of thousands of independent nodes, all following simple rules. All the properties of bitcoin, including currency, transactions, payments, and the security model that does not depend on central authority or trust, derive from this invention.

Antonopoulos, Andreas M.. Mastering Bitcoin (p. 266).

I hope you enjoyed reading it.

After conducting extensive research on Bitcoin from various sources, I created a mind map to illustrate how it operates behind the scenes.

In addition, Bitcoin is continuously being developed and updated with new features through Bitcoin Improvement Proposals (BIPs) while maintaining its core functionality and components.

This article was influenced by numerous sources, including the Bitcoin whitepaper and “Mastering Bitcoin” by Andreas Antonopoulos.

Please feel free to contact me if you have any inquiries or feedback. I am always open to discussing them.

The illustrations and diagrams were created by me using Canva and are available for reference on GitHub.

If you liked this article, connect with me!

LinkedIn | X | GitHub

--

--

Akshay Arora
Coinmonks

Product Manager @KNNX | Fintech | Bitcoin | Capital Markets