wallet/sql: preserve legacy wallet schema#1285
Closed
Roasbeef wants to merge 4 commits into
Closed
Conversation
In this commit, we add sqlc to the repository tool image and wire deterministic generation into the Makefile and CI. This gives each schema PR a mechanical check that the generated Go query surface matches the SQL checked into the tree. Extracted-from: e0666e0 Extracted-from: b6fbbb6 Extracted-from: 66cc4be Extracted-from: bd468f6
In this commit, we add the first SQLite + PostgreSQL schema slice for the port-first wallet. The block table uses the chain height as its natural key, keeps the backend-specific byte types explicit, and generates the same query surface for both backends. This lands only SQL assets and generated accessors. It does not route the wallet through a new store or change any public wallet API. Extracted-from: f6e0258 Extracted-from: 3d67ecd Extracted-from: e773de5 Extracted-from: 69e459b Extracted-from: 594bb0d Co-authored-by: Gustavo Stingelin <gustavo.stingelin@outlook.com> Co-authored-by: yyforyongyu <yong2452@gmail.com>
In this commit, we add bounded SQLite and PostgreSQL connection pools and an embedded migration runner that can move the schema from empty to head, back to empty, then forward again. We use the released lnd/sqldb v1.0.13 module for shared SQLite defaults and make its transaction, error, and query utilities available to the later store adapter. The wallet schema and rollback-capable migration runner stay local because the concrete lnd stores own lnd-specific schema and migration ordering. Extracted-from: de762f0 Extracted-from: 2477f80 Extracted-from: 12bedf6 Extracted-from: 9bf5e56 Extracted-from: aa1725a8755db62a8746e46ee8894ab5df3d828a Extracted-from: d7a5127cc08edb68455f1e7ece45564df3fee487 Extracted-from: 7074419bfe3f7dcd393e302d6201177d3e35df49 Extracted-from: 2be43f4108cc143abb83dd8e35f8e5d4d0667fa3 Co-authored-by: Viktor Torstensson <viktor.t.git@gmail.com> Co-authored-by: yyforyongyu <yong2452@gmail.com>
In this commit, we add the wallet, scope, account, and address schema shared by the SQLite and PostgreSQL backends. The schema keeps the current dual-passphrase encryption hierarchy, watch-only nullability, encrypted public material, scope account counters, and SHA256 address identifiers. It also persists the sticky used bit directly, so the SQL port does not change gap-limit behavior or require the key-vault rewrite. Extracted-from: bbfe24b Extracted-from: b6b6a7e Extracted-from: 9a313ea Extracted-from: bb5a67b Extracted-from: c5d82b2 Extracted-from: 5a639d4 Extracted-from: 99e40ab Extracted-from: 132ba5b Extracted-from: 47b750b Extracted-from: 69e459b Co-authored-by: yyforyongyu <yong2452@gmail.com>
Roasbeef
marked this pull request as ready for review
July 11, 2026 00:28
Roasbeef
changed the base branch from
codex/sql-port-stage1-migrations
to
master
July 11, 2026 00:30
Member
Author
|
Replaced by #1289 after renaming the head branch to remove the codex prefix. The head SHA and commit structure are unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR, we add the port-first wallet, scope, account, and address schema for SQLite and PostgreSQL.
This PR is stacked on #1284, which adds the database connection and migration foundation.
The schema preserves the current dual-passphrase encryption hierarchy and encrypted public material instead of taking the single-passphrase key-vault redesign. It also preserves watch-only nullability, the explicit per-scope last-account counter, the manager creation time, uint32 account identity, SHA256 address identifiers, and all five legacy address row shapes.
Address usage remains a sticky persisted bit. We do not derive it from surviving UTXOs, since the KV wallet can mark an address used after the relevant transaction history is no longer available. This keeps
LastUnusedAddressand gap-limit behavior stable across a later migration.No wallet API, signer interface, PSBT flow, or runtime control path changes here.
Verification: