-
Notifications
You must be signed in to change notification settings - Fork 1
feat: support RN app migration #290
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
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 adds support for migrating existing React Native Bitkit wallets to the native Swift app. The migration automatically detects RN wallet data on first launch and transfers wallet credentials, Lightning channels, settings, activities, widgets, and metadata to the native app format.
Key Changes:
- Comprehensive RN wallet data detection and migration system with MMKV binary parsing
- Channel migration support for Lightning Network state preservation
- Migration loading UI with success/error toast notifications
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Bitkit/Services/MigrationsService.swift | Implements complete RN migration logic including MMKV parsing, keychain reading, and data transformation for settings, activities, channels, and widgets |
| Bitkit/AppScene.swift | Adds migration detection flow on app startup and displays loading screen during migration |
| Bitkit/ViewModels/WalletViewModel.swift | Passes pending channel migration data to Lightning service during wallet initialization |
| Bitkit/ViewModels/AppViewModel.swift | Handles post-sync migration completion with metadata reapplication and success notification |
| Bitkit/Services/LightningService.swift | Accepts and applies channel migration data during Lightning node setup |
| Bitkit/Services/CoreService.swift | Adds utility to mark all unseen activities as seen after migration |
| Bitkit/Utilities/Keychain.swift | Removes outdated TODO comment about RN keychain migration |
| Bitkit.xcodeproj/.../Package.resolved | Updates ldk-node dependency revision for channel migration support |
| var jsonString = rootJson | ||
| if let jsonStart = rootJson.firstIndex(of: "{") { | ||
| jsonString = String(rootJson[jsonStart...]) | ||
| } |
Copilot
AI
Dec 24, 2025
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.
The JSON extraction logic is duplicated across multiple extract methods (extractRNMetadata, extractRNWidgets, extractRNActivities, extractRNClosedChannels). Consider extracting this into a shared helper method that takes a key name and returns the parsed JSON object.
This comment was marked as resolved.
This comment was marked as resolved.
|
Just retried with the seed you shared, when I restored in the RN channels were forced closed so I opened new ones, then installed the native app and channels and LN txs passed with no issue. Can you please recheck the bundle ID matches that of RN and the network in both is set to regtest? |
jvsena42
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.
Tested on #292 :
- On RN, open a channel
- Perform lightnign and on-chain transaction
- On native: Remove "-regtest" from Bitkit and BitkitNotification Bundle identifier
- Install app
- All activities and channels were restored with success
Support restore from RN app
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.
This the #290 (review) tests again
|
Ran another test, functionality looks good to me, couldn't find any issues.
|
|
Thanks @pwltr Just note one thing about the restore from mnemonic. It's works by checking which backup is latest the native or react then restores it, which means after you migrate the app auto backs up and then if you wipe and restore it recovers from the native app backup. So to test the restore from RN backup you'd need to either restore on the RN app again so it becomes the latest backup, or you could edit the AppScene file and set the the shouldRestoreRN to true so it ignores times and just restores from RN for testing |
Thanks yeah that's how I understood it. Tested both paths now and all good there as well. One thing to note is that none of the 'user' state is backed up so that is not restored, which you might have noticed. That's more general backup/restore though and not migration specific. I think we can live with that though. |
ovitrif
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.
Tested on mainnet with prod app installed and having a LN channel open.
The migration was successful and then I was able to send and receive LN funds.
considering this ✅ IMO
This PR adds support for migrating an existing React Native Bitkit into the Bitkit native app.
The migration passes:
record.mp4
What's still needed: