Skip to content

fix: orphaned channel recovery pre-startup#826

Merged
jvsena42 merged 9 commits intomasterfrom
fix/orphaned-channels-override
Mar 9, 2026
Merged

fix: orphaned channel recovery pre-startup#826
jvsena42 merged 9 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:
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.

Preview

recover-channel-monitor.webm
counterparty-close.webm

QA Notes

Implement this code to simulate a failure:

    suspend fun retrieveChannelMonitor(channelId: String): ByteArray? = withContext(ioDispatcher) {
        runCatching {
            throw RuntimeException() //dont commit
  1. Fresh install from RN migration
    • Install RN app, open a channel, backup seed
    • Implement android code to simulate a channel recovery failure
    • Install Android app, restore from seed
    • Verify the channel is force closed
    • Open a new channel
    • Re-runt the android app without the mock code
    • ✅ Verify channel monitor is imported and the new channel is not closed
    • Mine 146 blocks
    • Verify that the swiping transaction is displayed and the balance is updated

OBS: The not can't trigger the ChanelClosed event for the RN closed channel because the old channelManager isn't set anymore, but still can detect the confirmed force-close transaction because it imports the channel monitor. Same behavior on iOS

OBS2: I realized there is not much value on implementing #819 for android because the node is frequently already running from the Foreground Service logic and would have to be restarted anyway

  1. Normal counterparty close channel
    • Use the slack command to close the channel
    • Verify the app displays the closed channel sheet and update the balance

@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

@jvsena42 jvsena42 self-assigned this Mar 8, 2026
@jvsena42 jvsena42 marked this pull request as ready for review March 8, 2026 16:57
@jvsena42 jvsena42 enabled auto-merge (squash) March 9, 2026 10:06
@jvsena42 jvsena42 requested a review from ovitrif March 9, 2026 10:06
@jvsena42 jvsena42 modified the milestones: 2.0.1, 2.1.0 Mar 9, 2026
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Found 3 CLAUDE.md compliance issues.

@jvsena42 jvsena42 requested a review from pwltr March 9, 2026 11:58
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

Tested:

  1. Fresh install from RN migration 🟢
  2. Normal counterparty close 🟢

Two remarks:

  1. Would've been great to create a Closed Channel record in the Lightning Connections screen.
  2. Would've been nice to fix #668 for release 2.1.0
    • Since we're working with milestones now, assigned it the 2.2.0 milestone for next release

@jvsena42 jvsena42 merged commit 3f24993 into master Mar 9, 2026
17 checks passed
@jvsena42 jvsena42 deleted the fix/orphaned-channels-override branch March 9, 2026 18:56
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

2 participants