Skip to content

Wallet schema v2 #2146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: wallet-refactor-migrate-vault
Choose a base branch
from
Draft

Conversation

ekzyis
Copy link
Member

@ekzyis ekzyis commented May 2, 2025

Description

based on #2092 because it's the target branch

This PR does the following:

  • add static table WalletV2 which stores which send and receive methods a wallet supports
    => allows multiple send and recv methods per wallet
  • split wallets by send and recv for easier validation of configuration instead of having both send and recv optional and rely on application logic to make sure the configuration is not invalid
  • add wallet method tables (WalletSend..., WalletRecv...) which store configuration per user wallet
  • use triggers to make sure that a method of a user wallet is actually supported by the wallet

How to add a new wallet:

  • add a new row to the WalletV2 table and declare which send and recv methods it supports
  • if it supports a new method, update enums and add a new wallet method table to store configuration

TODO:

  • use unique index for walletId in wallet method tables so a user wallet can't have the same method twice for the same wallet
  • check if HTTP methods to send and recv (LNbits, Blink, Phoenixd) can be abstracted away via one WalletSendHTTP table without resorting to JSON columns
  • check if triggers can be unified
  • add trigger to update JSON in UserWallet row
    • split JSON column into two columns for send and recv?
  • wallet migration
    • wallet seed
    • migrate wallets
    • wallet seed with multiple wallets (LNbits, NWC, ...) per user
    • merge send/recv methods into the same wallet as much as possible
    • verify wallet migration with SQL assertions after migration
  • verify wallet support
  • update code to save/load wallets
  • rename walletId foreign keys that point to UserWallet instead of WalletV2 to userWalletId to avoid confusion?

Additional Context

This is based on the latest discussion with @huumn how to plan further ahead with the wallet schema than to just migrate the vault in #2092.

Checklist

Are your changes backwards compatible? Please answer below:

tbd

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

tbd

For frontend changes: Tested on mobile, light and dark mode? Please answer below:

n/a

Did you introduce any new environment variables? If so, call them out explicitly here:

no

@ekzyis ekzyis added the wallets label May 2, 2025
@ekzyis ekzyis marked this pull request as draft May 2, 2025 06:11
@huumn huumn mentioned this pull request May 5, 2025
13 tasks
@ekzyis ekzyis force-pushed the wallet-refactor-migrate-vault branch from 7efb350 to a10af10 Compare May 5, 2025 23:05
@ekzyis ekzyis force-pushed the wallet-schema-v2 branch 3 times, most recently from eccc4d0 to 840bb20 Compare May 7, 2025 05:35
Copy link

gitguardian bot commented May 7, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
16991000 Triggered Generic High Entropy Secret f45e9f0 docker/db/wallet-seed.sql View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@ekzyis ekzyis force-pushed the wallet-schema-v2 branch from 840bb20 to 571408b Compare May 7, 2025 05:45
* static table WalletV2 stores which send and receive methods a wallet supports
  => allows multiple send and recv methods per wallet
* split wallets by send and recv for easier validation of configuration instead of having both send and recv optional
  and rely on application logic to make sure the configuration is not invalid
* wallet method tables (WalletSend..., WalletRecv...) store configuration per user wallet
* use triggers to make sure that a method of a user wallet is actually supported by the wallet

How to add a new wallet:

* add a new row to the WalletV2 table and declare which send and recv methods it supports
* if it supports a new method, add a new method table to store the configuration and set correct enum value as type
@ekzyis ekzyis force-pushed the wallet-schema-v2 branch from 571408b to 548ee49 Compare May 8, 2025 03:26
ekzyis added 2 commits May 8, 2025 00:47
This moves existing wallets from the old schema to the new schema.

However, this will create a new wallet for each old wallet even though they could possibly be merged into the same wallet since wallets support multiple send/recv methods now.

This will be fixed in a later commit.
@ekzyis ekzyis force-pushed the wallet-schema-v2 branch from 548ee49 to b961fb9 Compare May 8, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant