JIT Channels 即時通道
了解 Just-In-Time Channels 如何在收到支付時即時開設通道,提供無縫的用戶體驗。
什麼是 JIT Channels?
JIT Channels(Just-In-Time Channels,即時通道)是一種在用戶收到支付時才開設通道的技術。 而不是預先開設通道等待使用,LSP 在檢測到發往用戶的支付時實時創建通道, 通道開設費用直接從首筆支付中扣除。
用戶體驗: 用戶不需要任何初始資金。只需分享收款地址,收到第一筆支付時通道自動開設。 這大大降低了新用戶的入門門檻。
傳統 vs JIT 對比
Traditional Channel Opening Flow: 1. User decides to use Lightning Network 2. User buys/transfers on-chain BTC 3. Wait for on-chain confirmation 4. Open channel (another on-chain TX) 5. Wait for channel confirmation 6. Finally can use! Total time: Hours to days Entry barrier: Need BTC and technical knowledge first JIT Channel Flow: 1. User downloads wallet, gets receiving address 2. Someone sends payment to user 3. LSP intercepts payment, instantly opens channel 4. Payment completes through new channel 5. User receives funds, channel established! Total time: Seconds Entry barrier: None Timing Comparison: Traditional: [Buy BTC]->[Wait confirm]->[Open channel]->[Wait confirm]->[Use] |________________ 1-24 hours ________________| JIT: [Receive payment request]->[Open channel + forward]->[Use] |________________ seconds ________________|
工作原理
JIT Channel Opening Flow:
Sender -> Routing Network -> LSP -> New User
Step 1: Payment Arrives at LSP
Sender initiates payment to user's invoice
LSP receives HTLC:
- payment_hash: abc123...
- amount: 100,000 sats
- target: user node
LSP discovers: User has no channel!
Step 2: LSP Instantly Opens Channel
LSP calculates fee:
- Channel open fee: 2,000 sats
- User receivable: 98,000 sats
LSP opens Zero-Conf channel:
- Capacity: 100,000 sats
- User side: 98,000 sats
- LSP side: 2,000 sats (fee)
Uses SCID Alias for immediate usability
Step 3: Forward Payment
LSP forwards HTLC through new channel:
Inbound HTLC: 100,000 sats
|
v
Outbound HTLC: 98,000 sats (minus fee)
|
v
User reveals preimage
|
v
Payment complete!
Result:
- User receives 98,000 sats
- User now has a usable channel
- LSP collects 2,000 sats fee
- Entire process transparent to sender LSPS2 規範
LSPS2: JIT Channels 規範
流程:
1. 客戶端請求 JIT 通道信息
{
"method": "lsps2.get_info",
"params": {}
}
響應:
{
"opening_fee_params_menu": [
{
"min_fee_msat": 2000000,
"proportional": 1000, // 0.1%
"valid_until": "2024-01-01T00:00:00Z",
"min_lifetime": 1008, // 區塊
"max_client_to_self_delay": 2016,
"promise": "signature..."
}
],
"min_payment_size_msat": 1000000,
"max_payment_size_msat": 100000000000
}
2. 客戶端購買 JIT 通道
{
"method": "lsps2.buy",
"params": {
"opening_fee_params": { ... },
"payment_size_msat": 100000000
}
}
響應:
{
"jit_channel_scid": "1234567x123x1",
"lsp_cltv_expiry_delta": 144,
"client_trusts_lsp": false
}
3. 客戶端創建發票
使用 jit_channel_scid 作為路由提示
發送方支付時,LSP 攔截並開通道 Zero-Conf 結合
為什麼需要 Zero-Conf
傳統通道需要等待鏈上確認才能使用。JIT 通道使用 零確認通道 技術,讓通道在資金交易未確認時就能使用。
SCID Alias
使用別名短通道 ID(SCID Alias)而不是基於區塊位置的真實 SCID。 允許在通道確認前就能路由支付。
費用模式
JIT Channel Fee Structure: Fee Components: 1. Fixed fee: covers on-chain TX cost 2. Proportional fee: covers liquidity cost Calculation Example: Minimum fee: 2,000 sats Proportional fee: 0.1% (1000 ppm) Payment 100,000 sats: Fee = max(2000, 100000 * 0.001) = 2,000 sats Payment 1,000,000 sats: Fee = max(2000, 1000000 * 0.001) = 2,000 sats Payment 5,000,000 sats: Fee = max(2000, 5000000 * 0.001) = 5,000 sats Fee Transparency to User: Sender pays: 100,000 sats JIT fee: -2,000 sats -------------------- User receives: 98,000 sats User knows how much they'll receive before payment Dynamic Fees (based on on-chain fee rate): - Low fee period: lower JIT fees - High fee period: higher JIT fees - LSP can adjust quotes in real-time
安全考量
LSP 信任
JIT 通道依賴 LSP 的配合。如果 LSP 惡意或離線,支付會失敗。 用戶資金仍然安全(閃電通道的標準保護),但服務可用性依賴 LSP。
Zero-Conf 風險
Zero-Conf 通道在資金交易確認前有雙花風險。但由於 LSP 控制資金交易, 實際風險由 LSP 承擔。如果 LSP 雙花自己的交易,用戶不會損失。
支付大小限制
首筆支付必須大於最低費用才有意義。太小的支付可能全部被費用吞掉。 LSP 會設定最低支付金額限制。
與 Splicing 的關係
JIT + Splicing Future: Current (JIT Channels): Each new user needs new channel -> new on-chain TX Problem: - If 1000 new users - Need 1000 on-chain TXs - On-chain fees accumulate Splicing Solution: LSP has one large channel pool New user joins -> Splice-in to existing channel User leaves -> Splice-out from channel Can batch multiple users' splice operations Reduces total on-chain TX count Phoenix Wallet Already Uses This Model: - Single channel model - All operations via splice - More efficient fund management - Better user experience
實現狀態
Breez SDK 完整支持 JIT 通道。新用戶首次收款時自動開通道。
Phoenix 使用類似概念配合 Splicing,提供無縫的通道管理體驗。
LSPS2 規範標準化了 JIT 通道協議,促進不同 LSP 之間的互操作性。
相關資源
下一步: 了解 Zero-Conf Channels 如何讓通道在鏈上確認前就能使用。