fix: use file paths instead of hex during LND onboarding#2231
fix: use file paths instead of hex during LND onboarding#2231im-adithya wants to merge 1 commit intomasterfrom
Conversation
📝 WalkthroughWalkthroughThe changes migrate LND credential handling from direct hex value inputs to file-based inputs. Users now provide paths to certificate and macaroon files, which are read from disk, converted to hex, and persisted in configuration. This change applies consistently across the backend setup logic and frontend form components. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/api.go (1)
1534-1559:⚠️ Potential issue | 🟠 MajorLND certificate/macaroon rotation not supported—stored hex snapshots are stale after file changes
Certificates and macaroons are read once during setup (lines 1535, 1548) and converted to hex snapshots stored in config. At runtime, the application reads only the stored hex values (see
service/start.go:345-347), never re-checking the original file paths. If cert or macaroon files rotate on disk after setup, those changes won't be picked up without restarting the application. Consider implementing a mechanism to either re-read files at runtime or provide a credential refresh endpoint.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/api.go` around lines 1534 - 1559, The current setup code encodes LNDCertFile and LNDMacaroonFile contents to hex and persists those snapshots via cfg.SetUpdate, which prevents picking up rotated files at runtime; update the flow so the runtime reads the live files or supports explicit refresh: either persist the original file paths (store LNDCertFile/LNDMacaroonFile strings instead of hex) and change the component that initializes the LND client to call a new helper (e.g., readAndEncodeLndCredentials or reloadLndCredentials) that reads the files and encodes them when creating/recreating the LND connection, or add a credential refresh API endpoint (e.g., RefreshLndCredentials) that re-reads the files and calls cfg.SetUpdate with new hex values; ensure symbols to edit include LNDCertFile, LNDMacaroonFile, cfg.SetUpdate and the LND client initialization path (the code that currently reads stored hex at runtime) so rotated certs/macaroon are picked up without needing a full restart.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/api.go`:
- Around line 1536-1538: The error returned after logging the failed file reads
should be wrapped with context using fmt.Errorf instead of returning the raw
err; replace the bare returns at the logger lines (e.g., the
logger.Logger.WithError(err).Error("Failed to read lnd cert file") site and the
similar read failure site referenced around 1549-1551) with returns like return
fmt.Errorf("failed to read lnd cert file: %w", err) (and the analogous
contextual message for the other read), and add an import for "fmt" if missing.
---
Outside diff comments:
In `@api/api.go`:
- Around line 1534-1559: The current setup code encodes LNDCertFile and
LNDMacaroonFile contents to hex and persists those snapshots via cfg.SetUpdate,
which prevents picking up rotated files at runtime; update the flow so the
runtime reads the live files or supports explicit refresh: either persist the
original file paths (store LNDCertFile/LNDMacaroonFile strings instead of hex)
and change the component that initializes the LND client to call a new helper
(e.g., readAndEncodeLndCredentials or reloadLndCredentials) that reads the files
and encodes them when creating/recreating the LND connection, or add a
credential refresh API endpoint (e.g., RefreshLndCredentials) that re-reads the
files and calls cfg.SetUpdate with new hex values; ensure symbols to edit
include LNDCertFile, LNDMacaroonFile, cfg.SetUpdate and the LND client
initialization path (the code that currently reads stored hex at runtime) so
rotated certs/macaroon are picked up without needing a full restart.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bb269f03-7734-4a5e-bdd7-206aa5130dd1
📒 Files selected for processing (4)
api/api.goapi/models.gofrontend/src/screens/setup/node/LNDForm.tsxfrontend/src/types.ts
💤 Files with no reviewable changes (1)
- api/models.go
Fixes #1968
Summary by CodeRabbit