Skip to content

fix: orphaned channel recovery pre-startup#826

Draft
jvsena42 wants to merge 5 commits intomasterfrom
fix/orphaned-channels-override
Draft

fix: orphaned channel recovery pre-startup#826
jvsena42 wants to merge 5 commits intomasterfrom
fix/orphaned-channels-override

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Mar 6, 2026

Fixes #819

Port of synonymdev/bitkit-ios#480

This PR:

  1. Moves orphaned channel monitor recovery to run before the node starts, eliminating the stop/restart cycle
  2. Fixes channel manager override by passing null for orphaned recovery — only monitors are needed for sweeping force-closed channels

Description

When recovering orphaned channel monitors from an RN remote backup, the stale RN channel manager was being passed to LDK alongside the monitors. This overwrites the native app's current channel manager, which can force-close any existing channels the user has opened.

The recovery also ran after the node was already started, requiring an expensive stop/restart cycle. This change moves the fetch to before node initialization, so monitors are included in the initial LDK setup — matching the iOS approach.

Preview

QA Notes

  1. Verify compilation and tests pass
    • ./gradlew compileDevDebugKotlin
    • ./gradlew testDevDebugUnitTest
    • ./gradlew detekt
  2. Fresh install from RN migration
    • Install RN app, open a channel, backup seed
    • Install Android app, restore from seed
    • Verify orphaned monitors are recovered without node restart in logs
    • Verify channel manager is not overwritten (look for "Applied channel migration" log with monitors count)
  3. Normal startup (no migration)
    • Verify isChannelRecoveryChecked short-circuits the check
    • Verify no extra network calls on startup

@jvsena42 jvsena42 force-pushed the fix/orphaned-channels-override branch from ed8c8a1 to b5da1f0 Compare March 6, 2026 11:24
@jvsena42 jvsena42 marked this pull request as draft March 6, 2026 12:02
@jvsena42
Copy link
Member Author

jvsena42 commented Mar 6, 2026

draft for testing

@jvsena42
Copy link
Member Author

jvsena42 commented Mar 6, 2026

after setting channelManager = null the ChannelClose event is not being triggered. I'm still investigating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move orphaned channel monitor check to pre-setup node

1 participant