Commit Graph

338 Commits

Author SHA1 Message Date
Jack Grigg a0016588ac Remove unused dependencies
Some were only used by tests, others weren't used at all.
2022-11-01 09:02:27 +00:00
Francisco Gindre 60c153930d get_transparent_balances fails with `no such column`
Error message:

"Error while fetching transparent balances for AccountId(0): no such column: u.received_by_accountt"

Closes #686
2022-10-26 19:09:36 -03:00
Kris Nuttycombe 334383f363 Allow shielding from multiple taddrs within a single transaction. 2022-10-25 13:17:21 -06:00
Kris Nuttycombe efa95fcb39 Add `get_transparent_balances` to data api. 2022-10-25 12:53:54 -06:00
Kris Nuttycombe 8cb16d878e Require a source transparent address to shield transparent funds.
Previously, `shield_transparent_funds` was only shielding funds
associated with the legacy default transparent address. This meant
that transparent funds sent to unified addresses could not reliably
be shielded, as a unified address will frequently be constructed
using a diversifier index greater than zero.

This modifies the `get_transparent_receivers` method to return address
metadata containing the account ID and diversifier index used to derive
each address along with the receiver.
2022-10-25 12:53:54 -06:00
Kris Nuttycombe e13459bd31 Allow insertion of UTXOs associated with the legacy taddr.
The legacy transparent address is never added to the `addresses` table,
but we still need to be able to receive UTXOs sent to that address. So,
we add a special case for when a UTXO matches that legacy address, and
set the account ID to 0 manually.
2022-10-24 17:32:30 -06:00
Sean Bowe bd7f9d7c3c
Bump zcash_encoding and zcash_address crate versions to 0.2. 2022-10-19 16:51:59 -06:00
Kris Nuttycombe 5bf36989e2 Fix beta clippy complaints. 2022-10-19 13:35:51 -06:00
Sean Bowe 176e21b015
Update zcash_primitives to orchard 0.3; release zcash_primitives and zcash_proofs 0.8. 2022-10-19 13:32:51 -06:00
Kris Nuttycombe c773ea3b3e Make the internals of `WalletTransparentOutput` private. 2022-10-14 12:38:55 -06:00
Kris Nuttycombe 69791af92c Mark our utxos spent when we detect them as inputs to a transaction.
This modifies `decrypt_and_store_transaction` to check for inputs
to a transaction being decrypted that correspond to utxos known
to our wallet. For each such UTXO found, it is marked spent.
2022-10-14 10:40:43 -06:00
Kris Nuttycombe 47a0d0d2b7 Remove the `WalletReadTransparent` and `WalletWriteTransparent` extension traits.
These traits introduce a problem, in that constraints on a method cannot
be conditionally required based upon the presence or absence of a
feature flag. Instead, we make the methods previously introduced by
the removed traits present in all cases on the `WalletRead` and
`WalletWrite` traits, but ensure that their implementations return
an error if the caller attempts to use them in a wallet that has not
been configured with support for transparent inputs functionality.
2022-10-13 21:05:49 -06:00
Jack Grigg 8842de18cc Remove unused dependencies
These were mostly detected with `cargo-udeps`, for which I've also added
exclusions for the dependencies it can't detect are used in doc-tests.
2022-10-13 20:06:52 +00:00
Kris Nuttycombe 5864e71eec
Add comment to call out the storage details of diversifier indices.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-10-13 10:38:59 -06:00
Kris Nuttycombe 306d37e706 Add a test verifying that update fails on missing associated address. 2022-10-13 09:13:14 -06:00
Kris Nuttycombe f1f9465f37 Remove `received_by_account` field from WalletTransparentOutput
Due to how the wallets retrieved unspent transparent outputs from the
light wallet server, the account associated with a particular UTXO may
not be known by the light wallet. Instead of requiring the caller to
perform a separate lookup and match the address of the received UTXO
with a known account, it's simpler to perform this lookup internally at
the time of insertion or update.

In order to make this operation more efficient, the `addresses_table`
migration is modified to add a column to cache the transparent receiver
so that it may be used in the joins in the UTXO insert and update
operations.
2022-10-12 23:11:39 -06:00
str4d 59a4dd6efc
Merge pull request #665 from nuttycom/wallet/transaction_views_add_account
Add more information to v_transactions, v_sent_tx, and v_received_tx
2022-10-13 00:38:37 +01:00
Kris Nuttycombe 5a2f659594 Ensure that only purely wallet-internal tx are returned as internal.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2022-10-12 16:53:00 -06:00
Kris Nuttycombe e6f039d0f9 Allow multiple migrations to be specified for custom wallet init.
Since our migrations form a DAG, it doesn't make sense to only allow a
single migration to be specified for wallet initialization; instead,
allow multiple migrations so that one can hit all the desired leaves.
2022-10-12 12:35:27 -06:00
Kris Nuttycombe f7a3b9bda3
Merge pull request #661 from nuttycom/wallet/spend_with_usk
Use unified spending keys for spends & shielding.
2022-10-12 12:15:34 -06:00
Kris Nuttycombe c3b6ef28c9
Merge pull request #647 from nuttycom/update_ua_test_vectors
Update unified address test vectors
2022-10-12 10:56:26 -06:00
Kris Nuttycombe 85390cb8ce Add more information to v_transactions, v_sent_tx, and v_received_tx
This adds sent and received note count information, transaction fees,
account information, and makes the information returned about sent
notes and received notes consistent with one another.
2022-10-12 08:52:37 -06:00
Kris Nuttycombe e666e69230 Address comments from code review. 2022-10-11 16:21:17 -06:00
Kris Nuttycombe fdf5aa7b8e Fix exclusive or in sent_notes recipient check. 2022-10-11 15:49:52 -06:00
Kris Nuttycombe 62e1f99eb0 Improve TransferType documentation. 2022-10-11 14:42:06 -06:00
Kris Nuttycombe fd1640c242 Update CHANGELOGs 2022-10-11 13:08:15 -06:00
Kris Nuttycombe 3c837381db Disallow invalid pool/address combinations with `Recipient`. 2022-10-11 12:52:44 -06:00
Kris Nuttycombe 56b2edd498 Simplify sqlite backend storage for sent notes & utxos.
The currently deprecated implementations of `insert_sent_utxo`,
`insert_sent_note`, `put_sent_utxo` and `put_sent_note` all store to the
same `sent_notes` table internally. Since there's no immediate plan to
change this arrangement, it's better to have a single pair of internal
`insert_sent_output` and `put_sent_output` methods instead.
2022-10-11 08:57:44 -06:00
Kris Nuttycombe 06e43a572a Track inputs sent to wallet-internal recipients.
Ensure that we're attempting trial-decryption with the internal IVK
and correctly track internal vs. external recipients in the wallet
database.
2022-10-11 08:56:22 -06:00
str4d 1dc3cfe724
Merge pull request #657 from nuttycom/wallet/upsert_utxos
Use upsert functionality for transparent UTXOs, rather than delete/repopulate.
2022-10-11 04:17:49 +01:00
Kris Nuttycombe bd8472535c Add a test for unified address derivation. 2022-10-07 20:37:39 -06:00
Kris Nuttycombe c7be8ef04a Allow spent UTXOs to be absent in migrations when adding tx fee.
The previous approach to UTXO handling involved UTXO data being
deleted from the wallet after the relevant UTXOs had been spent.
However, this means that we can no longer accurately compute
transaction fees for the transactions spending those UTXOs.
The `net_value` of the resulting rows in v_transactions will be
null.
2022-10-06 17:13:27 -06:00
Kris Nuttycombe c5b9219f00 Look up the account by the UFVK corresponding to the USK when spending. 2022-10-05 14:35:51 -06:00
Kris Nuttycombe b7cc038050 Use unified spending keys for spends & shielding. 2022-10-05 14:35:51 -06:00
Kris Nuttycombe e9406201d5
Merge pull request #663 from nuttycom/sapling_key_cleanup
Fix Sapling key organization.
2022-10-05 14:35:16 -06:00
Kris Nuttycombe 6df6fec860 Add utxo received_by_account data to WalletTransparentOutput
Also, this removes wallet::delete_utxos_above.
2022-10-04 13:34:52 -06:00
Kris Nuttycombe 14787f574f Add a migration to add account ID to the utxos table. 2022-10-04 12:25:56 -06:00
Kris Nuttycombe 60785a1d7a Fix Sapling key organization.
This change moves Sapling-specific key generation into a
submodule of `zip32`. Public reexports are used to keep the
existing API consistent.
2022-10-03 20:28:04 -06:00
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