Dual-Funded Channels 雙向資金通道
了解雙向資金通道如何讓通道雙方都可以提供初始資金,改善閃電網路的流動性和用戶體驗。
什麼是雙向資金通道?
傳統的閃電網路通道是單向資金的:只有開啟通道的一方提供資金。 雙向資金通道(Dual-Funded Channels)允許雙方同時提供資金, 這意味著新開的通道立即就有雙向流動性,大幅改善用戶體驗。
核心價值: 雙向資金通道解決了「新通道沒有入站容量」的問題,讓用戶可以立即接收支付, 而不需要先發送支付或購買入站流動性。
單向 vs 雙向資金通道
Single-Funded Channel (Traditional):
Alice opens channel to Bob, provides 0.1 BTC:
Funding TX:
Input: Alice's UTXO (0.1 BTC)
|
v
Output: 2-of-2 multisig
• Alice: 0.1 BTC (can send)
• Bob: 0 BTC (can't receive)
Problem: Bob can't receive any payments until Alice sends first
────────────────────────────────────────────
Dual-Funded Channel:
Alice and Bob each provide 0.1 BTC:
Funding TX:
Input 1: Alice's UTXO (0.1 BTC)
Input 2: Bob's UTXO (0.1 BTC)
|
v
Output: 2-of-2 multisig
• Alice: 0.1 BTC (can send, receive 0.1)
• Bob: 0.1 BTC (can send, receive 0.1)
Advantage: Both have bidirectional liquidity immediately! Interactive-TX 協議
雙向資金通道使用 Interactive-TX 協議(BOLT 提案)來協商 funding 交易:
Interactive-TX 流程:
┌─────────┐ ┌─────────┐
│ Alice │ │ Bob │
└────┬────┘ └────┬────┘
│ │
│──── open_channel2 ─────────────────>│
│ (propose dual-funding) │
│ │
│<─── accept_channel2 ───────────────│
│ (agree to participate) │
│ │
│══════ TX 協商開始 ══════════════════│
│ │
│──── tx_add_input ──────────────────>│
│ (Alice's UTXO) │
│ │
│<─── tx_add_input ──────────────────│
│ (Bob's UTXO) │
│ │
│──── tx_add_output ─────────────────>│
│ (2-of-2 funding output) │
│ │
│<─── tx_add_output ─────────────────│
│ (Bob's change, if any) │
│ │
│──── tx_add_output ─────────────────>│
│ (Alice's change, if any) │
│ │
│──── tx_complete ───────────────────>│
│ │
│<─── tx_complete ───────────────────│
│ │
│══════ TX 協商完成 ══════════════════│
│ │
│──── commitment_signed ─────────────>│
│<─── commitment_signed ─────────────│
│ │
│──── tx_signatures ─────────────────>│
│<─── tx_signatures ─────────────────│
│ │
│ [廣播 funding tx] │
▼ ▼ 訊息格式
添加輸入到協商中的交易
channel_id + serial_id + prevtx + prevtx_vout + sequence
添加輸出到協商中的交易
channel_id + serial_id + sats + script
移除之前添加的輸入或輸出
channel_id + serial_id 表示已完成添加輸入/輸出
channel_id 交換輸入簽名
channel_id + txid + witnesses[] Liquidity Ads 流動性廣告
雙向資金通道還支援「流動性廣告」,讓節點可以出售入站流動性:
Liquidity Ads Operation: 1. Seller Advertisement (via node_announcement): "I'm willing to provide inbound liquidity" • funding_weight: transaction size • lease_fee_base_sat: base fee • lease_fee_basis: percentage fee • channel_fee_max_base_msat: max routing fee • channel_fee_max_prop_millionths 2. Buyer Request (in open_channel2): "I want to buy X sats of inbound liquidity" • request_funds: X sats • lease_start_blockheight 3. Seller Agrees (in accept_channel2): "I will provide X sats, charge Y sats" • will_fund: X sats • lease_fee: Y sats Lease period: • Seller commits not to unilaterally close for duration • Enforced via CSV timelock • Typical lease: 4032 blocks (~1 month)
安全考量
UTXO 探測攻擊
惡意節點可能假裝要開通道,但目的是探測你的 UTXO。解決方案:要求對方先提交輸入,或使用 RBF 保護。
資金鎖定攻擊
對方可能故意拖延簽名交換,鎖定你的資金。解決方案:設定超時機制,使用 RBF 取回資金。
RBF 保護
RBF (Replace-By-Fee) Protection: 1. Use require_confirmed_inputs • Only accept confirmed UTXOs as inputs • Prevent opponent from blocking with low-fee tx 2. RBF Rules • All inputs must be RBF replaceable (sequence < 0xfffffffe) • If negotiation fails, can replace with higher fee 3. Timeout Mechanism • Set negotiation timeout • Auto-abort and release UTXOs on timeout
與 Splicing 的關係
Interactive-TX 協議不僅用於開啟新通道,也是 Splicing 的基礎:
Interactive-TX Use Cases: 1. Opening New Channel (Dual-Funded Channel Open) • Both parties negotiate funding transaction • Use open_channel2 / accept_channel2 2. Channel Splicing • Adjust existing channel capacity • Use splice_init / splice_ack • Reuse tx_add_input, tx_add_output messages 3. Future Applications • Channel Factories • Multi-party channels
實現狀態
CLN 從 v0.10.1 開始支援雙向資金通道和流動性廣告,是第一個完整實現的節點。
Eclair 支援雙向資金通道,Phoenix 錢包使用此功能進行按需通道開設。
LND 正在開發雙向資金通道支援,預計在未來版本中加入。
使用案例
LSP 即時開通道
用戶首次收款時,LSP 可以即時開啟雙向資金通道,提供入站流動性讓用戶立即收款。
商家節點
商家可以購買入站流動性,確保客戶能夠即時支付。
節點運營商
通過流動性廣告出售入站容量,創造被動收入。
交易所
與用戶開啟雙向通道,支持即時存款和提款。
相關資源
下一步: 了解 零確認通道 如何實現即時通道開設。