Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Failure to reject absurdly high channel reserves

未关闭
#9,475 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c
领域
payments

调研方向

从 openingd/common.c 中第 126-144 行附近的聚合储备检查开始,跟踪 channel_reserve_satoshis 的通道开启验证。确认在两个余额都低于储备时,提供的参数会被拒绝,并根据 issue 建议的限制验证对方储备上限的行为。

由索引模型根据 Issue 内容生成。

描述

BOLT 2 has one required and one suggested check that provide an upper limit on the channel reserve imposed by the counterparty:

  1. The receiving node MUST fail the channel if:
      - both `to_local` and `to_remote` amounts for the initial commitment transaction are less than or equal to `channel_reserve_satoshis`
    
  2. The receiving node MAY fail the channel if:
      - it considers `channel_reserve_satoshis` too large.
    

CLN implements neither.

Impact

CLN will accept a channel reserve larger than its own initial balance, leaving it unable to send anything on the channel until the funder chooses to push more funds to it. For example, CLN accepts the following channel parameters:

funding_satoshis = 100_000
push_msat = 20_000_000
feerate_per_kw = 500
channel_reserve_satoshis = 87_000
channel_type = anchors

The balances on the initial commitment transaction after fees are:

to_local (funder) = 78_778 sat
to_remote (CLN) = 20_000 sat

Both sides are below the reserve, so CLN cannot spend until it has received a further sats, and the funder is under no obligation to ever send it. CLN's balance is still recoverable on-chain by closing the channel.

One thing to note is that CLN does impose the aggregate reserve check on the funding amount: https://github.com/ElementsProject/lightning/blob/c1551c557cc524e2241f9cbae7d3895b1b0b627c/openingd/common.c#L126-L144 This rejects cases where aggregate reserve/fee exceeds the channel capacity, but misses cases where the capacity covers the fee and reserve, yet after pushing some amount to the peer, both balances fall below the reserve.

Suggested fix

Add a check for requirement 1 above, as mandated by the spec.

Also add a cap on the channel reserve imposed by the counterparty. For reference, LND caps at 20% of capacity and Eclair caps at 5%.

Discovery

The missing specification check was detected while fuzzing with smite.

主要语言
C
星标
3.1k
派生
1k
平均合并
3 天 10 小时
30 天内合并 PR
40

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ElementsProject/lightning 的其他 Issue

查看 ElementsProject/lightning 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。