跳至主要內容
高級

Anchor Outputs 錨定輸出

了解 Anchor Outputs 如何讓閃電網路通道在強制關閉時動態調整手續費,解決費率預估難題。

12 分鐘

什麼是 Anchor Outputs?

Anchor Outputs(錨定輸出)是閃電網路承諾交易的一項重要改進。它在承諾交易中 添加兩個小額「錨定」輸出,讓任一方都可以通過 CPFP(Child-Pays-For-Parent) 在廣播時動態增加交易手續費,解決了預估未來費率的難題。

核心問題: 傳統承諾交易的手續費在簽名時就固定了。如果之後網路擁堵導致費率飆升, 你的通道關閉交易可能卡住無法確認,HTLC 可能超時,資金面臨風險。

費率問題

Traditional Commitment TX Fee Rate Dilemma:

Time T0: Open channel
• Current fee rate: 10 sat/vB
• Commitment tx signed at 20 sat/vB (buffer)
• Looks fine

Time T0 + 6 months: Need to close channel
• Current fee rate: 200 sat/vB (network congestion)
• Your commitment tx only has 20 sat/vB
• Transaction stuck in mempool!
• HTLC may timeout, funds at risk!

Or the opposite:

Time T0: Open channel
• Anticipating future congestion
• Set high fee rate: 100 sat/vB
• Sacrificing channel capacity for fees

Time T0 + 6 months: Close channel
• Current fee rate: 5 sat/vB
• Overpaid by 95 sat/vB!
• Money wasted

Neither approach works!

Anchor Outputs 解決方案

Anchor Outputs Commitment Transaction Structure:

Commitment Transaction
+---------------------------------------------------+
| Inputs:                                           |
|   Funding TX output                               |
+---------------------------------------------------+
| Outputs:                                          |
|   to_local (Alice's balance)                      |
|   to_remote (Bob's balance)                       |
|   HTLC outputs (if any)                           |
|   anchor_alice (330 sats)  <- anchor output       |
|   anchor_bob (330 sats)    <- anchor output       |
+---------------------------------------------------+
| Fee: minimum rate (e.g., 1 sat/vB)                |
+---------------------------------------------------+

Using CPFP to accelerate:

+--------------------+
| Commitment TX      |------> low fee rate
| (parent)           |
+--------+-----------+
         |
         | spend anchor_alice
         v
+--------------------+
| CPFP TX            |------> high fee rate
| (child)            |        covers total fee
+--------------------+

Miners will include parent and child together!

Anchor 腳本

Anchor Output Script:

<anchor_pubkey> CHECKSIG
IFDUP
NOTIF
  16 CHECKSEQUENCEVERIFY
ENDIF

Explanation:
1. Owner can immediately spend with anchor_pubkey
2. If signature fails (someone else tries to spend)
   -> Must wait 16 blocks
3. This allows anyone to clean up unused anchors after 16 blocks

Why 330 sats?
• This is the dust limit
• Smaller outputs would be rejected by nodes
• Small enough to not waste channel capacity
• Large enough to be recognized as valid output

Feature bits:
• option_anchor_outputs (bit 20/21) - original
• option_anchors_zero_fee_htlc_tx (bit 22/23) - improved

Zero-Fee HTLC Anchors

改進版的 Anchor Outputs 還解決了 HTLC 交易的費率問題:

Zero-Fee HTLC Transactions:

Problem: HTLC-Success and HTLC-Timeout txs also need fees

Traditional approach:
  Commitment TX --> HTLC Output
                         |
                         v
                    HTLC-Success TX (fixed fee rate)
                    or HTLC-Timeout TX (fixed fee rate)

  These second-stage tx fee rates are also pre-signed!

Zero-Fee HTLC approach:
  Commitment TX --> HTLC Output
                         |
                         v
                    HTLC TX (0 fee rate)
                         |
                         | add extra input to pay fee
                         v
                    Complete tx with CPFP

Benefits:
• HTLC txs can also dynamically adjust fee rate
• More flexibility in HTLC timeout races
• Can use wallet UTXOs to pay fees

UTXO 需求

新的運營需求

使用 Anchor Outputs 的節點需要維護額外的鏈上 UTXO 用於 CPFP。 如果沒有可用 UTXO,可能無法及時加速交易。

UTXO 管理

  • • LND 有專用的「anchor 錢包」
  • • 自動維護最低餘額
  • • 監控 UTXO 可用性

與 Watchtower 的關係

Watchtower + Anchor Outputs:

Traditional Watchtower:
• Stores pre-signed penalty transactions
• Fee rate fixed at signing time
• If fee rate too low, penalty may fail!

Anchor-aware Watchtower:
• Stores penalty tx + has CPFP capability
• Needs its own UTXO pool
• Can dynamically adjust fee rate
• Increases Watchtower costs

Challenges for Watchtower:
1. Maintain UTXO pool
2. Monitor fee rate market
3. Ready to pay CPFP fees
4. May need to charge users to cover costs

版本演進

原版 (option_anchor_outputs)

第一版 Anchor Outputs,承諾交易有 anchors,但 HTLC 交易仍使用預簽費率。

改進版 (option_anchors_zero_fee_htlc_tx)

當前推薦版本。HTLC 交易使用零費率,也可以通過 CPFP 加速。 static_remotekey 是必需的。

Simple Taproot Channels(未來)

Taproot 通道會使用不同的 anchor 設計,可能只需要單個共享 anchor。

實現狀態

LND 默認啟用

LND 0.12+ 默認使用 anchor channels,自動管理 anchor 錢包。

Core Lightning 支持

CLN 支持 anchor channels,可通過配置啟用。

Eclair 支持

Eclair 和 Phoenix 支持 anchor channels。

相關資源

下一步: 了解 通道儲備金 如何保護雙方免受欺詐。

已複製連結
已複製到剪貼簿