librustzcash icon indicating copy to clipboard operation
librustzcash copied to clipboard

`zcash_client_sqlite`: Enable migrations to be performed without any seed

Open str4d opened this issue 11 months ago • 0 comments

Some migrations require a seed phrase. Currently we have two:

  • UFVK support: seed required to derive the Orchard FVK component for each (derived) account.
  • Account ID changes: seed required to derive the seed fingerprint to store with each derived account.

As discussed in #1283, there are cases where a caller wants to query a wallet DB without necessarily having any of the necessary seeds. We should therefore have an opt-in way to migrate a database without any of the relevant seeds, which "downgrades" all accounts to "read-only" (i.e. from Derived to Imported).

  • In a pairing with @nuttycom, we considered this transition in terms of allowing hd_seed_fingerprint to be null while hd_account_index was non-null. That would be sufficient if we were modifying the latest migration making the account ID changes (as part of Zashi 1.0), but in the general migration case we'd either need to have some other way to track this, or do something like delete the seed fingerprint from the database. For #1283 (and therefore Zashi 1.0) we are avoiding this complexity.

We would also want to pair this with some new method like WalletWrite::link_seed(Self::AccountId, seed, zip32::AccountId) that enables "upgrading" a UFVK account from Imported to Derived (enabing spends from them again).

  • We cannot upgrade accounts imported from UIVKs, as we have not performed the necessary historic scanning, and can't do that scanning in-line within a WalletWrite call. The caller would need to delete the UIVK account and then separately add the derived account with its UFVK.

str4d avatar Mar 18 '24 16:03 str4d