跳至主要內容
進階

Multi-Path Payments 多路徑支付

了解多路徑支付(MPP)如何將大額支付拆分成多個小額部分,通過不同路徑同時發送,提高支付成功率。

12 分鐘

什麼是多路徑支付?

多路徑支付(Multi-Path Payments, MPP)允許將一筆支付拆分成多個較小的部分(shards), 通過不同的路徑同時發送。這解決了單一路徑可能沒有足夠流動性的問題, 大幅提高了大額支付的成功率。

核心價值: 在閃電網路中,單一通道的流動性有限。MPP 讓你可以利用多個通道的流動性 來完成大額支付,而不需要找到一條擁有全部流動性的路徑。

單路徑的限制

Single-Path Payment Problem:

Scenario: Alice wants to pay 1 BTC to Dave

Network state:
Alice --[0.3]--> Bob --[0.8]--> Carol --[0.5]--> Dave
      |                                           ^
      +--[0.4]--> Eve --[0.6]--> Frank --[0.3]---+

Path 1: Alice -> Bob -> Carol -> Dave
        Bottleneck: 0.3 BTC (Alice-Bob channel)

Path 2: Alice -> Eve -> Frank -> Dave
        Bottleneck: 0.3 BTC (Frank-Dave channel)

Problem:
• No single path can support 1 BTC
• Payment fails!

Solution:
• Split 1 BTC
• Path 1 sends 0.3 BTC
• Path 2 sends 0.3 BTC
• Other paths send remaining 0.4 BTC

MPP 類型

Basic MPP

接收方必須在發票中聲明支持,所有分片使用相同的 payment_hash。

  • • 已廣泛部署
  • • 需要發票支持
  • • 使用 payment_secret 保護

AMP (Atomic Multi-Path)

由 Lightning Labs 提出,每個分片使用不同的 payment_hash,提供更好的隱私。

  • • 更強的隱私
  • • 可用於自發支付
  • • 無需發票聲明

Basic MPP 機制

Basic MPP Flow:

1. Receiver generates invoice
   Invoice:
     payment_hash: H = SHA256(preimage)
     payment_secret: S (32 bytes random)
     amount: 1,000,000 sats
     features: basic_mpp

2. Sender splits payment
   Total 1,000,000 sats -> 3 shards:
   - Shard 1: 400,000 sats, path A
   - Shard 2: 350,000 sats, path B
   - Shard 3: 250,000 sats, path C

3. Each shard's HTLC payload
   Final hop payload:
     amt_to_forward: 400000
     outgoing_cltv_value: ...
     payment_secret: S
     total_msat: 1000000000

4. Receiver processing
   • Collect all HTLCs with same H and S
   • Verify total_msat matches
   • Wait for all shards to arrive
   • Reveal preimage to settle all shards at once

5. Atomicity guarantee
   • All shards succeed -> payment complete
   • Any shard fails -> all shards timeout and return

Payment Secret

Payment Secret Importance:

Problem: MPP without payment_secret

Attack scenario (Wormhole Attack):
1. Alice sends shard 1 (500k sats) to Bob
2. Malicious routing node Eve intercepts
3. Eve sends her own 500k sats fake shard
4. Receiver gets 1M sats, reveals preimage
5. Eve uses preimage to settle Alice's shard
6. Eve stole 500k sats!

Solution: Payment Secret
• Only invoice holder knows payment_secret
• Receiver only accepts HTLCs with correct secret
• Eve cannot forge shards (doesn't know secret)

Feature bits:
• var_onion_optin (bit 8/9): required
• payment_secret (bit 14/15): required for MPP

AMP (Atomic Multi-Path)

AMP Mechanism:

Differences from Basic MPP:

Basic MPP:
• All shards use same payment_hash H
• May be correlated by routing nodes

AMP:
• Each shard has different payment_hash H_i
• Final preimage derived from shared secret
• Routing nodes cannot correlate shards

AMP secret derivation:
1. Sender chooses random root_share
2. For n shards:
   share_i = HMAC("share", root_share, i)
   preimage_i = share_1 XOR share_2 XOR ... XOR share_i
   hash_i = SHA256(preimage_i)

3. Receiver needs all shares to calculate final preimage
4. Ensures atomicity: can only settle after collecting all shards

Advantages:
• Each HTLC looks like independent payment
• Stronger privacy protection
• Supports spontaneous payments (Keysend + AMP)

路徑選擇策略

均勻分割

將支付均勻分成 N 份,適合當所有路徑流動性相近時。

1M sats → 500k + 500k

最大流動性優先

優先使用流動性最大的路徑,盡量減少分片數量。

1M sats → 800k (路徑A) + 200k (路徑B)

費用優化

綜合考慮流動性和路由費用,找到總費用最低的分割方案。

可靠性優先

選擇歷史成功率高的路徑,可能會多付一些費用。

超時處理

MPP Timeout Scenarios:

Scenario 1: Partial shard failure
  Shard 1: Successfully reaches receiver
  Shard 2: Routing failure

  Handling:
  • Receiver waits reasonable time
  • After timeout, let all HTLCs expire
  • Sender can retry (different paths or split)

Scenario 2: Receiver offline
  All shards arrive, but receiver doesn't reveal preimage

  Handling:
  • All HTLCs timeout
  • Funds return to sender

Receiver MPP timeout setting:
  mpp_timeout: 60 seconds (typical)
  Timer starts after receiving first shard
  If not complete before timeout -> abandon, wait for HTLC expiry

Best practices:
• Sender should send all shards in parallel
• Avoid delays from sequential sending
• Monitor partial failures and retry quickly

實現狀態

Basic MPP 廣泛支持

LND、CLN、Eclair、LDK 都支持發送和接收 Basic MPP。

AMP 部分支持

LND 完整支持 AMP,其他實現支持程度不一。

優勢與權衡

優勢

  • • 大幅提高大額支付成功率
  • • 更好地利用網路流動性
  • • 減少對單一大通道的依賴
  • • 可以並行發送加快速度

權衡

  • • 可能支付更多路由費
  • • 增加複雜性
  • • 部分失敗需要重試
  • • 佔用更多 HTLC 槽位

相關資源

下一步: 了解 Keysend 如何實現無需發票的自發支付。

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