-
Notifications
You must be signed in to change notification settings - Fork 430
Expose channel_reserve_satoshis via ChannelParameters
#4319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Expose channel_reserve_satoshis via ChannelParameters
#4319
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
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
cd475ee to
2f585af
Compare
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
🔔 1st Reminder Hey @valentinewallace @tankyleo! This PR has been waiting for your review. |
1 similar comment
|
🔔 1st Reminder Hey @valentinewallace @tankyleo! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @valentinewallace @tankyleo! This PR has been waiting for your review. |
1 similar comment
|
🔔 2nd Reminder Hey @valentinewallace @tankyleo! This PR has been waiting for your review. |
Summary
channel_reserve_satoshis: Option<u64>field toChannelParametersstructSome(value)with the explicit reserve fromopen_channelmessageNonesince reserve is calculated from total channel value (initiator + acceptor funding), which isn't known atOpenChannelRequesttimechannel_parameters()fromCommonOpenChannelFieldsto individualOpenChannelandOpenChannelV2impls to handle V1/V2 difference correctlytest_open_channel_request_channel_reserve_satoshisto verify the implementationFixes #3909
Revives the closed PR #3910 with the approach suggested by reviewers:
Option<u64>instead of trying to read from wire for V2 (which doesn't have this field)channel_parameters()toOpenChannel/OpenChannelV2Test plan
cargo check -p lightningpassescargo test -p lightning --lib)test_open_channel_request_channel_reserve_satoshisvalidates V1 channels correctly populate the fieldchannel_open_testspass🤖 Generated with Claude Code