4.1 Introduction
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.
4.2 Basic transaction structure
Every Bitcoin transaction consists of: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’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.
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.
4.5 Outputs explained
Outputs specify:- The destination (Bitcoin address).
- The amount of bitcoin to send.
- The locking script (usually a public key hash).
- 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.
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.
- High fees,
- Privacy leaks,
- Stuck transactions.
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.