Module 4: Anatomy of a Bitcoin Transaction
4.1 Introduction
When a user clicks "Send Bitcoin" in a wallet,
a complex series of operations happens behind the scenes.
Bitcoin transactions are cryptographic messages that:
Prove ownership of funds (by signing with private keys),
Specify how funds should be moved (inputs and outputs),
Set transaction fees,
Get broadcasted to the Bitcoin network for inclusion into a block.
A deep understanding of how Bitcoin transactions work is critical for designing secure, efficient wallet products.
4.2 Basic Transaction Structure
Every Bitcoin transaction consists of:
Component | Description |
---|---|
Inputs | References to previous UTXOs the sender controls. |
Outputs | New destinations where Bitcoin is being sent (including change back to the sender). |
Signatures | Cryptographic proofs that the sender has authority to spend the inputs. |
Fee | The difference between total inputs and total outputs. |
4.3 Real-World Example
Let's say Chinedu in Lagos wants to send Bitcoin to Kwame in Accra.
Background:
Chinedu’s wallet controls two UTXOs:
UTXO1: 0.4 BTC
UTXO2: 0.2 BTC
Chinedu wants to send 0.5 BTC to Kwame.
Process:
Chinedu’s wallet selects UTXO1 (0.4 BTC) and UTXO2 (0.2 BTC) as inputs.
Builds two outputs:
0.5 BTC to Kwame’s address.
0.099 BTC back to a new change address controlled by Chinedu.
Pays 0.001 BTC as transaction fee.
Visual:
4.4 Inputs Explained
Inputs are references to existing unspent outputs.
Each input specifies:
The transaction ID (txid) of the previous transaction.
The output index (which output inside that transaction is being spent).
A cryptographic signature proving ownership.
Inputs are how Bitcoin enforces that no one can spend someone else's money — because only someone with the correct private key can produce a valid signature.
4.5 Outputs Explained
Outputs specify:
The destination (Bitcoin address).
The amount of Bitcoin to send.
The locking script (usually a public key hash).
Every output becomes a potential UTXO — someone else's "coin" to spend in the future.
A transaction can have:
One output (simple send),
Two outputs (send + change),
Multiple outputs (batching transactions to many recipients).
4.6 Change Output
Because UTXOs are indivisible:
Chinedu cannot "cut" 0.5 BTC out of 0.6 BTC cleanly.
He must consume entire UTXOs (0.4 + 0.2 = 0.6 BTC),
Then create a new output returning leftover funds (change) back to himself.
4.7 Transaction Fees
In Bitcoin, fees are not explicitly set in the transaction.
They are calculated as:
Fee = Sum of Inputs - Sum of Outputs
In Chinedu’s example:
0.4 + 0.2 = 0.6 BTC (inputs) 0.5 + 0.099 = 0.599 BTC (outputs) Fee = 0.6 - 0.599 = 0.001 BTC
Miners prioritize transactions offering higher fee rates (sats per byte) for inclusion into blocks.
4.8 Digital Signatures
Each input must be signed by the sender’s private key.
The signature proves that Chinedu owns the UTXOs being spent.
If the signature is invalid, Bitcoin nodes reject the transaction.
Wallets automate signature creation internally — users never manually interact with raw signatures.
4.9 Visual Diagram: Bitcoin Transaction Flow
4.10 Special Transaction Types
There are more complex transaction types in Bitcoin:
Multisignature transactions: Require multiple private keys to sign.
SegWit transactions: Use segregated witness structure for lower fees.
Taproot transactions: Enable more private and flexible scripts.
Batch transactions: Multiple recipients in a single transaction.
However, at the fundamental level,
all Bitcoin transactions follow the same basic model: Inputs → Outputs → Fees → Signatures.
4.11 PM Reflection Points
If you are managing a Bitcoin wallet product:
Sending Bitcoin is not simply "debit X, credit Y" like a database.
It is about gathering real pieces of Bitcoin (UTXOs) and constructing valid signed messages to move them.
Wallets must:
Manage UTXOs properly.
Calculate correct change outputs automatically.
Estimate and offer flexible transaction fee options.
Sign all inputs securely with private keys on-device.
Poor transaction building leads to:
High fees,
Privacy leaks,
Stuck transactions.
A deep understanding of transaction structure improves both UX and user trust.
4.12 Summary of Module 4
A Bitcoin transaction:
Consumes old UTXOs (inputs).
Creates new UTXOs (outputs).
Pays a network fee.
Requires valid cryptographic signatures for each input.
Gets broadcast to the Bitcoin network for validation and inclusion into a block.
Wallets are builders of Bitcoin transactions, not just button clickers. Getting transaction construction right is essential for security, privacy, and usability.
Module 4 Complete
We now have a deep, real understanding of what happens inside a Bitcoin transaction — and why wallet apps must handle UTXO selection, change outputs, fees, and signatures carefully.