fix: dynamic trusted peer IPs from Blocktank API#456
fix: dynamic trusted peer IPs from Blocktank API#456ben-kaufman wants to merge 5 commits intomasterfrom
Conversation
77f80dc to
b77c812
Compare
c86c8be to
b77c812
Compare
ovitrif
left a comment
There was a problem hiding this comment.
utAck
proceeding to test 🧪
There was a problem hiding this comment.
tAck
Tests
Note: Tests 3 and 4 use the Peer Simulation picker added in #458 (stacked on this PR) to simulate edge cases without modifying code or network conditions.
1. 🟢 Fresh Wallet: new LND4 peer connected instead of old one, trusted peers fetched from api/info
INFOℹ️: Fetched 3 trusted peers from Blocktank API [WalletViewModel.swift: fetchTrustedPeersFromBlocktank() line: 277]
INFOℹ️: Using 3 trusted peers from Blocktank API [LightningService.swift: connectToTrustedPeers(remotePeers:) line: 317]
2. 🟢 Existing install (stale LND4 IP cached)
- Built branch
release-2.0.4& installed app using old version (using commit of last tag) - Loaded old wallet, confirmed it uses old LND4 as one of the 3 trusted peers
- Built this branch & installed app of this branch
- Confirmed IP of LND4 is updated (see imgs)
| Before | After |
|---|---|
![]() |
![]() |
3. 🟢 API unreachable → fallback to env peers
- Used Peer Simulation picker in LDK Debug screen (set to API Failure)
- With wallet loaded, selected it, then restarted Lightning node from LDK Debug screen
- Confirmed fallback to hardcoded env peers:
WARN⚠️ : ⚠️ [DEBUG] Simulating Blocktank API failure [WalletViewModel.swift: fetchTrustedPeersFromBlocktank() line: 247]
WARN⚠️ : No remote peers available, falling back to preconfigured env peers [LightningService.swift: connectToTrustedPeers(remotePeers:) line: 321]
4. 🟢 API peers unreachable → verify + env fallback
- Verified
verifyTrustedPeersOrFallbacklogic handles case where API peers connect but none are reachable - Since env peers and API peers share the same node IDs (LND4), verification correctly logs:
WARN⚠️ : No trusted peers connected. All preconfigured env peers overlap with API peers (not retrying with stale addresses). [LightningService.swift: verifyTrustedPeersOrFallback() line: 350]
- This is correct behavior: avoids retrying with stale hardcoded IPs when the same nodes were already attempted via fresh API addresses
Add BlocktankPeerSimulation enum to WalletViewModel with simulation modes (None, API Failure, Unreachable Peers) and a segmented picker in the LDK Debug screen for testing Blocktank peer connection edge cases. Dev Settings is already UI-gated via @AppStorage, so no compile-time guards are needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract reconnectTrustedPeers() from WalletViewModel.start() and call it after lightningService.restart() in LdkDebugScreen so the peer simulation picker actually takes effect on restart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
piotr-iohk
left a comment
There was a problem hiding this comment.
Tested:
-
- Existing install (stale LND4 IP cached): stale inactive channels became operational
Also overal sanity:
- Existing install (stale LND4 IP cached): stale inactive channels became operational
- create CJIT, send/receive ln payments.
|
Not sure if it is a false positive or integration tests need to be updated: |
feat(settings): LDK peer simulation debug UI
|
@piotr-iohk Need one more review & approval. PS. this PR's branch is not for merging (current merging auto-deletes the branch IIRC); not before we build and pub to TestFlight. |
I suppose it would make sense to bump the version here also? |
100%, I'm doing it for android already 👍🏻 EDIT: done in e5955b1 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@piotr-iohk build number bumped; pls make build for TestFlight 🙏🏻 |
piotr-iohk
left a comment
There was a problem hiding this comment.
LGTM tested in TestFlight:
- inactive channels became active
- LN interop (WoS, Blink, Bitkit)
- CJIT
- create channel via transfer


Description
This PR:
/infoendpoint at startup, instead of relying solely on hardcoded addresses34.65.186.40to34.65.153.174fix/peer-address-upsertbranch which persists updated peer addresses on connectPreviously, iOS used only hardcoded peer addresses. When LND4's IP changed, the app kept retrying the stale address indefinitely. Android already fetched peers from the Blocktank API — this brings iOS to parity.
The ldk-node fix (synonymdev/ldk-node#53) ensures that even without an app update,
Node::connectwith the new IP will persist the updated address and the reconnection loop will use it going forward.Linked Issues/Tasks
Screenshot / Video
N/A — no UI changes, peer connection logic only.
QA Notes
1. Fresh install
2. Existing install (stale LND4 IP cached)
3. API unreachable
4. API returns unreachable peers
Made with Cursor