feat: Export Static Channel Backup - #1387
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1387 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 211 212 +1
Lines 7190 7232 +42
Branches 1447 1404 -43
=========================================
+ Hits 7190 7232 +42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryAdds static channel-backup export for running LND and litd nodes through the Actions tab and node context menu.
Confidence Score: 4/5The PR should not merge until an absent LND backup payload is rejected instead of producing a successful zero-byte recovery file. The export path currently turns missing multi-channel backup data into an empty buffer, writes it to disk, and reports success; the renderer also bypasses the repository’s required IPC boundary for native dialog and filesystem operations. Files Needing Attention: src/lib/lightning/lnd/lndService.ts and src/store/models/lightning.ts
|
| Filename | Overview |
|---|---|
| src/lib/lightning/lnd/lndService.ts | Extracts the multi-channel backup bytes but silently converts a missing payload into an empty successful export. |
| src/store/models/lightning.ts | Implements save-dialog and file-writing orchestration, including direct privileged renderer access that violates the repository process boundary. |
| electron/lnd/lndProxyServer.ts | Adds the ExportAllChannelBackups RPC handler and registers it with the existing LND IPC listener map. |
| src/components/designer/lightning/actions/ExportChannelBackupButton.tsx | Adds button and context-menu variants with asynchronous success and error notifications. |
| src/components/designer/NodeContextMenu.tsx | Exposes backup export for started LND and litd nodes without considering whether backup data exists. |
Sequence Diagram
sequenceDiagram
actor User
participant UI as Export Button
participant Store as Lightning Store
participant Main as LND IPC Proxy
participant LND
participant Disk
User->>UI: Export Channel Backup
UI->>Store: exportChannelBackup(node)
Store->>User: Show save dialog
Store->>Main: exportAllChannelBackups
Main->>LND: ExportAllChannelBackups
LND-->>Main: ChanBackupSnapshot
Main-->>Store: Backup bytes
Store->>Disk: Write selected .backup file
Store-->>UI: Selected file path
UI-->>User: Export success notification
Reviews (1): Last reviewed commit: "feat(lnd): add channel backup export but..." | Re-trigger Greptile
| return Buffer.from( | ||
| (res.multiChanBackup?.multiChanBackup as unknown as Uint8Array) || [], | ||
| ); |
There was a problem hiding this comment.
Reject missing backup payloads
When LND omits multiChanBackup, this fallback converts the missing payload into an empty buffer; the store then writes a zero-byte .backup file and reports a successful export, leaving the user with an unusable recovery artifact.
| return Buffer.from( | |
| (res.multiChanBackup?.multiChanBackup as unknown as Uint8Array) || [], | |
| ); | |
| const backup = res.multiChanBackup?.multiChanBackup; | |
| if (!backup) { | |
| throw new Error('No channel backup is available to export'); | |
| } | |
| return Buffer.from(backup as unknown as Uint8Array); |
| } | ||
|
|
||
| const api = injections.lightningFactory.getService(node); | ||
| const backup = await api.exportChannelBackup(node); |
There was a problem hiding this comment.
Avoid privileged renderer access
This renderer-side store directly opens an Electron remote dialog and writes to the filesystem, bypassing the repository requirement that privileged operations cross the main-process IPC boundary. This couples the feature to renderer filesystem access and prevents it from working where remote or direct renderer access is disabled.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Addresses part of #635
Description
This PR adds the export half of static channel backup (SCB) support for LND nodes, closing out the first part of #635. A user can now export a running LND (or litd) node's channel backup to disk from either the Actions tab or the node's right-click context menu, for later use in channel recovery testing. The restore half is intentionally out of scope and will follow in a separate PR.
Steps to Test
.backupfile is byte-identical to the node's ownchannel.backupinside its Docker volumeScreenshots