Skip to content

Conversation

@ben-kaufman
Copy link
Contributor

This PR adds support for migrating an existing React Native Bitkit into the Bitkit native app.
The migration passes:

  • Balances
  • Channels
  • Activities
  • Settings
  • Widgets
  • Tags and notes
  • Closed Channels
record.mp4

What's still needed:

  1. New design for the loading screen and success toast of migration
  2. Support for restoring a wallet created in RN app which was later deleted. Ie. create wallet in RN, use it, delete the app, install native, recover using mnemonic.

Copy link
Contributor

Copilot AI left a 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

Comment on lines +532 to +535
var jsonString = rootJson
if let jsonStart = rootJson.firstIndex(of: "{") {
jsonString = String(rootJson[jsonStart...])
}
Copy link

Copilot AI Dec 24, 2025

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.

Copilot uses AI. Check for mistakes.
@jvsena42

This comment was marked as resolved.

@ben-kaufman
Copy link
Contributor Author

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
jvsena42 previously approved these changes Dec 30, 2025
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

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

Tested on #292 :

  1. On RN, open a channel
  2. Perform lightnign and on-chain transaction
  3. On native: Remove "-regtest" from Bitkit and BitkitNotification Bundle identifier
  4. Install app
  5. All activities and channels were restored with success

Copy link
Member

@jvsena42 jvsena42 left a 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

@pwltr
Copy link
Contributor

pwltr commented Jan 5, 2026

Ran another test, functionality looks good to me, couldn't find any issues.

  1. Launch react native app
  2. Create wallet
  3. Use app
    • receive onchain funds
    • send/receive/boost/tag onchain transactions
    • open channels
    • send/receive/tag lightning payments
    • change settings
    • set PIN
    • complete backup mnemonic flow
    • reorder/add/remove widgets
  4. Update to native app
  5. Check that all data was restored successfully
  6. Use app
  7. Wipe and restore from mnemonic

@ben-kaufman
Copy link
Contributor Author

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

@pwltr
Copy link
Contributor

pwltr commented Jan 5, 2026

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.

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.

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

@ovitrif ovitrif enabled auto-merge January 6, 2026 00:49
@ovitrif ovitrif disabled auto-merge January 6, 2026 00:49
@ovitrif ovitrif merged commit 36c3449 into master Jan 6, 2026
10 checks passed
@ovitrif ovitrif deleted the feat/rn-migration branch January 6, 2026 00:49
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.

5 participants