Understanding Bitcoin's UTXO Structure, Transaction Scripts, and RBF/CPFP Operations


3 min read

Understanding Bitcoin's UTXO Structure, Transaction Scripts, and RBF/CPFP Operations

Let's delve into the fascinating world of Bitcoin and explore its UTXO structure, transaction scripts, and the intriguing operations of RBF (Replace-by-Fee) and CPFP (Child-Pays-for-Parent).

Understanding Bitcoin's UTXO Structure

UTXO stands for Unspent Transaction Output. It's a crucial concept in the Bitcoin blockchain that fundamentally defines how transactions are structured.

In Bitcoin, when someone sends you funds, they're not sending you coins per se, but rather they're "locking" a certain amount of Bitcoin in an output, which is represented as a UTXO. Each UTXO has:

  1. An Amount: The number of Bitcoins it represents.

  2. A Locking Script: A script (written in Bitcoin Script language) that defines the conditions under which the UTXO can be spent.

  3. A Reference to the Transaction: The transaction that created the UTXO, identified by its transaction ID and output index.

For example, let's consider a simplified UTXO:

  • Amount: 0.5 BTC

  • Locking Script: OP_DUP OP_HASH160 <public_key_hash> OP_EQUALVERIFY OP_CHECKSIG

  • Transaction Reference: Transaction ID: abc123, Output Index: 0

When you spend this UTXO, you provide a new transaction with an unlocking script that satisfies the conditions set by the locking script. The new transaction consumes this UTXO and creates new UTXOs as outputs.

Bitcoin Transaction Scripts

Bitcoin transactions use a scripting language to determine the spending conditions for UTXOs. The most common transaction script is the Pay-to-Public-Key-Hash (P2PKH) script. Here's an example:

  • Locking Script (ScriptPubKey): OP_DUP OP_HASH160 <public_key_hash> OP_EQUALVERIFY OP_CHECKSIG

  • Unlocking Script (ScriptSig): <signature> <public_key>

When spending this UTXO, the unlocking script provides a valid signature and public key that satisfies the locking script's conditions.

Bitcoin's RBF (Replace-by-Fee)

RBF, or Replace-by-Fee, is a mechanism that allows users to replace a pending (unconfirmed) transaction with a new one that includes a higher transaction fee. This is useful when a transaction is taking too long to confirm, and you want to expedite the process.


  1. You send 1 BTC to Alice with a low fee, and the transaction is stuck in the mempool (unconfirmed).

  2. You create a new transaction with the same inputs but a higher fee.

  3. Miners prioritize the second transaction because of the higher fee, and it gets confirmed.

Bitcoin's CPFP (Child-Pays-for-Parent)

CPFP, or Child-Pays-for-Parent, is a method to speed up the confirmation of a low-fee transaction by creating a dependent transaction with a higher fee.


  1. You send 0.5 BTC to Bob with a low fee, and this transaction is stuck.

  2. You send 0.5 BTC back to yourself (as a new transaction) with a high fee, making it dependent on the first transaction.

  3. Miners see that including the second transaction would make the first transaction's fee reasonable, so they include both transactions in a block.

These mechanisms, along with the UTXO structure and Bitcoin's scripting language, underpin the functionality and flexibility of the Bitcoin blockchain, allowing users to manage transactions, fees, and confirmations in a way that suits their needs.