Understanding Bitcoin Transactions
A transaction represents the transfer of Bitcoin value across the network, eventually recorded in blocks. These transactions reference previous outputs as inputs, allocating Bitcoin values to new outputs. Unlike encrypted data, Bitcoin transactions are transparent—anyone can examine them once they're included in a block. After sufficient confirmations, transactions become irreversible.
Key Features of Bitcoin Transactions
- Transparency: All transactions are publicly visible on the blockchain.
- Decentralization: Verified by network participants without central authority.
- Immutability: Once confirmed, transactions cannot be altered.
👉 Explore Bitcoin transactions in depth
Structure of a Bitcoin Transaction
Below is the standard format of a Bitcoin transaction within a block:
| Field | Description | Size |
|---|---|---|
| Version no | Typically 1 (2 for OP_CHECKSEQUENCEVERIFY timelocks) | 4 bytes |
| Flag | Indicates Segregated Witness data (0001 if present) | Optional 2 bytes |
| In-counter | Number of inputs (VarInt) | 1–9 bytes |
| List of inputs | References to previous transaction outputs | Variable |
| Out-counter | Number of outputs (VarInt) | 1–9 bytes |
| List of outputs | New Bitcoin allocation instructions | Variable |
| Witnesses | SegWit validation data (if applicable) | Variable |
| Lock_time | Block height/timestamp for finalization | 4 bytes |
Note: Version 0 transactions are undefined, while versions >2 are reserved for future use.
Transaction Inputs and Outputs
- Inputs: Reference past transaction outputs, providing proof of ownership via signatures.
- Outputs: Specify conditions to spend Bitcoin (e.g., recipient addresses).
Example: Single-Input Transaction
Input:
Previous tx: f5d8...b9a6 (50 BTC source)
Index: 0
scriptSig: [Signature + Public Key]
Output:
Value: 5000000000 satoshis (50 BTC)
scriptPubKey: [Recipient's address conditions]Verification Process
- The input's
scriptSigexecutes, leaving data on the stack. - The referenced output's
scriptPubKeyuses this data to validate the transaction. - If
scriptPubKeyreturnstrue, the input is authorized.
Types of Bitcoin Transactions
1. Pay-to-PubkeyHash (P2PKH)
- Most common transaction type.
- ScriptPubKey:
OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG - Recipient provides signature + public key to redeem.
2. Pay-to-Script-Hash (P2SH)
- For complex scripts (e.g., multisig wallets).
- ScriptPubKey:
OP_HASH160 <ScriptHash> OP_EQUAL - ScriptSig: Must provide a script matching the hash.
👉 Learn advanced Bitcoin scripting
Mining and Generation Transactions
Coinbase Transaction: First transaction in a block, creating new Bitcoin.
- Input: Contains "coinbase" data (miner's arbitrary info).
- Output: Typically includes block reward + transaction fees.
- Extranonce: Allows miners to expand proof-of-work possibilities.
Transaction Components in Detail
Input Format (Txin)
| Field | Description | Size |
|---|---|---|
| Previous TX Hash | Hash of the referenced transaction | 32 bytes |
| Previous Txout-index | Output index in the referenced TX | 4 bytes |
| ScriptSig | Unlocking script | Variable |
| Sequence_no | Used for lock_time transactions | 4 bytes |
Output Format (Txout)
| Field | Description | Size |
|---|---|---|
| Value | Satoshis to transfer | 8 bytes |
| ScriptPubKey | Locking script conditions | Variable |
FAQs About Bitcoin Transactions
How long does a Bitcoin transaction take?
- Typically 10–60 minutes (1 confirmation). For high-value transactions, wait for multiple confirmations.
Can I cancel a Bitcoin transaction?
- No. Once broadcast, transactions are irreversible. Double-spending is prevented by consensus rules.
What are transaction fees?
- Fees incentivize miners to include transactions in blocks. They vary based on network congestion.
What is Segregated Witness (SegWit)?
- A protocol upgrade separating signature data from transaction data, increasing block capacity.
Conclusion
Bitcoin transactions form the backbone of the network's operation, enabling secure, transparent value transfer. Understanding their structure—from inputs/outputs to scripting—empowers users to interact confidently with the blockchain. Whether you're sending P2PKH payments or multisig transactions, the principles remain grounded in cryptographic verification and decentralized consensus.
For further reading, explore Bitcoin scripting or raw transaction formatting.