Commit Graph

318 Commits

Author SHA1 Message Date
Kris Nuttycombe bfc5b9a5b3 Parameterize `DecryptedOutput` by note type. 2023-04-26 14:47:10 -06:00
Kris Nuttycombe 55c2de0066 Remove the redundant `WalletSaplingOutput::to` and `DecryptedOutput::to` fields. 2023-04-26 14:47:10 -06:00
Kris Nuttycombe c15a185454 Remove deprecated APIs & rename Sapling-specific data structures to include "Sapling"
This helps to clarify the Sapling-specific nature of a number of
operations in wallet code.
2023-04-26 14:47:10 -06:00
Kris Nuttycombe 7d18d1d02a Adds documentation for the `v_transactions` and `v_tx_outputs` views.
This change also settles on `account_value_delta` as the name of the
column in `v_transactions` that describes the transaction's effect on
the value of the associated account.
2023-04-14 14:16:16 -06:00
Kris Nuttycombe b6fd844505 Fix Rust formatting errors. 2023-04-14 11:08:06 -06:00
Kris Nuttycombe 25b2148604 Account for received utxos in `v_transactions`.
Also, rename `v_tx_events` to `v_tx_outputs`.
2023-04-12 15:37:34 -06:00
Kris Nuttycombe 024c858c8a Ensure that we don't filter out sent UTXOs that collide with Sapling change output indices.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-04-11 16:21:02 -06:00
Kris Nuttycombe 17827539b3 Fix double-entry accounting errors in transaction views. 2023-04-11 14:59:48 -06:00
Kris Nuttycombe d6fafa291b Update Sapling note encryption for `zcash_note_encryption 0.3.0`
Fixes zcash/librustzcash#455
2023-03-21 11:09:38 -06:00
str4d b6f7ff06ed
Merge pull request #761 from nuttycom/wallet/expose_transaction_propose
Factor out a transaction proposal API from `spend`.
2023-02-01 00:51:31 +00:00
Kris Nuttycombe 4fafd14d17 Factor out a transaction proposal API from `spend`.
This change makes it possible for wallets using the
`zcash_client_backend::data_api::wallet` module to perform transaction
preparation, including input selection and fee calculation, as an
independent step prior to creating proofs and signatures. This can be
used to improve user experience by making it possible to report the
proposed effects of the transaction to the wallet user (including
privacy implications) prior to authorizing the transaction.
2023-02-01 00:15:33 +00:00
Kris Nuttycombe 636bac7154 Make block height argument to `BlockSource::with_blocks` optional.
Previously, if a caller wanted to use a block source to perform
scanning from the first available block, they would have to guess
at the block height to start from. Changing this to an optional
argument makes this explicit.
2023-01-31 13:14:07 -07:00
Francisco Gindre bf73ed3a00 Adds `limit` parameter to `validate_chain()`
This allows callers to validate smaller intervals of the given
`BlockSourceT` shortening processing times of the function call at the
expense of obtaining a partial result on a given section of interest of
the block source.

`params: &ParamsT` has been removed from the arguments since they were
only needed to fall back to `sapling_activation_height` when `None` as
passed as the `validate_from` argument. Passing `None` as validation
start point on a pre-populated `block_source` would result in an error
`ChainError::block_height_discontinuity(sapling_activation_height - 1, current_height)`

With this new API callers must specify a concrete `validate_from`
argument and assume that `validate_chain` will not take any default
fallbacks to chain `ParamsT`.

The addition of a `limit` to the chain validation function changes the
meaning of its successful output, being now a `BlockHeight, BlockHash)`
tuple indicating the block height and block hash up to which the chain
as been validated on its continuity of heights and hashes. Callers
providing a `limit` aregument are responsible of subsequent calls to
`validate_chain()` to complete validating the remaining blocks stored on
the `block_source`.

Closes zcash/librustzcash#705
2023-01-31 13:14:04 -07:00
Francisco Gindre e9eb5f8c0f Remove unstable function `WalletWrite::remove_unmined_tx`
Closes #622

Used PR https://github.com/zcash/librustzcash/pull/621 as reference to
know what had been added and remove it.
2023-01-31 15:21:46 -03:00
Kris Nuttycombe bf85a28ec1 Add a note about metadata database initialization to `FsBlockDb::for_path`
Fixes #748
2023-01-26 14:34:27 -07:00
Jack Grigg f00257faad zcash_client_sqlite: Add `FsBlockDb` API test 2023-01-25 15:39:38 +00:00
Jack Grigg 9226c98dd5 zcash_client_sqlite: `impl {Clone, Copy, Debug, PartialEq, Eq} for BlockMeta` 2023-01-25 15:33:02 +00:00
Jack Grigg e37f458a70 zcash_client_sqlite: Add `FsBlockDb::find_block` 2023-01-25 15:33:01 +00:00
Kris Nuttycombe 5d62b68d70
Merge pull request #756 from zcash/blockmeta_rewind_to_height
[#751] add support for rewind_to_height to FsBlockDb
2023-01-24 20:19:22 -07:00
Jack Grigg 7f970bb82f Use `EphemeralSecretKey, EphemeralPublicKey, SharedSecret` types in APIs 2023-01-24 15:02:49 +00:00
Jack Grigg 87d0bd7db1 Refactor `sapling::Note`
Its internals are now private, and it stores a `PaymentAddress` (and by
extension the diversifier) instead of `g_d`.
2023-01-24 15:02:27 +00:00
Jack Grigg 42c332a7a8 Use `sapling::note::ExtractedNoteCommitment` type in APIs 2023-01-24 14:37:11 +00:00
Francisco Gindre 7306b9d2a9 [#751] add support for rewind_to_height to FsBlockDb
Closes #751

Ran `cargo fmt`

return the result as an error rather than unwrap

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-01-17 14:43:33 -03:00
Kris Nuttycombe 95cbc7abaf
Merge pull request #734 from zcash/sapling-type-safety
Improve Sapling type safety
2023-01-05 13:12:45 -07:00
str4d 268754d635
Merge pull request #747 from zcash/FsBlockDbError_display
Implement fmt::Display descriptions for FsBlockDbError
2023-01-04 08:15:39 +00:00
Francisco Gindre 015a585cfb Implements fmt::Display descriptions for FsBlockDbError
Closes #742

Fix clippy errors

PR Suggestions. Make Displayed error messaged more readable to users

Revert clippy fixes in favor of rustfmt rules

Commit suggestion on `InvalidBlockstoreRoot`

Co-authored-by: str4d <jack@electriccoin.co>

PR Suggestion `MissingBlockPath`

Co-authored-by: str4d <jack@electriccoin.co>

PR Suggestion `InvalidBlockPath`

Co-authored-by: str4d <jack@electriccoin.co>

Run cargo fmt and fix issues
2023-01-03 14:59:52 -03:00
Dimitris Apostolou 500c8f657d
Fix typo 2022-12-31 13:03:24 +02:00
Kris Nuttycombe 125d2bc3d5
Merge pull request #727 from nuttycom/test/shield_transparent_funds
Add `shielding_threshold` argument to `shield_transparent_funds`.
2022-12-15 13:11:55 -07:00
Jack Grigg fee0b6a18d Make Sapling transaction structs non-transparent
We instead provide getters for the struct fields.
2022-12-13 04:03:06 +00:00
Jack Grigg 6c984429fb zcash_client_sqlite: Add error for missing FsBlockDB block files 2022-12-09 09:48:01 +00:00
Jack Grigg 3504d7031c zcash_client_sqlite: Remove `*Error` suffixes from `FsBlockDbError` cases 2022-12-09 09:48:01 +00:00
Kris Nuttycombe 0f56f095c2 Add `shielding_threshold` argument to `shield_transparent_funds`.
Previously, the shielding threshold was fixed to 100000 zatoshis.

Fixes #726
2022-12-08 17:15:48 -07:00
Kris Nuttycombe fff6983512 Replace a number of uses of `assert!(matches!(...))` with `assert_matches!(...)`
The remaining uses of `assert!(matches!(...))` are all in cases where
for some reason the `assert_matches` macro interferes with correct
type inference.
2022-12-08 12:17:14 -07:00
Kris Nuttycombe be4c19d82e Fix transparent balance error when the wallet is empty.
Fixes #724
2022-12-08 12:00:35 -07:00
Jack Grigg 7e71cc5353 Add `tracing` spans to light client chain scanning
This enables downstream users to profile how much time is spent in each
of the main subcomponents of the current chain scanner.
2022-12-06 08:17:49 +00:00
Kris Nuttycombe 73ab884073 Implement ZIP 317 fee estimation, calculation, & change selection 2022-11-10 15:30:13 -07:00
Kris Nuttycombe 847ba49761 Add dust note detection to change selection.
The change selection algorithm has the most useful information for
determining whether or not a note is dust, so this adds a new error case
to `ChangeError` that allows the change selection to report the presence
of input notes without economic value back to its caller.
2022-11-10 12:18:30 -07:00
Kris Nuttycombe 9a7dc0db84 Add traits for fee estimation and input selection
This adds a set of abstractions that allow wallets to provide
independent strategies for fee estimation and note selection, and
implementations of these strategies that perform these operations in the
same fashion as the existing `spend` and `shield_transparent_funds`
functions.

This required a somewhat hefty rework of the error handling in
zcash_client_backend. It fixes an issue with the error types whereby
callees needed to have a bit too much information about the error
types produced by their callers.

Reflect the updated note selection and error handling in zcash_client_sqlite.
2022-11-10 12:17:59 -07:00
Kris Nuttycombe cd29022233 Test spending of change notes. 2022-11-04 13:42:11 -06:00
str4d c5d8484f19
Merge pull request #688 from nuttycom/wallet/spend_internal_notes
Correctly construct outputs when spending internal notes.
2022-11-04 01:34:56 +00:00
Kris Nuttycombe c0abaa4727
Merge pull request #693 from nuttycom/wallet/skip_unmined_tx_in_migrations
Fix a bug in migrations when transaction block height is unknown.
2022-11-03 19:29:03 -06:00
Kris Nuttycombe 77efc18dd9 Fix a bug in migrations when transaction block height is unknown.
Un-mined transactions cannot currently be migrated to retroactively
store fee information, because the encoding used to persist them is unknown.
2022-11-03 18:54:53 -06:00
Kris Nuttycombe b68d37a0b1 Use DiversifiableFullViewingKey instead of ExtFVK where possible. 2022-11-03 18:44:45 -06:00
Jack Grigg 587e1fa60b Fix clippy lints related to `prost` API usage 2022-11-03 05:02:39 +00:00
Jack Grigg 379b703e6b zcash_client_backend: Switch from `protobuf 2` to `prost 0.11`
The latter is maintained by the Tokio developers, and has easy
integration with the `tonic` gRPC library which is actively maintained.
2022-11-02 06:21:38 +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