Commit Graph

300 Commits

Author SHA1 Message Date
Kris Nuttycombe f7aa7b2c84 Upgrade rusqlite to version 0.25 2022-10-03 08:12:37 -06:00
Kris Nuttycombe 81e0d482d0
Merge pull request #656 from nuttycom/sqlite/migration_organization
Move wallet migrations into individual modules.
2022-10-03 08:10:08 -06:00
Jack Grigg e54e3f21e8 zcash_client_sqlite: Remove direct ff dependency 2022-10-02 23:16:44 +01:00
Kris Nuttycombe ccf9e00b00 Move wallet migrations into individual modules. 2022-10-02 14:20:17 -06:00
Kris Nuttycombe 2c16f78fee zcash_client_sqlite: fix wallet::get_max_account_id
This had the same bug as was fixed in 5b8ec380a0
2022-09-26 16:48:58 -06:00
Kris Nuttycombe 6cb0d21219
Merge pull request #645 from nuttycom/fix_beta_lints
Fix problems identified by clippy's beta lints
2022-09-17 15:49:49 -06:00
Kris Nuttycombe 03c3370de8 Fix problems identified by clippy's beta lints 2022-09-17 08:57:37 -06:00
Jack Grigg 5b8ec380a0 zcash_client_sqlite: Fix `FsBlockDb::get_max_cached_height`
The `MAX` SQLite function returns `null` when the table is empty. The
code was expecting zero rows to be returned in this case, and was trying
to parse the `null` as an integer.
2022-09-17 02:40:19 +00:00
Kris Nuttycombe f8fd27653c Add a BlockSource implementation that reads blocks from files in the filesystem.
Also, this adds functionality to create and insert records into the
block metadata db that is used as the source for which blocks to read.
2022-09-15 08:27:26 -06:00
Kris Nuttycombe d086c57f2f Make init_accounts_table only permit sequential account identifiers.
Also, check to ensure that account creation does not exceed the
maximum account identifier value.
2022-09-14 13:55:31 -06:00
Kris Nuttycombe 75eb082203
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-09-14 12:20:39 -06:00
Kris Nuttycombe d0062a87d4 Add WalletWrite::create_account function 2022-09-13 18:58:28 -06:00
Kris Nuttycombe b5908dc964
Merge pull request #632 from nuttycom/data_api/get_next_address
Replace `get_address` with `get_current_address` and `get_next_available_address`
2022-09-12 18:43:38 -06:00
Kris Nuttycombe 03b0ff7e0a Replace `get_address` with `get_current_address` and `get_next_available_address`
This updates the data access API to provide diversified address
functionality. In order to support this change, the addresses table
is updated to store diversifier index information in big-endian order
to allow sorting by diversifier index, and account initialization
is updated to store the diversifier index accordingly. The currently
unreleased `addresses_table` migration is updated to reflect this
change.
2022-09-12 17:58:22 -06:00
Kris Nuttycombe 7d1e976d0a Add missing `WalletMigrationError` to changelog. 2022-09-10 17:02:43 -06:00
Kris Nuttycombe e14e44d6d7 Improve consistency of transaction views test. 2022-09-10 17:02:43 -06:00
Kris Nuttycombe 3120b304c7 Use `NULL` to represent the empty memo.
We don't need to store a bunch of copies of the empty memo, and code
should not be depending upon the presence or absence of a memo to
distinguish between different states of transaction retrieval.
2022-09-10 17:02:43 -06:00
Kris Nuttycombe 167bcd86ce Update migration to handle the raw-tx-absent case.
The raw serialized transaction data for a transaction is not always
guaranteed to be present, and we cannot correctly calculate the fee
paid by a transaction if we don't have the raw data. For such rows
that contain only transaction metadata, the fee information will be
added at the same time the raw transaction data is added.
2022-09-10 17:02:43 -06:00
Kris Nuttycombe 7934e834d3 Add test for fee calculation in add_transaction_views migration. 2022-09-10 11:01:36 -06:00
Kris Nuttycombe b327bf7073 Move WalletMigrationAddTxViews to a submodule. 2022-09-10 11:01:36 -06:00
Kris Nuttycombe 7842e6274f Check against the standard empty memo for memo counts. 2022-09-09 16:32:37 -06:00
Kris Nuttycombe 95610f7b4f Add fee to the transactions table & compute correct net_value in v_transactions. 2022-09-09 16:12:29 -06:00
Kris Nuttycombe 66c9f31e14 Add memo counts to transaction views. 2022-09-09 16:09:56 -06:00
Kris Nuttycombe 81c948a37e Add views that join transactions & notes for Android SDK support.
Android does not provide a good way to perform outer joins in
its type-safe query builder API, so we expose views build using
those joins instead.
2022-09-09 16:09:04 -06:00
Jack Grigg 7112ed9da5 zcash_client_backend: Add `WalletReadTransparent::get_transparent_receivers`
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-09-08 20:24:42 +00:00
Jack Grigg 154ef077b4 zcash_client_sqlite: Move address data to an `addresses` table
Closes zcash/librustzcash#489.
2022-09-08 18:50:18 +00:00
Jack Grigg 7d404d2747 zcash_client_sqlite: Fix `WalletRead::get_address` return value
Previously it would return an error if the account identifier did not
correspond to a known account.
2022-09-08 18:49:41 +00:00
Jack Grigg a32714043b zcash_client_backend: Change `WalletRead::get_address` to return UA 2022-09-08 18:49:13 +00:00
Kris Nuttycombe a93f5945ab Remove redundant TryFrom/TryInto imports. 2022-09-02 12:05:15 -06:00
Kris Nuttycombe 16a0e43f2d Update to Rust 2021 and explicitly set MSRVs 2022-09-02 12:05:09 -06:00
Jack Grigg 4f5d757883 zcash_client_backend: Change to `WalletWrite::remove_unmined_tx`
This fixes a bug in the logic ported from the Android SDK: it was
possible to remove a transaction in the middle of a chain, which would
cause a long-spent note to become unspent and cause the wallet balance
to be over-counted. We now restrict transaction removal to unmined
transactions, which is sufficient for the Android SDK use cases.
2022-08-30 22:54:58 +00:00
Jack Grigg 586b7e5bb0 zcash_client_backend: Add `WalletWrite::remove_tx` method
This is to replace the database mutations in the Android SDK. It is
placed behind an `unstable` feature flag until we are satisfied that it
is suitable as a general-purpose API (or replace it).
2022-08-29 21:32:18 +00:00
Jack Grigg 04b1d505b2 zcash_client_sqlite: Move `DataConnStmtCache` into submodule
This removes direct access to the prepared statements, instead forcing
callers to use the type-safe methods added in the previous commit.
2022-08-29 19:25:36 +00:00
Jack Grigg 12e8c53310 zcash_client_sqlite: Add statement helper methods to `DataConnStmtCache`
These methods provide type-safe ways to interact with the prepared
statements.
2022-08-29 19:25:36 +00:00
Jack Grigg 439e8f2599 zcash_client_sqlite: Add `DataConnStmtCache::new` constructor
This is a move-only commit (other than the necessary variable renames).
2022-08-29 15:26:08 +00:00
Kris Nuttycombe 5dceb93ec8
Merge pull request #612 from nuttycom/wallet/set_fixed_user_version
Set a fixed `user_version` value for the sqlite schema in the initial migration.
2022-08-23 14:29:46 -06:00
Kris Nuttycombe 83c47b1a42 Set a fixed `user_version` value for the sqlite schema in the initial migration. 2022-08-23 12:23:47 -06:00
Kris Nuttycombe 6b73443f53 Add a test to check the result of database migrations against an expected schema. 2022-08-23 12:16:19 -06:00
Kris Nuttycombe 5d817f6120 Update to schemer 0.2 2022-08-19 09:55:55 -06:00
Kris Nuttycombe 913d572087 Allow the seed to be an optional argument to database init.
This adds a new `WalletMigrationError` type so that we have
a good place to report whether or not the seed is required.
2022-08-18 16:03:20 -06:00
Kris Nuttycombe 61fb732e7b Ensure that we detect the correct pool type for sent notes. 2022-08-18 10:15:58 -06:00
Kris Nuttycombe e0c919cc68 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-08-18 10:15:58 -06:00
Kris Nuttycombe 880076b38f Improve error reporting for address & viewing key decoding. 2022-08-18 10:15:58 -06:00
Kris Nuttycombe 4930982d7e Test migrations against possibly-previously-existing database states.
This adds tests that verifies that migrations can run successfully
against databases in the following states:
* created by release version 0.3.0
* created by the `autoshielding_poc` branch
* created by current `main` prior to addition of migrations
2022-08-18 10:15:58 -06:00
Kris Nuttycombe e9db8d5b01 Use `secrecy` when handling seed phrases in migrations code. 2022-08-18 10:15:58 -06:00
Kris Nuttycombe cdfaa57496 Add migrations to support using UFVKs instead of Sapling extfvks.
Fixes #594
2022-08-18 10:15:58 -06:00
Kris Nuttycombe 7c5b320108 Introduce wallet database schema migrations.
This replaces the current wallet initialization code with a migration
that brings the database up to the state produced by release 0.3.0.
A subsequent commit will add migrations that correctly produce the
database state as of zcash/librustzcash@602270cb1f.

Fixes #369
2022-08-18 10:15:58 -06:00
Kris Nuttycombe 199c49760b Use the new name rustdoc::broken_intra_doc_links 2022-07-29 15:56:44 -06:00
Kris Nuttycombe f1c2da7b1d Add sapling::NullifierDerivingKey newtype.
Nullifier computation only requires the nullifier deriving key,
not the entire Sapling viewing key. This separation of concerns
will be needed for batch decryption when wallet-internal keys
will need to be considered.
2022-07-28 15:23:21 -06:00
Daira Hopwood 09567fc280
Merge pull request #574 from nuttycom/fix_account_key_init
Fix account key init
2022-06-29 21:36:29 +01:00