Skip to content

feat: add bbolt-to-SQLite migration tool for embedded LND wallets#3788

Draft
kaloudis wants to merge 6 commits intoZeusLN:masterfrom
kaloudis:embedded-lnd-sqlite-migration-tool
Draft

feat: add bbolt-to-SQLite migration tool for embedded LND wallets#3788
kaloudis wants to merge 6 commits intoZeusLN:masterfrom
kaloudis:embedded-lnd-sqlite-migration-tool

Conversation

@kaloudis
Copy link
Copy Markdown
Contributor

@kaloudis kaloudis commented Mar 5, 2026

Description

Relates to issue: ZEUS-3357

Summary

  • Adds a migrateBboltToSqlite utility that stops LND, rewrites the config for SQLite, restarts, and verifies the
    migration succeeded (rolling back on failure)
  • Adds migration tracking in MigrationUtils to record whether a migration has been attempted for a given wallet
  • Adds a "Migrate Database to SQLite" item to the Tools menu, visible only for embedded LND nodes still using
    bbolt
  • Shows a confirmation dialog before migrating, and restarts the app on success

Test plan

  • Verify the menu item appears in Tools when using an embedded LND node with isSqlite unset/false
  • Verify the menu item does NOT appear for non-embedded-LND nodes or nodes already using SQLite
  • Test the migration flow on a bbolt wallet: confirm dialog → migration → success alert → app restart
  • Verify the node's isSqlite setting is updated to true after successful migration
  • Test migration failure scenario (e.g. wrong password) and verify the error alert is shown and config is rolled
    back

PR Type

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • Embedded LND
  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • Nostr Wallet Connect
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial feature allowing users to seamlessly migrate their embedded LND wallet databases from bbolt to SQLite. This change aims to enhance the underlying database performance and maintainability for embedded LND nodes by providing a guided, user-initiated migration path, complete with safeguards for configuration and user experience.

Highlights

  • SQLite Migration Utility: A new utility, migrateBboltToSqlite, has been added to stop LND, rewrite its configuration for SQLite, restart, and verify the migration, with automatic rollback on failure.
  • Migration Tracking: MigrationUtils now includes functionality to record and check whether a bbolt-to-SQLite migration has been attempted for a given wallet.
  • User Interface Integration: A 'Migrate Database to SQLite' option has been added to the Tools menu, appearing only for embedded LND nodes still utilizing bbolt.
  • Interactive Migration Flow: The migration process now includes a confirmation dialog, and upon successful completion, the app will restart.
Changelog
  • locales/en.json
    • Added new localization strings for the SQLite migration feature, including menu item text, confirmation, success, and failure messages.
  • utils/LndMobileUtils.ts
    • Introduced migrateBboltToSqlite function to manage the LND database migration process, including stopping LND, updating configuration, restarting, and verifying success or rolling back.
  • utils/MigrationUtils.ts
    • Added BBOLT_TO_SQLITE_MIGRATION_KEY constant for tracking migration status.
    • Implemented hasDatabaseMigrationBeenAttempted to check if a migration has been previously tried.
    • Added markDatabaseMigrationAttempted to record a successful migration attempt.
    • Created checkBboltWalletExists to identify embedded LND nodes still using bbolt with existing wallet data.
  • views/Tools/index.tsx
    • Imported migrateBboltToSqlite and MigrationsUtils for use in the Tools view.
    • Implemented handleMigrateSqlite to orchestrate the user-facing migration flow, including alerts, calling the migration utility, and updating node settings.
    • Added a conditional UI element to display the 'Migrate Database to SQLite' option in the Tools menu for eligible embedded LND nodes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist 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

This pull request introduces a valuable feature for migrating embedded LND wallets from bbolt to SQLite, including a new utility function, migration attempt tracking, and a UI in the Tools menu. A critical privacy leak was identified where the Tor setting is ignored during migration restart, potentially exposing the user's IP address. This should be addressed by passing the user's Tor preference to the migration utility. Additionally, there are areas for improvement in code robustness and maintainability, specifically regarding error handling in the core migration logic and improving type safety by replacing any types with the specific Node interface.

@kaloudis kaloudis linked an issue Mar 5, 2026 that may be closed by this pull request
@kaloudis kaloudis force-pushed the embedded-lnd-sqlite-migration-tool branch from c5f3500 to ce775cd Compare March 23, 2026 00:32
@kaloudis kaloudis force-pushed the embedded-lnd-sqlite-migration-tool branch from ce775cd to 02561ac Compare March 23, 2026 00:47
@kaloudis
Copy link
Copy Markdown
Contributor Author

Pumping the brakes on this, as we have to create our own db migration tool to facilitate this or build off of code from https://github.com/lightninglabs/lndinit?tab=readme-ov-file#migrate-db

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded LND: migrate to SQLite

2 participants