Lightning Network Anchor Outputs Explained: The Basics (Part 1)
Source: Dev.to
Welcome back, and thank you for being here to learn with me.
Recap: Part 1
- Problem: Pre‑signed Lightning commitment transactions can have outdated fees by the time you need to broadcast them.
- Solution: Anchor outputs let you boost fees later using CPFP (Child Pays For Parent).
What We’ll Cover in Part 2
- How CPFP really works – the mechanics at the Bitcoin protocol level.
- Why 330 sats? – the “magic number” explained.
- The one‑block delay (CSV) – why it’s crucial for security.
- What happens to your other outputs – a quick overview.
- Real‑world examples with actual numbers.
1. CPFP Mechanics
The basic idea
- Miners want to maximize profit, so they fill each block with the highest‑fee transactions.
- They consider transaction packages (parent + child) and compute a combined fee rate.
Example with real numbers
| Transaction | Size (vbytes) | Fee (sats) | Fee rate (sat/vbyte) |
|---|---|---|---|
| Parent (your commitment TX) | 200 | 200 | 1 sat/vbyte ❌ Too low |
| Child (spends the 330‑sat anchor) | 150 | 120 000 | — |
| Total package | 350 | 120 530 | 344 sat/vbyte ✅ |
- The child transaction cannot be confirmed until the parent is confirmed (it spends an output from the parent).
- Miners must include both or neither, so the high fee in the child pulls the parent into the block.
2. Why 330 sats?
- Dust limit – Bitcoin rejects outputs that are too small to be economical.
- Standard dust limit ≈ 546 sats.
- Anchor‑output script – a special script type with a lower dust limit of 330 sats, making it the smallest spendable output that isn’t considered dust.
- Consensus – All major Lightning implementations (LND, Core Lightning, Eclair, LDK) adopted 330 sats in the BOLT specifications, ensuring compatibility.
Why this number is “just right”
- Small enough not to waste channel capacity.
- Large enough to be recognized as a valid output and to cover the cost of a tiny child transaction.
The example below is truncated in the original draft; feel free to fill in the missing values as needed.
You have a Lightning channel:
- Your balance: 5,0… (value continues in the original text)
(Continue the walkthrough with the actual numbers you wish to illustrate.)
TL;DR
- CPFP works because miners evaluate the combined fee rate of parent + child packages.
- 330 sats is the smallest non‑dust, spendable output for anchors, standardized across implementations.
- A 1‑block CSV lock on all non‑anchor outputs prevents adversarial “pinning” attacks and gives you a safe window to bump fees.
- Only anchor outputs are immediately spendable; everything else is delayed by one block for security.
Channel Overview
| Item | Amount (sats) | Amount (BTC) |
|---|---|---|
| Your balance | 5,000,000 | 0.05 BTC |
| Partner balance | 3,000,000 | 0.03 BTC |
| Your anchor | 330 | – |
| Partner anchor | 330 | – |
| Total channel capacity | 8,000,660 | – |
Your partner goes offline, so you must force‑close the channel to retrieve your funds.
1️⃣ Check the mempool fee market
- Current fee rate:
250 sats/vbyte(high congestion) - Commitment transaction size:
220 vbytes - Required fee for confirmation:
220 × 250 = 55,000 sats
Problem: Your pre‑signed commitment transaction only includes a
440 satfee (≈ 2 sats/vbyte). At the current market rate it would sit in the mempool for days or weeks.
2️⃣ Broadcast the commitment transaction
- Fee paid:
440 sats(far too low) - Status: Unconfirmed, stuck in the mempool
3️⃣ Create a CPFP child transaction
| Parameter | Value |
|---|---|
| Spends | Your 330‑sat anchor output |
| Adds inputs | 60,000 sats from your on‑chain wallet |
| Creates output | Sends to your wallet |
| Size | 180 vbytes |
| Fee | 54,560 sats (child) + 330 sats (anchor) = 54,890 sats |
3.1 Calculate the package fee rate (parent + child)
- Parent size:
220 vbytes - Child size:
180 vbytes - Total size:
400 vbytes
| Component | Fee (sats) |
|---|---|
| Parent | 440 |
| Child | 54,890 |
| Total | 55,330 |
- Package rate:
55,330 ÷ 400 ≈ 138 sats/vbyte
This is still below the required 250 sats/vbyte.
4️⃣ Re‑calculate the child fee to meet the market rate
- Target total fee:
400 vbytes × 250 sats/vbyte = 100,000 sats - Parent already paid:
440 sats - Child must pay:
100,000 – 440 = 99,560 sats
Create the child transaction with a 99,560 sat fee.
4.1 Final package
| Item | Fee (sats) |
|---|---|
| Parent | 440 |
| Child | 99,560 |
| Total | 100,000 |
- Package rate:
100,000 ÷ 400 = 250 sats/vbyte✅
5️⃣ Confirmation & Cost Summary
- Total on‑chain cost:
100,000 sats≈ $130 USD (at $65 k/BTC) - Funds secured:
5,000,000 sats(0.05 BTC ≈ $3,250 USD)
Result: Paying the fee is worthwhile to recover your funds.
6️⃣ Fee Scenarios (illustrative)
| Fee rate (sats/vbyte) | Parent fee (220 vbytes) | Child fee (180 vbytes) | Total cost (USD) |
|---|---|---|---|
| 5 | 1,100 sats (~$1.43) | 900 sats (~$1.17) | ≈ $2.60 ✅ |
| 200 | 44,000 sats (~$57) | 36,000 sats (~$47) | ≈ $104 ⚠️ |
| 500 | 110,000 sats (~$143) | 90,000 sats (~$117) | ≈ $260 💀 |
Force‑closing during high‑fee periods can be expensive, which is why Lightning encourages cooperative closes.
7️⃣ Why Anchor Outputs Matter
- Without anchors you may be unable to close a channel during fee spikes (the parent transaction would never confirm).
- With anchors you have the option to add fees via CPFP, giving you a path to recover funds.
Common Q&A
| Question | Answer |
|---|---|
| Can I spend an anchor output more than once? | No. Once an anchor is spent in a child transaction, it cannot be spent again. If that child still doesn’t confirm, you must create another child (a “grandchild”) that spends the first child – this is CPFP chaining. |
| Do both parties have separate anchors? | Yes. Each side can create its own child transaction. Whichever child confirms first will pull the parent through, so either party can ensure confirmation. |
| What about the balance output? | It has a 1‑block CSV lock. You must wait one block after the commitment transaction confirms before you can spend the balance output. Anchors can be spent immediately. |
| Can I use RBF to bump the fee? | Not reliably. RBF requires cooperation from the other party (unlikely in a force‑close) and is vulnerable to pinning attacks. CPFP with anchors is the preferred method. |
8️⃣ Key Take‑aways
- CPFP mechanics: Miners evaluate the combined fee rate of parent + child, incentivizing them to confirm both.
- 330 sats anchor: The minimum non‑dust spendable amount, standardized across Lightning implementations.
- CSV lock: A 1‑block delay on balance outputs prevents transaction‑pinning attacks and gives a clean window for fee‑bumping.
- Cost spectrum: From a few dollars in normal times to hundreds during extreme congestion – still cheaper than being stuck.
- Economic incentive: High force‑close costs push users toward cooperative closes and reliable channel partners.
9️⃣ What’s Next? (Part 3 – Practical Guide)
- Check if your node supports anchor outputs (LND, Core Lightning, Eclair).
- Enable/disable anchor outputs in each implementation.
- Reserve funds: How much on‑chain Bitcoin to keep for emergency fee‑bumping.
- Tools & commands for monitoring anchor outputs and fee‑bumping.
- Step‑by‑step actions when a force‑close occurs.
We’ve moved from “what are anchor outputs?” (Part 1) → “how do they work?” (Part 2) → hands‑on usage (Part 3).
If any part of Part 2 was confusing, let me know—your feedback helps improve the explanations.
See you in Part 3!
CSV Lock (1‑Block Delay) on Balance Outputs Prevents Transaction Pinning Attacks
- Only anchors can be spent immediately; all other outputs must wait 1 block.
- Real costs vary from $3 to $200+ depending on network congestion.
Coming Next (Part 3)
- Practical setup
- Implementation guides
- Reserve‑fund management
If you have any questions or feedback, drop them in the comments.