Skip to content

wallet/sql: preserve legacy wallet schema#1289

Open
Roasbeef wants to merge 1 commit into
sql-port-stage1-migrationsfrom
sql-port-stage1-wallet-schema
Open

wallet/sql: preserve legacy wallet schema#1289
Roasbeef wants to merge 1 commit into
sql-port-stage1-migrationsfrom
sql-port-stage1-wallet-schema

Conversation

@Roasbeef

Copy link
Copy Markdown
Member

In this PR, we add the port-first wallet, scope, account, and address schema for SQLite and PostgreSQL.

This PR is stacked on #1288, 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 LastUnusedAddress and gap-limit behavior stable across a later migration.

No wallet API, signer interface, PSBT flow, or runtime control path changes here.

Verification:

  • SQLite and PostgreSQL migration round trips
  • legacy watch-only, scope, account, address, and ciphertext shape tests
  • generated sqlc code reproduced cleanly
  • full package tests, excluding the environment-dependent local bitcoind startup failure

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
Roasbeef force-pushed the sql-port-stage1-wallet-schema branch from 97c962d to 6ca4b5f Compare July 11, 2026 01:16
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