Skip to content

Conversation

@yashbhutwala
Copy link

Summary

  • Add channel_reserve_satoshis: Option<u64> field to ChannelParameters struct
  • For V1 channels: Returns Some(value) with the explicit reserve from open_channel message
  • For V2 channels: Returns None since reserve is calculated from total channel value (initiator + acceptor funding), which isn't known at OpenChannelRequest time
  • Move channel_parameters() from CommonOpenChannelFields to individual OpenChannel and OpenChannelV2 impls to handle V1/V2 difference correctly
  • Add test test_open_channel_request_channel_reserve_satoshis to verify the implementation

Fixes #3909

Revives the closed PR #3910 with the approach suggested by reviewers:

  • Uses Option<u64> instead of trying to read from wire for V2 (which doesn't have this field)
  • Follows @wpaulino's suggestion to move channel_parameters() to OpenChannel/OpenChannelV2
  • Properly documents the V1 vs V2 behavior

Test plan

  • cargo check -p lightning passes
  • All 1191 lightning tests pass (cargo test -p lightning --lib)
  • New test test_open_channel_request_channel_reserve_satoshis validates V1 channels correctly populate the field
  • All 41 channel_open_tests pass

🤖 Generated with Claude Code

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 16, 2026

👋 Thanks for assigning @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Add `channel_reserve_satoshis: Option<u64>` to `ChannelParameters` so
users can access the counterparty's channel reserve when handling the
`OpenChannelRequest` event.

For V1 channels (`open_channel`), this returns `Some(value)` with the
explicit reserve from the message.

For V2 channels (`open_channel2`), this returns `None` because the
reserve is calculated as `max(1% of total_channel_value, dust_limit)`
per spec, where total_channel_value includes both parties' funding.
Since the acceptor's contribution is unknown at `OpenChannelRequest`
time, the final reserve cannot be determined.

Move `channel_parameters()` from `CommonOpenChannelFields` to separate
implementations on `OpenChannel` and `OpenChannelV2` to handle the
V1/V2 difference correctly.

Fixes lightningdevkit#3909
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 51.72414% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (4281e49) to head (2f585af).

Files with missing lines Patch % Lines
lightning/src/ln/msgs.rs 50.00% 13 Missing ⚠️
lightning/src/ln/channelmanager.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4319      +/-   ##
==========================================
- Coverage   86.61%   86.60%   -0.01%     
==========================================
  Files         158      158              
  Lines      102730   102748      +18     
  Branches   102730   102748      +18     
==========================================
+ Hits        88977    88989      +12     
- Misses      11335    11342       +7     
+ Partials     2418     2417       -1     
Flag Coverage Δ
fuzzing 36.08% <51.72%> (-1.01%) ⬇️
tests 85.90% <51.72%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tankyleo tankyleo self-requested a review January 16, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose channel_reserve_satoshis via ChannelParameters in OpenChannelRequest

2 participants