beginner

How Bitcoin Transactions Work: A Complete Technical Guide

Learn the mechanics of Bitcoin transactions, from creating a transaction to confirmation on the blockchain.

18 min read
February 14, 2025
BF
Byte Federal Team
Blockchain Specialists
How Bitcoin Transactions Work: A Complete Technical Guide

Introduction: Understanding the Mechanics of Bitcoin

Every time someone says "I sent you some bitcoin," a fascinating process unfolds across thousands of computers worldwide. Bitcoin transactions aren't like traditional electronic payments—they don't involve banks moving entries between accounts. Instead, they're cryptographically signed messages broadcast to a decentralized network, verified by thousands of nodes, and permanently recorded in the blockchain.

Understanding how Bitcoin transactions work is crucial for anyone using Bitcoin, whether you're making your first purchase at a Bitcoin ATM or managing a corporate treasury. This article provides a technical deep-dive into transaction mechanics, from creation to confirmation.

Transaction Fundamentals

What is a Bitcoin Transaction?

A Bitcoin transaction is a signed data structure that transfers value from transaction inputs to transaction outputs. Think of it as a digital check that:

  • Specifies which bitcoins are being spent (inputs)
  • Declares where they're going (outputs)
  • Proves you have the right to spend them (signature)
  • Cannot be altered once signed

Unlike traditional banking where transactions update account balances, Bitcoin uses an unspent transaction output (UTXO) model. There are no "accounts" in Bitcoin—only collections of unspent outputs that you control with your private keys.

The UTXO Model

Every bitcoin in existence is stored in an unspent transaction output (UTXO). When you check your Bitcoin wallet balance, you're really seeing the sum of all UTXOs that your private keys can spend.

Think of UTXOs like physical bills in your wallet:

  • You might have a $50 bill, two $20 bills, and a $10 bill (totaling $100)
  • To pay $60, you can't split the $50—you give both the $50 and one $20, getting $10 in change
  • Similarly, Bitcoin UTXOs can't be partially spent—you must spend the entire UTXO and create change outputs

Example: If you have a 1 BTC UTXO and want to send 0.3 BTC to someone:

  1. You create a transaction spending the entire 1 BTC UTXO
  2. Output 1: 0.3 BTC to recipient's address
  3. Output 2: 0.699 BTC back to your address (change)
  4. The remaining 0.001 BTC becomes the miner fee

Anatomy of a Bitcoin Transaction

Transaction Inputs

Transaction inputs reference previous transaction outputs that you want to spend. Each input contains:

  • Previous Transaction Hash: Points to the transaction containing the UTXO you're spending
  • Output Index: Which specific output from that transaction you're spending
  • ScriptSig: Your digital signature proving you have the right to spend this UTXO
  • Sequence Number: Enables advanced features like Replace-By-Fee (RBF)

Transaction Outputs

Outputs specify where bitcoins are going. Each output contains:

  • Amount: How many satoshis (1/100,000,000 of a bitcoin)
  • ScriptPubKey: Conditions that must be met to spend this output in the future

The most common output type is Pay-to-Public-Key-Hash (P2PKH), which says: "These bitcoins can be spent by whoever can prove they own the private key corresponding to this Bitcoin address."

Transaction Metadata

Additional transaction fields include:

  • Version Number: Identifies which Bitcoin protocol rules this transaction follows
  • Locktime: Optional field specifying when the transaction can be added to the blockchain
  • Witness Data: For SegWit transactions, contains signatures separated from transaction data

The Transaction Lifecycle

Step 1: Transaction Creation

When you want to send bitcoin, your wallet software:

  1. Selects UTXOs to spend (coin selection)
  2. Creates outputs for recipient and change
  3. Calculates the fee based on transaction size and desired confirmation speed
  4. Generates the transaction data structure

Step 2: Digital Signing

Your wallet uses your private key to create a digital signature proving you own the UTXOs being spent. This process:

  • Takes the transaction data
  • Hashes it using SHA-256 and RIPEMD-160
  • Signs the hash with your private key using ECDSA (Elliptic Curve Digital Signature Algorithm)
  • Adds the signature to the transaction's scriptSig field

The signature proves three things:

  1. You possess the private key corresponding to the Bitcoin address
  2. The transaction data hasn't been tampered with
  3. You explicitly authorized this specific transaction

Step 3: Broadcasting

Once signed, your wallet broadcasts the transaction to Bitcoin nodes. This propagation happens through:

  1. Your wallet sends the transaction to nodes it's connected to
  2. Those nodes validate the transaction
  3. Valid transactions are relayed to their peer nodes
  4. Within seconds, the transaction reaches thousands of nodes globally

Step 4: Mempool Entry

Unconfirmed transactions wait in each node's mempool (memory pool). The mempool:

  • Stores unconfirmed transactions temporarily
  • Orders them by fee rate (satoshis per byte)
  • Removes transactions once they're included in blocks
  • May drop low-fee transactions if space is limited

You can view the current mempool state at mempool.space, which shows pending transactions and estimated confirmation times.

Step 5: Mining and Confirmation

Miners select transactions from the mempool to include in the next block:

  1. Transaction Selection: Miners typically prioritize high-fee transactions
  2. Block Creation: Selected transactions are assembled into a candidate block
  3. Proof-of-Work: Miners compute billions of hashes trying to solve the mining puzzle
  4. Block Propagation: When a miner succeeds, they broadcast the new block
  5. Confirmation: The transaction receives its first confirmation

Step 6: Additional Confirmations

Each new block added after the one containing your transaction adds another confirmation. Standard practice:

  • 1 confirmation: Sufficient for small purchases (coffee, retail)
  • 3 confirmations: Standard for medium-value transactions
  • 6+ confirmations: Required for large transactions (exchanges, high-value purchases)

Why wait for multiple confirmations? Each confirmation makes the transaction exponentially harder to reverse, protecting against potential blockchain reorganizations.

Transaction Types and Scripts

Pay-to-Public-Key-Hash (P2PKH)

The original and most common transaction type. Outputs are locked to a Bitcoin address (which is a hash of a public key). To spend, you must provide:

  • The public key that hashes to the address
  • A valid signature from the corresponding private key

Bitcoin addresses starting with "1" use P2PKH.

Pay-to-Script-Hash (P2SH)

P2SH enables more complex spending conditions by allowing the recipient to specify a script hash. Common uses include:

  • Multi-signature: Requiring signatures from multiple keys
  • Time-locks: Locking funds until a specific time
  • Complex contracts: Custom spending conditions

Bitcoin addresses starting with "3" use P2SH.

Segregated Witness (SegWit)

SegWit (activated in 2017) separates signature data from transaction data, providing:

  • Lower fees: Signature data is discounted in fee calculations
  • Larger blocks: More transactions per block
  • Transaction malleability fix: Enables Lightning Network and other layer-2 solutions

SegWit addresses start with "bc1" (bech32 format).

Taproot (2021)

Bitcoin's most recent upgrade improves privacy and efficiency:

  • Simple and complex transactions look identical on-chain
  • Enables Schnorr signatures (more efficient than ECDSA)
  • Supports signature aggregation for multi-sig transactions

Taproot addresses also start with "bc1" but use bech32m encoding.

Transaction Fees: Economics and Optimization

How Fees Work

Bitcoin transaction fees are calculated as:

Fee = Total Inputs - Total Outputs

The "missing" bitcoin becomes the miner's reward. Fees are typically expressed in satoshis per virtual byte (sat/vB), with higher rates resulting in faster confirmations.

Factors Affecting Transaction Size

Transaction size depends on several factors that directly affect fees. The number of inputs dominates size calculations—more inputs create larger transactions requiring higher fees, making UTXO consolidation during low-fee periods economically important. Number of outputs slightly increases size, though far less dramatically than inputs. Address type significantly impacts efficiency: SegWit transactions consume approximately 40% less space than legacy transactions, translating directly to lower fees. Script complexity adds overhead—multi-signature setups and complex spending conditions require more data than simple single-signature transactions, increasing costs proportionally.

Fee Estimation Strategies

Modern wallets estimate appropriate fees based on:

Modern wallets employ sophisticated fee estimation analyzing current mempool state to assess network congestion, your desired confirmation time to determine necessary fee competitiveness, and historical data revealing recent confirmation patterns. This multi-factor analysis produces fee recommendations balancing cost against urgency. During periods of high network activity—bull markets, major news events, popular NFT mints—fees can spike from mere cents to $50 or more per transaction as users compete for limited block space. Planning transactions during low-activity periods and consistently using SegWit addresses helps minimize costs across all market conditions.

Fee Optimization Techniques

Fee optimization techniques dramatically reduce transaction costs. Batch transactions combine multiple payments into single transactions, amortizing overhead across recipients—exchanges and services use batching to reduce per-payment costs by 70%+. Using SegWit addresses reduces transaction size by approximately 40%, directly cutting fees proportionally. Timing transactions strategically during low-activity periods like weekends or late nights UTC takes advantage of reduced network congestion when fee competition eases. UTXO consolidation combines many small UTXOs during low-fee periods, preventing future high-fee situations where spending requires combining numerous inputs. Replace-By-Fee (RBF) allows starting with conservative low fees and increasing only if confirmation delays prove problematic, saving money when initial estimates prove adequate.

Advanced Transaction Features

Replace-By-Fee (RBF)

RBF allows you to increase the fee on an unconfirmed transaction by broadcasting a replacement transaction with:

RBF replacement transactions use the same inputs as the original transaction, include a higher fee to incentivize miners, and employ a special sequence number signaling RBF capability to network nodes. This mechanism proves invaluable when you underestimate fees and transactions languish unconfirmed in the mempool—simply broadcast a replacement paying miners more to prioritize your transaction. Note that RBF must be signaled in the original transaction; you cannot retroactively add RBF to transactions created without it.

Child-Pays-For-Parent (CPFP)

CPFP allows you to speed up a stuck transaction by:

  1. Creating a new transaction that spends outputs from the unconfirmed transaction
  2. Including a high enough fee to make mining both transactions profitable

Miners will include both the "parent" (original) and "child" (new) transactions together since the child can't be mined without the parent.

Time Locks

Bitcoin supports two types of time locks:

  • nLockTime: Prevents transaction from being mined until a specific block height or time
  • nSequence/CSV: Requires a relative time delay from when a UTXO was confirmed

Time locks enable sophisticated contracts like Lightning Network payment channels and hash time-locked contracts (HTLCs).

Multi-Signature Transactions

Multi-sig requires multiple signatures to spend funds. Common configurations:

  • 2-of-2: Both parties must sign (escrow arrangements)
  • 2-of-3: Two of three parties must sign (adds a mediator or backup key)
  • M-of-N: Any M signatures from N possible keys (corporate treasury, institutional custody)

Transaction Validation

Nodes validate transactions through a comprehensive checklist:

Syntax and Data Structure Checks

  • Transaction size within limits
  • Valid number of inputs and outputs
  • Amounts within valid range (0 to 21 million BTC)

Consensus Rule Checks

  • Input UTXOs exist and are unspent
  • Sum of outputs ≤ sum of inputs
  • Scripts execute successfully (signatures are valid)
  • Transaction not in blockchain already
  • Not a double-spend of existing mempool transactions

Policy Checks (node-specific)

  • Minimum fee requirements
  • Dust limits (outputs too small to be economical to spend)
  • Standard transaction types
  • Mempool size limits

Transaction Privacy Considerations

Address Reuse

Using the same Bitcoin address multiple times significantly reduces privacy:

  • All transactions to/from that address are linked
  • Your entire transaction history becomes visible
  • Recipients can see your balance

Best practice: Use a new address for each transaction. Modern wallets automatically generate new addresses.

Change Address Management

Change outputs can leak privacy information. If you send 0.5 BTC from a 1 BTC UTXO:

  • 0.5 BTC goes to recipient
  • 0.49 BTC returns to you as change

An observer might guess which output is payment and which is change based on amount, timing, and subsequent transactions.

CoinJoin and Privacy Tools

CoinJoin transactions combine inputs from multiple users into a single transaction, making it difficult to determine which inputs paid which outputs. We'll explore CoinJoin in detail in our Bitcoin Privacy Techniques article.

Common Transaction Issues and Solutions

Stuck Transactions

Problem: Transaction remains unconfirmed for hours or days

Solutions:

  • Wait—eventually it will confirm or be dropped from mempools
  • Use RBF to increase the fee
  • Use CPFP to spend the output with a higher fee
  • Wait for mempools to clear (typically within 2 weeks)

Dust Outputs

Problem: UTXOs so small that fees exceed their value

Solution:

  • Consolidate dust UTXOs during low-fee periods
  • Set minimum output sizes in wallet settings
  • For merchants: require minimum payment amounts

Incorrect Fee Estimation

Problem: Paid too much or too little in fees

Prevention:

  • Use wallets with reliable fee estimation
  • Check current mempool state before sending
  • Enable RBF for flexibility
  • Understand urgency vs. cost tradeoffs

Conclusion: Mastering Bitcoin Transactions

Understanding Bitcoin transactions at this technical level empowers you to:

  • Optimize fees and save money
  • Troubleshoot transaction issues
  • Understand wallet behavior
  • Appreciate Bitcoin's security model
  • Make informed decisions about transaction timing and structure

Every Bitcoin transaction represents a remarkable coordination of cryptography, distributed consensus, and economic incentives. From the moment you click "send" to final confirmation on the blockchain, thousands of computers worldwide collaborate to validate, propagate, and permanently record your transaction—all without requiring trust in any central authority.

This foundational knowledge prepares you for our next topics: wallet security, managing private keys, and advanced transaction types. Understanding how transactions work is essential for safely and effectively using Bitcoin.

Key Takeaways

  • Bitcoin uses a UTXO model, not account balances
  • Transactions are signed messages that transfer ownership of UTXOs
  • Fees are calculated as input minus output, measured in sat/vB
  • Confirmations make transactions increasingly irreversible
  • Modern address types (SegWit, Taproot) reduce fees and improve privacy
  • Never reuse addresses—use a new one for each transaction
  • Understanding transaction mechanics helps optimize costs and security

Topics Covered

transactions blockchain mining

Ready to Take Action?

Put your knowledge into practice with Byte Federal's products and services.

Continue Learning

Explore more articles in this pathway to deepen your Bitcoin knowledge

Back to Fundamentals Pathway