|
| 1 | +--- |
| 2 | +title: "Child Pay For Parent (CPFP)" |
| 3 | +date: 2024-01-25T15:32:14Z |
| 4 | +lastmod: "2024-07-26" |
| 5 | +draft: false |
| 6 | +category: Transactions |
| 7 | +layout: TopicBanner |
| 8 | +order: 4 |
| 9 | +icon: "FaClipboardList" |
| 10 | +images: ["/decoding-bitcoin/static/images/topics/thumbnails/musig-thumbnail.webp"] |
| 11 | +parent: "fee-calculation" |
| 12 | +--- |
| 13 | + |
| 14 | +Imagine receiving bitcoin but the transaction is stuck in the mempool. |
| 15 | +The sender used a fee that's too low, and miners aren't picking it up. |
| 16 | + |
| 17 | +<div className="dark:hidden w-full rounded-lg"> |
| 18 | + <SvgDisplay |
| 19 | + src="/decoding-bitcoin/static/images/topics/transactions/fees/cpfp-1.svg" |
| 20 | + width="100%" |
| 21 | + height="auto" |
| 22 | + /> |
| 23 | +</div> |
| 24 | +<div className="hidden dark:block w-full rounded-lg"> |
| 25 | + <SvgDisplay |
| 26 | + src="/decoding-bitcoin/static/images/topics/transactions/fees/cpfp-1.svg" |
| 27 | + width="100%" |
| 28 | + height="auto" |
| 29 | + /> |
| 30 | +</div> |
| 31 | + |
| 32 | +What can you do? This is where Child Pays For Parent (CPFP) comes in. |
| 33 | + |
| 34 | + |
| 35 | +## What is CPFP? |
| 36 | + |
| 37 | +CPFP is a fee-bumping strategy where the recipient of an unconfirmed transaction creates a new transaction (child) that spends the pending funds and includes a high enough fee to incentivize miners to confirm both transactions together. |
| 38 | + |
| 39 | + |
| 40 | +## How Does CPFP Work? |
| 41 | + |
| 42 | +Let's break it down with an example: |
| 43 | + |
| 44 | +1. Alice sends 1 BTC to Bob with a very low fee |
| 45 | +2. The transaction gets stuck in the mempool because miners ignore low-fee transactions |
| 46 | +3. Bob creates a new transaction (child) spending the unconfirmed bitcoin |
| 47 | +4. Bob attaches a high fee to the child transaction |
| 48 | +5. Miners see they can collect both fees by including both transactions |
| 49 | +6. Both transactions get confirmed in the next block |
| 50 | + |
| 51 | + |
| 52 | +<div className="dark:hidden w-full rounded-lg"> |
| 53 | + <SvgDisplay |
| 54 | + src="/decoding-bitcoin/static/images/topics/transactions/fees/cpfp-2.svg" |
| 55 | + width="100%" |
| 56 | + height="auto" |
| 57 | + /> |
| 58 | +</div> |
| 59 | +<div className="hidden dark:block w-full rounded-lg"> |
| 60 | + <SvgDisplay |
| 61 | + src="/decoding-bitcoin/static/images/topics/transactions/fees/cpfp-2.svg" |
| 62 | + width="100%" |
| 63 | + height="auto" |
| 64 | + /> |
| 65 | +</div> |
| 66 | + |
| 67 | +## Technical Details |
| 68 | + |
| 69 | +CPFP works because of two key Bitcoin concepts: |
| 70 | + |
| 71 | +1. **UTXO Model**: Bitcoin allows spending unconfirmed outputs, enabling the creation of child transactions |
| 72 | +2. **Mempool Package Evaluation**: Miners evaluate related transactions as a package, considering their combined size and fees |
| 73 | + |
| 74 | +### Fee Calculation |
| 75 | + |
| 76 | +The effective fee rate for a CPFP package is: |
| 77 | + |
| 78 | +<div className="text-center my-4 text-orange-500"> |
| 79 | + $$\text{Effective Fee Rate} = \frac{\text{Parent Fee + Child Fee}}{\text{Parent Size + Child Size}}$$ |
| 80 | +</div> |
| 81 | + |
| 82 | +CPFP is particularly useful when: |
| 83 | +- You receive a transaction with too low fees |
| 84 | +- The sender didn't enable RBF (Replace-By-Fee) |
| 85 | +- You need urgent confirmation of incoming funds |
| 86 | + |
| 87 | +## Limitations |
| 88 | + |
| 89 | +While powerful, CPFP has some constraints: |
| 90 | +- Only the recipient can initiate CPFP |
| 91 | +- Requires enough funds to cover the new transaction fee |
| 92 | +- Some wallets don't support CPFP natively |
| 93 | +- May not work during extreme network congestion |
0 commit comments