Skip to content

Conversation

@dcorral
Copy link

@dcorral dcorral commented Jan 29, 2026

Summary

Replaces file-based persistence with SQLite database using sea-orm ORM.

Changes

New database tables:

  • mnemonic - encrypted mnemonic storage
  • kv_store - LDK persistence (channel manager, payments, swaps, network graph, scorer)
  • config - configuration key/value pairs (indexer_url, proxy_url, etc.)
  • revoked_token - revoked auth token IDs
  • channel_peer - channel peer pubkey/address mapping

Migrated to database:

  • Mnemonic (was encrypted file)
  • All LDK KVStore data (channel manager, inbound/outbound payments, swaps, scorer)
  • Config parameters (synced to files for rust-lightning compatibility)
  • Revoked tokens (was flat file)
  • Channel peer data (was flat file)
  • PSBTs (temporary storage during channel funding)
  • Output spender transactions

Architecture:

  • Single shared DatabaseConnection via Arc
  • SeaOrmKvStore implements rust-lightning's KVStoreSync trait
  • Migrations run automatically on startup
  • Config stored in DB as source of truth, synced to files for rust-lightning compatibility

Copy link
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

This is a quick review, will do a more detailed one after the following points have been addressed:

  • Why did you put the entities in an entity directory at the project root? If there's no particular reason please generate the entities in a src/database/ directory. Please also check the structure we used in rgb-lib, if possible I would appreciate if we could use the same naming/structure.

  • Please create a single init_db migration, it seems overkill to define the DB with multiple separate migrations.

  • Please avoid async-std since it's deprecated.

  • Please replace the auto-generated README in the migration crate with the one in rgb-lib, I think you can copy that and make only small changes.

  • Please do not refactor the test code, the PR should make only the changes necessary for its scope.

  • Please drop the src/test/revoked_token_persistence.rs file and just add some checks to the already existing authentication test.

  • I see no DB transaction usage, is this because there are no cases where they are required?

  • Please explain the purpose of SeaOrmKvStore.

  • Please explain or revert the changes to .gitignore.

  • Please use the latest version of sea-orm.

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.

2 participants