Skip to content

switchrpc: wire MacService and NetworkDir in config setup#10737

Merged
yyforyongyu merged 1 commit intolightningnetwork:elle-base-branch-payment-servicefrom
calvinrzachman:switchrpc-macaroon-wiring
Apr 21, 2026
Merged

switchrpc: wire MacService and NetworkDir in config setup#10737
yyforyongyu merged 1 commit intolightningnetwork:elle-base-branch-payment-servicefrom
calvinrzachman:switchrpc-macaroon-wiring

Conversation

@calvinrzachman
Copy link
Copy Markdown
Collaborator

Change Description

The switchrpc config dispatcher in PopulateDependencies was missing the MacService and NetworkDir fields, which meant cfg.MacService was always nil when switch_server.go's New() function ran, so switch.macaroon was never written to disk.

This brings switchrpc server in line with the pattern used by every other sub-server (signrpc, walletrpc, chainrpc, invoicesrpc, etc.).

Steps to Test

  • Build lnd with switchrpc build tag and observe creation of file.

The switchrpc configuration in PopulateDependencies was missing
the MacService and NetworkDir fields, so switch.macaroon was never
written to disk.

This adds the two missing config setup steps, bringing switchrpc
setup in line with the pattern used by the other lnd sub-servers.
@calvinrzachman calvinrzachman self-assigned this Apr 16, 2026
@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 ensures that the switchrpc sub-server configuration is properly initialized by including necessary dependencies that were previously omitted. This change aligns the switchrpc setup with the standard pattern used by other sub-servers in the project, ensuring consistent behavior and correct file system operations.

Highlights

  • Configuration Update: Updated the PopulateDependencies function to correctly inject MacService and NetworkDir into the switchrpc configuration.
  • Bug Fix: Resolved an issue where switch.macaroon was not being written to disk due to missing configuration fields.

🧠 New Feature in Public Preview: You can now enable Memory 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 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 counter productive. 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.

@github-actions github-actions Bot added the severity-medium Focused review required label Apr 16, 2026
@github-actions
Copy link
Copy Markdown

🟡 PR Severity: MEDIUM | subrpcserver_config.go (1 file, 7 lines) | Root-level Go file not matching CRITICAL (server.go/rpcserver.go) or HIGH (lnrpc/*) packages. No bump: 1 file, 7 lines, single package. <!-- 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 updates the dependency population for the switchrpc.Config sub-server by adding NetworkDir and MacService fields. Feedback was provided to replace the use of reflection with direct field assignments, as the configuration object is already type-asserted, which would improve type safety and maintainability.

Comment thread subrpcserver_config.go
Comment on lines +324 to +329
subCfgValue.FieldByName("NetworkDir").Set(
reflect.ValueOf(networkDir),
)
subCfgValue.FieldByName("MacService").Set(
reflect.ValueOf(macService),
)
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

While this is consistent with the rest of the function, using reflection with FieldByName is brittle and can lead to runtime panics if the field names in the switchrpc.Config struct are ever changed.

Since the subCfg variable is already typed as *switchrpc.Config, you can set the fields directly for better type safety and readability.

This would be a good refactoring to apply to the other cases in this function as well.

            subCfg.NetworkDir = networkDir
            subCfg.MacService = macService

@saubyk saubyk added this to lnd v0.22 Apr 16, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 Apr 16, 2026
@saubyk saubyk moved this from Backlog to In progress in lnd v0.22 Apr 16, 2026
Copy link
Copy Markdown
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@Abdulkbk Abdulkbk left a comment

Choose a reason for hiding this comment

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

tACK

Image

Copy link
Copy Markdown
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

⚒️

@yyforyongyu yyforyongyu merged commit c6be683 into lightningnetwork:elle-base-branch-payment-service Apr 21, 2026
43 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog severity-medium Focused review required

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants