-
Notifications
You must be signed in to change notification settings - Fork 16
fix: prevent channel monitor loss when remote backup fails #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This is the PR that initially introduced the bug: #204 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug where channel monitor persistence was conditional on remote backup success, potentially causing unrecoverable fund loss. The fix ensures channel monitors are always persisted locally first, regardless of remote backup status.
Key Changes:
- Local channel monitor persistence now occurs before remote backup attempts
- Remote backup failures no longer block or skip local persistence
- Threading issues in
chainMonitor.channelMonitorUpdated()calls are fixed by dispatching to main/UI thread
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/package.json | Version bump from 0.0.160 to 0.0.161 |
| lib/ios/Classes/LdkPersist.swift | Reordered persistence to write locally first, moved remote backup to async callback, fixed threading for chain monitor update |
| lib/android/src/main/java/com/reactnativeldk/classes/LdkPersister.kt | Reordered persistence to write locally first, moved remote backup to async callback, fixed threading for chain monitor update |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, didn't test but the changeset reads easy, and I trust the author :D
|
As the copilot comment mentioned, is there any reason we shouldn't re-add the new channel event emitters beneath the local writes? Android: iOS: |
|
@coreyphillips I'm not so familiar with the code so maybe I'm wrong but I think it does call the new channel event since it no longer returns right after saving locally, so new channel event is now emitted in line 38 in Android and line 46 iOS. So that seems like a false positive issue from copilot. |
ben-kaufman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
|
@pwltr Will you add a PR to integrate this fix into Bitkit? Thx 🙏🏻 . |
Fix: Critical Channel Monitor Persistence Bug
🚨 Critical Issue Fixed
This PR resolves a critical bug that could lead to unrecoverable fund loss in multiple failure scenarios involving remote backup operations.
🐛 Problem
✅ Solution
chainMonitor.channelMonitorUpdated()calls🔧 Technical Changes
chainMonitor.channelMonitorUpdated()callsChannelMonitorUpdateStatus.Completedimmediately after local persistence🧪 Testing