Repository navigation
fix: recover with the saved servers after a failed server change - #1546
Conversation
Recovery after a failed Electrum or RGS change called setup with nil URLs, which setup resolves to the network defaults, so a wallet with a custom server ran on the default for the rest of the session. Recovery now reads the saved servers through a closure WalletViewModel sets, the same ones a normal start passes. LightningService.swift is also compiled into the notification extension and the unit tests, which have no server config services, so they keep the defaults. Verified: swiftformat --lint on the changed files
Verified: none (runs next on m1a)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
QA: 🟢 Recovery after a failed Electrum change keeps the saved RGS serverRecovery after a failed Electrum change keeps the saved RGS server With a custom RGS URL saved, a failed change to Electrum
Device tests skipped
|
[Medium impact] The change affects Lightning recovery after a server-change restart fails. The PR appears safe to merge, with a non-blocking gap in the recovery test. Findings
SummaryRecovery now reads saved Electrum and RGS URLs through a closure set by
Reviews (1) · Last reviewed commit: "test: recovery reads the saved servers" · Reviewed by Greptile |
Verified: swiftformat --lint on the changed file
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Recovery after a failed Electrum or RGS change now restarts the node with the saved servers, read through a closure WalletViewModel installs on LightningService, instead of nil URLs that fall back to the network defaults. Reviewed c012075 (5baaea2 plus a test rename), full tier.
What I checked, and 4 candidates I ruled out
Read in full: restart, restartNode, applyConfigChange, restartWithPreviousConfig and configureGossipSource in LightningService.swift; the normal start in WalletViewModel.swift; ElectrumConfigService.getCurrentServer, RgsConfigService.getCurrentServerUrl; both connect flows in SettingsViewModel+Electrum.swift and SettingsViewModel+Rgs.swift.
Call sites traced: every restart caller (the two settings flows, LdkDebugScreen, the post-migration restart in AppViewModel); only the recovery path reads the new closure.
CI: SwiftFormat and validate green; unit and integration runs still pending at review time.
Build: Not built: on this track the review reasons from the code and CI, and iOS does not build on Linux.
Ruled out
- Recovery passes an empty RGS URL where the normal start passes nil:
getCurrentServerUrl()falls back toEnv.ldkRgsServerUrl, which is non-empty on every network, so the empty case is unreachable. - A failed Electrum change recovers onto the server that just failed: the Electrum flow saves only after a successful connection, so the closure reads the previous server.
- The notification extension or a test target picks up app config: the default closure returns
(nil, nil), the same as before. - Preview
WalletViewModel()instances overwrite the shared closure: they build the same.standard-backed services, so the values read are the same; the new test restores the previous closure.
Merge confidence: 4/5, WalletViewModelRecoveryServersTests covers the wiring but CI's unit run had not finished and the branch was not built here.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (the reviewer's run metadata does not carry a reasoning setting)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at c012075.
No new actionable code findings.
No actionable code findings. Recovery after a failed Electrum or RGS server change builds the node with the saved Electrum and RGS URLs, the same values a normal start passes. Electrum is stored only after the new server connects, so a failed Electrum change recovers onto the previously saved server. A failed RGS change is already stored before the restart (#1535); recovery follows that stored URL. The save order is unchanged in this diff.
Compared bitkit-android at 64670dba, limited to recovery startup and server persistence. A recovery start omits custom URLs, and LightningService resolves them to the saved Electrum and RGS settings. Both new URLs are written only after the change succeeds.
WalletViewModelRecoveryServersTests asserts that the closure returns the saved URLs. It does not run restartWithPreviousConfig. The resolved thread withdrew the request for a unit test that fails a real node build. On this revision, CI unit tests (run), integration tests, SwiftFormat, and translation validation succeeded. The local end-to-end job was still queued. I did not run those checks.
Device testing: not performed in this review. The author reports manual case 1 on f4cb0e0 (iPhone 17 Pro simulator, iOS 27.0, regtest): with a custom RGS URL saved, a failed Electrum change recovered on that RGS URL and the node started. The production files are the same at this head. Manual case 2 was not run.
Recommended before device testing: case 2 needs a second working Electrum server. The author reports that connecting to another spelling of the staging Electrum host did not save a custom server in the simulator.
Reviewer model: grok-4.7
Reasoning effort: xhigh
…servers # Conflicts: # Bitkit/Services/LightningService.swift
|
@ovitrif please resolve conflicts. |
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR at e8cc136, re-reviewed after the comparison base changed from 947d27b to 7c65088 and master changes touched LightningService.swift.
No new actionable code findings.
No actionable code findings. Recovery after a failed Electrum or RGS change builds the node with the saved Electrum and RGS URLs, the same values a normal start passes. The merge onto master kept those URLs: restartWithPreviousConfig calls setupNode with savedServerUrls(). Electrum is stored only after the new server connects, so a failed Electrum change recovers onto the previously saved server. A failed RGS change is already stored before the restart (#1535); recovery follows that stored URL. That save order is outside this diff.
Compared bitkit-android at 76c508bb, limited to recovery startup and server persistence. A recovery start omits custom URLs, and LightningService resolves them to the saved Electrum and RGS settings. Both new URLs are written only after the change succeeds.
WalletViewModelRecoveryServersTests asserts that the closure returns the saved URLs. restartWithPreviousConfig is outside that test. The resolved thread withdrew the request for a unit test that fails a real node build.
SwiftFormat (run) and translation validation (run) succeeded on this head. Unit tests (run) and integration tests (run) were still running. I did not run those checks.
Device testing: not performed in this review. The author reports manual case 1 on f4cb0e0 (iPhone 17 Pro simulator, iOS 27.0, regtest): with a custom RGS URL saved, a failed Electrum change recovered on that RGS URL and the node started. That commit predates this head's move of recovery from setup to setupNode. Manual case 2 was not run.
Recommended before device testing: re-run case 1 on this head. Case 2 still needs a second working Electrum server; the author reports that another spelling of the staging Electrum host did not save a custom server in the simulator.
Reviewer model: grok-4.7
Reasoning effort: xhigh
|
QA: 🟢 1. Recovery after a failed Electrum change keeps the saved servers1. Recovery after a failed Electrum change keeps the saved servers With a custom RGS URL saved, a failed change to Electrum head2x.mp4Device tests skipped
|
piotr-iohk
left a comment
There was a problem hiding this comment.
Device QA passed on e8cc13695 on an iPhone 17 simulator running iOS 27.2 on regtest. The installed CI build’s source tree matched the PR head.
- Saved
https://Bitkit.stag0.blocktank.to/rgs/snapshotas custom RGS. After an Electrum connection tounreachable.invalidfailed, the recovery logs showed that exact saved RGS URL. - Connected to a second Electrum server at
tcp://127.0.0.1:60002and confirmed it saved. After the failed change, recovery selected that previously saved server and loggedNode started.
Both Electrum servers were independently queried on the same regtest chain. The device exercised the DNS failure and recovery on the unchanged CI app.
Fixes #1530
Refs: #1529
Description
WalletViewModelhands the saved servers toLightningServiceas a closure, sinceLightningService.swiftis also compiled into the notification extension and the unit tests, which have no server config services; those keep the defaultsLightningServicealready resolves a missing URL to the savedelectrumServerandrgsServerUrlsettingsRecovery passes the saved servers to the
setupNodecall that #1529 added torestartWithPreviousConfig.Out of Scope
SettingsViewModel+Rgs.swift: the RGS screen saves a new URL before the restart, so a failed RGS change still stays saved and recovery now restarts on it — bug: a failed rgs server change stays saved #1535Design
N/A — no UI changes.
Preview
N/A — no user-visible changes.
QA Notes
Setup
Debug build (regtest, staging backend), a new wallet.
Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
https://Bitkit.stag0.blocktank.to/rgs/snapshot), then connect Electrum tounreachable.invalid→ the change fails and the app log shows recovery building with the saved RGS URL, not the default — needs the app log, which journeys do not readunreachable.invalid→ recovery'sUsing Electrum serverlog line shows the saved server — needs a second working Electrum server and the app logAutomated Checks
WalletViewModelRecoveryServersTests.swift—WalletViewModelhands recovery the saved Electrum and RGS serversEvidence
On an iPhone 17 Pro simulator (iOS 27.0), regtest, with a custom RGS URL saved, then a failed Electrum change to
unreachable.invalid:setupNodewith the saved RGS URL and the saved Electrum server, and the node started.WalletViewModelRecoveryServersTestspasses at 5baaea2 and e8cc136.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)