Skip to content

Add aux channel closer support to RBF cooperative close flow#10817

Open
haanhvu wants to merge 4 commits into
lightningnetwork:masterfrom
haanhvu:issue9663-3
Open

Add aux channel closer support to RBF cooperative close flow#10817
haanhvu wants to merge 4 commits into
lightningnetwork:masterfrom
haanhvu:issue9663-3

Conversation

@haanhvu
Copy link
Copy Markdown

@haanhvu haanhvu commented May 19, 2026

Change Description

fixes #9663

Add auxiliary channel closer support to the RBF cooperative close flow. This change propagates shutdown custom records through the RBF close state machine, derives and preserves auxiliary close outputs across fee renegotiations, and exposes final local/remote/aux close outputs in close updates. It also adds a dev-only mock auxiliary channel closer and integration/unit test coverage for the new behavior.

Tests

  • Added dev-only mock auxiliary channel closer coverage to exercise the new auxiliary close path in tests.
  • Extended RBF cooperative close unit tests to verify shutdown custom records are propagated through state transitions.
  • Extended RBF cooperative close unit tests to verify auxiliary close outputs are attached during close negotiation and preserved through to the final confirmed close state.
  • Added an integration test, rbf coop close with aux close outputs, that verifies auxiliary close outputs are included in the cooperative close transaction and preserved across fee updates.

haanhvu added 3 commits May 19, 2026 16:47
… through RBF coop close

- chancloser now carries shutdown custom records, derives auxiliary close outputs, and preserves them across RBF close state transitions.
- peer wires the extra close metadata into the RBF closer environment and surfaces final close outputs in close updates.

Signed-off-by: haanhvu <haanhvu888@gmail.com>
- add --dev.mock-aux-chan-closer config option for integration tests
- expose dev config helpers to detect and retrieve a mock AuxChanCloser
- wire ImplementationCfg.AuxChanCloser from dev config when enabled

Signed-off-by: haanhvu <haanhvu888@gmail.com>
- add integration test for RBF cooperative close with mock aux chan closer enabled
- assert extra close outputs are included in pending and final close transactions
- verify auxiliary outputs persist across fee bump update

Signed-off-by: haanhvu <haanhvu888@gmail.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for auxiliary channel closers into the RBF cooperative close flow. It ensures that custom shutdown records are correctly propagated and that auxiliary close outputs are derived, preserved during fee updates, and exposed in final close updates. These changes enable more flexible channel closing logic for custom channel types while maintaining robustness through new integration and unit tests.

Highlights

  • Auxiliary Channel Closer Support: Added support for auxiliary channel closers within the RBF cooperative close flow, allowing for custom shutdown records and additional close outputs.
  • State Machine Updates: Propagated shutdown custom records through the RBF close state machine and preserved auxiliary close outputs across fee renegotiations.
  • Testing and Mocking: Implemented a dev-only mock auxiliary channel closer and added comprehensive unit and integration tests to verify the new behavior.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Signed-off-by: haanhvu <haanhvu888@gmail.com>
@github-actions github-actions Bot added severity-critical Requires expert review - security/consensus critical and removed severity-critical Requires expert review - security/consensus critical labels May 19, 2026
@github-actions
Copy link
Copy Markdown

🔴 PR Severity: CRITICAL

Automated classification | 8 files (non-test) | 433 lines changed (non-test)

🔴 Critical (4 files)
  • lnwallet/chancloser/rbf_coop_msg_mapper.go - wallet channel-close message mapping (lnwallet/*)
  • lnwallet/chancloser/rbf_coop_states.go - RBF cooperative close state machine (lnwallet/*)
  • lnwallet/chancloser/rbf_coop_transitions.go - RBF cooperative close state transitions (lnwallet/*)
  • peer/brontide.go - encrypted peer connection handling, Noise protocol (peer/*)
🟡 Medium (3 files)
  • config.go - top-level daemon configuration
  • lncfg/dev.go - dev/build config (lncfg/*)
  • lncfg/dev_integration.go - dev/integration config (lncfg/*)
🟢 Low / Excluded (4 files — excluded from counts)
  • docs/release-notes/release-notes-0.22.0.md - release notes (docs/*)
  • itest/list_on_test.go - integration test list (itest/*)
  • itest/lnd_coop_close_rbf_test.go - integration test (itest/*)
  • lnwallet/chancloser/rbf_coop_test.go - unit test (*_test.go)

Analysis

This PR modifies the RBF (Replace-By-Fee) cooperative channel close state machine inside lnwallet/chancloser, which is squarely in the lnwallet/* critical package covering wallet operations, commitment transactions, and channel funding workflows. Changes include new states, transitions, and message mapping for the RBF coop-close flow (166 + 130 + 1 = 297 new lines in the state machine alone).

Additionally, peer/brontide.go is touched — this is the encrypted peer connection layer (Noise protocol), also a critical package. The PR therefore spans two distinct critical packages (lnwallet/* and peer/*), which would trigger a severity bump, though CRITICAL is already the ceiling.

Expert review is warranted given the state machine complexity and the interaction between channel-close coordination and the peer layer.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for auxiliary channel closers within the RBF cooperative close state machine, enabling the handling of custom TLV records and auxiliary close outputs. The implementation includes updates to the state machine environment, message mapping, and peer initialization, along with new integration tests. Feedback recommends refactoring the configuration logic in config.go to reduce code duplication and centralizing hardcoded test outputs into a shared constant to enhance maintainability.

Comment thread config.go
Comment on lines +1976 to +1978
if c.Dev.NeedMockAuxChanCloser() {
implCfg.AuxChanCloser = c.Dev.GetMockAuxChanCloserValueForTest()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if block is a duplicate of the one on lines 1959-1962. To improve maintainability, you could refactor ImplementationConfig to avoid this code repetition. One way is to declare implCfg before the main if/else block, initialize it within each branch, and then have a single block to set AuxChanCloser before returning.

Comment thread lncfg/dev_integration.go
Comment on lines +73 to +83
TxOut: wire.TxOut{
Value: 50_000,
PkScript: []byte{
0x00, 0x14, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11,
0x11, 0x11,
},
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This hardcoded TxOut is also defined in itest/lnd_coop_close_rbf_test.go and lnwallet/chancloser/rbf_coop_test.go. To improve maintainability and avoid inconsistencies, consider defining this as a shared constant or variable in a test helper package that can be imported by all three files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-critical Requires expert review - security/consensus critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: add custom chan support to new rbf chan closer

1 participant