How Child Pays For Parent (CPFP) Works: Mathematical Fee-Bumping and Miner Scoring
How Child Pays For Parent (CPFP) Works: Mathematical Fee-Bumping and Miner Scoring
When a transaction is broadcast with a fee rate that is too low to satisfy current network demand, it can become stuck indefinitely in mempools. Child Pays For Parent (CPFP) is a fee-bumping technique that allows a recipient (or a sender spending a change output) to accelerate the stuck parent transaction by creating a high-fee child transaction.
This guide details the mathematical scoring mechanisms miners use to evaluate unconfirmed packages and select them for inclusion in candidate blocks.
1. The Core Mining Dilemma
Miners compile transactions into candidate blocks to maximize their fee revenue. However, a miner cannot select a child transaction for a block unless all of its ancestor transactions are also included in that block.
If a parent transaction $T_P$ has a low feerate ($1\text{ sat/vB}$) and its child transaction $T_C$ has an extremely high feerate ($100\text{ sat/vB}$), the miner cannot simply mine $T_C$ and pocket the premium. To capture the fee on $T_C$, they must also mine $T_P$.
To solve this dependency problem, mining algorithms evaluate transactions not in isolation, but as packages of ancestors.
2. The Mathematical Package Formula
When evaluating a transaction $T$, a miner’s mempool scoring engine calculates its Ancestor Feerate (also referred to as its mining score):
$$F_{\text{package}}(T) = \frac{\text{Fee}(T) + \sum_{A \in \text{Ancestors}(T)} \text{Fee}(A)}{\text{Size}(T) + \sum_{A \in \text{Ancestors}(T)} \text{Size}(A)}$$
Where:
-
$\text{Ancestors}(T)$ is the set of all unconfirmed parent transactions of $T$ that are currently in the mempool.
-
$\text{Size}$ is measured in virtual bytes (vB).
-
$\text{Fee}$ is denominated in satoshis (Sats).
3. Step-by-Step Mathematical Example
Let's walk through a live scenario where a user has received a payment that is stuck in the mempool:
The Stuck Parent ($T_P$):
-
Size: $250\text{ vB}$
-
Fee: $250\text{ Sats}$ (Feerate: $1\text{ sat/vB}$)
-
Status: Stuck (Current market rate is $20\text{ sat/vB}$)
The Bumping Child ($T_C$):
The recipient spends the unconfirmed output from $T_P$ to construct a child transaction $T_C$ back to themselves:
-
Size: $200\text{ vB}$
-
Fee: $10,000\text{ Sats}$ (Individual Feerate: $50\text{ sat/vB}$)
Miner Package Evaluation:
A miner scans the mempool and computes the package feerate for $T_C$:
$$\begin{aligned} F_{\text{package}}(T_C) &= \frac{\text{Fee}(T_C) + \text{Fee}(T_P)}{\text{Size}(T_C) + \text{Size}(T_P)} \ F_{\text{package}}(T_C) &= \frac{10,000 + 250}{200 + 250} \ F_{\text{package}}(T_C) &= \frac{10,250\text{ Sats}}{450\text{ vB}} \approx \mathbf{22.78\text{ sat/vB}} \end{aligned}$$
The Outcome:
Because the collective package score of $22.78\text{ sat/vB}$ exceeds the current market clearance rate of $20\text{ sat/vB}$, the miner's block selection algorithm includes both $T_P$ and $T_C$ in their next candidate block.
⚡ 4. Package Relay and BIP 331 (Mempool Constraints)
Historically, CPFP suffered from a critical bootstrap problem on the P2P network layer:
THE BOOTSTRAPPING BOTTLENECK
┌──────────────────────────────────────┐
│ Child Transaction (50 sat/vB) │
└──────────────────┬───────────────────┘
│ (Rejected!)
▼
┌──────────────────────────────────────┐
│ Parent Transaction (0.5 sat/vB) │
│ * Below local minrelaytxfee (1 sat) │
└──────────────────────────────────────┘
-
The Relay Block: If a parent transaction $T_P$ was broadcast with a fee rate below a node's local
minrelaytxfee(e.g., $0.5\text{ sat/vB}$), the node would immediately reject $T_P$ and refuse to add it to its mempool or propagate it. -
The Child Trap: Since the parent transaction was never accepted into the node's mempool, the high-fee child transaction $T_C$ would also be rejected as "orphaned" (inputs spend from a non-existent parent).
-
The Solution (BIP 331 - Package Relay): To resolve this, modern Bitcoin Core protocols implement Package Relay. This allows peers to announce and transmit groups of transactions together (e.g., $T_P + T_C$ as a single bundle), letting the high-fee child sponsor the parent through the gossip layer.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: