Commit Graph

17505 Commits

Author SHA1 Message Date
Greg Pfeil 1aac7c0c32
Split C++ generated from Rust into own lib
This allows us to compile it with different flags. In particular, there are
warnings we can’t easily fix in the generated code.
2023-04-03 18:09:30 -06:00
Sean Bowe fccdb03c53 Add additional audits. 2023-04-03 16:41:07 -06:00
Kris Nuttycombe 43a0fe237e Update to use the `ff 0.13` dependency stack. 2023-04-03 16:33:06 -06:00
Daira Emma Hopwood 4fd3493291 Implement ZIP 317 computations.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-03 23:05:50 +01:00
Greg Pfeil 8de607322e
Correct EditorConfig for Makefiles
It was deciding to convert tabs to spaces on save, which isn’t great.
2023-04-03 13:30:59 -06:00
DeckerSU 78804dd438
InsertBlockIndex: pass const reference on hash, instead of hash
InsertBlockIndex should take a const reference to a uint256 instead of
just a uint256.

LoadBlockIndexGuts also assume std::function<CBlockIndex*(const uint256&)> insertBlockIndex
as an argument:

2d456afebe/src/txdb.h (L150)
2023-04-02 23:00:08 +02:00
Greg Pfeil 6e42aaeed6
Update release-notes for transparent change restriction
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-04-01 22:59:33 -06:00
Greg Pfeil 1786c60677
Require `AllowRevealedRecipients` for t-change 2023-04-01 22:58:52 -06:00
Miodrag Popović e276f07349
Update depends/hosts/mingw32.mk to use posix variant library path
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-04-01 11:51:36 +02:00
Kris Nuttycombe 2d456afebe
Merge pull request #6408 from sellout/wallet_tx_builder/lock-notes
Lock notes (except Orchard) in wallet_tx_builder
2023-03-31 18:05:06 -06:00
Greg Pfeil 342563eb48
Merge pull request #6352 from sellout/deterministic-rpc-tests
Make RPC test output more deterministic
2023-03-30 14:33:03 -06:00
Greg Pfeil 69ab52cb3e
Improve Doxygen for note locking 2023-03-30 14:22:34 -06:00
Miodrag Popović e6372f4f1f Fix for broken cross-build to Windows target on Ubuntu 22.04 and Debian 11 2023-03-30 11:02:24 +02:00
Kris Nuttycombe 564ef2a3ac
Merge pull request #6502 from rex4539/typos
Fix typos
2023-03-29 22:23:33 -06:00
Kris Nuttycombe 06f4525bc1
Merge pull request #6410 from sellout/wallet_tx_builder/refactor-privacy-policy
Refactor RPC privacyPolicy handling
2023-03-29 18:39:11 -06:00
Greg Pfeil 06553d1399
Lock notes (except Orchard) in wallet_tx_builder
This fixes an RPC test failure that tests specifically for this with
z_shieldcoinbase. This also exposed an issue where an overly-high fee resulted
in a negative Payment causing an exception too deep. Added an assert when
creating a Payment and guarded against it for z_shieldcoinbase.

Fixes #2621 and #5654 (but does not handle Orchard locking, which is tracked in
a separate issue).
2023-03-29 16:59:43 -06:00
Kris Nuttycombe f60d2c71e7
Refactor RPC privacyPolicy handling
Extracted from z_sendmany to be used across multiple transaction
operations. Previously, it also checked a `bool` to decide what “LegacyCompat”
means, but bools are too easy to concoct, so it now expects the sender and
recipients to be checked internally. Also, z_sendmany was generating the bool
only from the sender, illustrating how easy it is to miss something when you try
to precompute.
2023-03-29 16:56:20 -06:00
Dimitris Apostolou fdae3213ac Fix typos 2023-03-29 13:40:48 -06:00
Kris Nuttycombe 4892bf327d
Merge pull request #6470 from sellout/error-on-tmemos
Improve taddr no-memo check.
2023-03-29 09:17:23 -06:00
Kris Nuttycombe 2fe569ec45
Merge pull request #6503 from sellout/wallet_tx_builder/remove-wallet
Remove CWallet member from WalletTxBuilder
2023-03-28 20:01:57 -06:00
Daira Emma Hopwood dd246587a3 Fix bit-rotted code in miner tests.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2023-03-29 00:05:51 +01:00
Greg Pfeil 7bf5f598ee
Update src/wallet/rpcwallet.cpp
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-03-28 16:30:47 -06:00
Greg Pfeil af2526d755
Improve taddr no-memo check
Do the check deeper, preventing test_bitcoin from being able to bypass it. This
also moves it out of z_sendmany-specific code, which will be helpful when we add
other operations, like sendfromaccount.
2023-03-28 16:28:16 -06:00
Greg Pfeil effbc33276
Remove CWallet member from WalletTxBuilder
This resolves a conflict where most usage is `const`, but some modifies the
wallet. Previously it held a const member and then used `pwalletMain` directly
for the mutating calls. This now passes `CWallet` explicitly where necessary,
using `const` when possible.

This also benefits a follow-up PR (#6408) that introduces locking, which also
mutates the wallet.
2023-03-28 16:24:08 -06:00
Kris Nuttycombe 33d9ff3d24
Merge pull request #6513 from nuttycom/fix_build
Fix current build errors
2023-03-28 14:26:24 -06:00
Kris Nuttycombe 58e8d8620c revert broken "safe extract" functionality in golden tests. 2023-03-28 12:27:59 -06:00
Kris Nuttycombe 3baff76c35 Merge remote-tracking branch 'daira/fix-show-help' into fix_build 2023-03-28 10:51:13 -06:00
Jack Grigg 4a94975268 Use `RandomInvalidOutputDescription()` everywhere it makes sense
As a pre-check inside `z_sendmany` we estimate the size of the
transaction that would be created, to confirm it won't exceed any
limits. We do this by creating a fake transaction with fake outputs and
measuring its size. In the case of Sapling recipients, we'd push an
empty `OutputDescription`.

In zcash/zcash#6459 we pulled in changes that improved type safety in
the Rust types. One of these changes was that the `cv` field in a
Sapling Output Description is now enforced at parsing time to be not
small order (where previously we enforced this at proof verification
time).

The two above paragraphs collide because when measuring the size of the
fake transaction, we convert a `CMutableTransaction` into a
`CTransaction`; this calls `UpdateHash` to pin its txid, and that causes
the transaction to be serialized and then parsed across the FFI. This
causes the null `OutputDescription` to reach the Rust parser which
treats it as invalid.

There are two solutions to this, which are used in various contexts:

- Avoid pushing a null `OutputDescription` into a `CMutableTransaction`.
  This is the fix implemented in this PR for `z_sendmany`: we now call
  `RandomInvalidOutputDescription()` which gives us a consensus-invalid
  but parser-valid `OutputDescription`, suitable for estimating tx size.

- Use `UNSAFE_CTransaction` to avoid having `UpdateHash` be called on
  construction. This type is used in tests where we explicitly want to
  construct an invalid type in C++, for consensus checking purposes. One
  of the `OutputDescription()` uses was in a test, but didn't trigger
  the issue because the test was checking a different part of the
  transaction being invalid. Technically no change is needed here;
  however we now also call `RandomInvalidOutputDescription()` here for
  uniformity.

Part of zcash/zcash#6509.
2023-03-27 22:33:45 +00:00
Daira Emma Hopwood 507e23eec4 Repair show_help RPC test.
This was broken by a combination of several PRs that were apparently
merged with tests not passing (at least #6425 and #6479), due to a CI
fault.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-03-27 13:09:35 +01:00
Greg Pfeil 666a8d1b37
Merge pull request #6377 from sellout/wallet_tx_builder/z_sendmany
Extract common transaction logic from z_sendmany
2023-03-22 11:24:33 -06:00
Greg Pfeil 10a1beb7c5
Have GetRecipientPools return a copy
Previously returned a const reference to a non-const object, which could then be
modified under the caller’s feet.
2023-03-21 11:07:18 -06:00
Greg Pfeil 8ebb22c67f
Simplify SelectOVKs
This inverts the structure, dispatching on the selector pattern first, then only checking
`SpendableInputs` if the selector is multi-pool. This shortens the code, eliminates some failure
cases, and caught a bug where `SaplingExtendedFullViewingKey` selectors were not
supported (previously hidden by `match { ..., [](const auto&) … }`).
2023-03-20 18:22:53 -06:00
Greg Pfeil 5236f447c7
Apply suggestions for WalletTxBuilder from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-03-20 16:20:50 -06:00
Greg Pfeil af2c7e7e49
Address WalletTxBuilder review feedback 2023-03-20 14:23:18 -06:00
Greg Pfeil 1f72b42b81
Additional z_sendmany test cases
Also improve error messages.
2023-03-20 11:24:50 -06:00
Greg Pfeil 62ae44a131
Ensure that a WalletTxBuilder tx balances
This also removes the code that stops adding spends if they ever go
`>= targetAmount`. The included note limiting and change calculation should
ensure that it’s always `==` at the end, and we don’t want paper over a mistake
in those earlier calculations.

There are existing tests that fail if either
- the newly-added Orchard increment is missing or
- the assertion is applied when there’s Sprout change.
2023-03-20 09:40:42 -06:00
str4d 598ede46c4
Merge pull request #6499 from str4d/update-deps-5.5.0
Update dependencies again for 5.5.0
2023-03-18 00:43:52 +00:00
Jack Grigg 0b77f8f79a cargo update 2023-03-17 23:22:53 +00:00
Greg Pfeil 5081a8e8fd
Address WalletTxBuilder PR feedback 2023-03-17 16:11:40 -06:00
Jack Grigg fe0b3ee89f depends: Postpone CCache updates again
We can update CCache when we drop support for Ubuntu 18.04.
2023-03-17 20:42:13 +00:00
Jack Grigg 679e77ce3f depends: CMake 3.26.0 2023-03-17 20:40:13 +00:00
Jack Grigg 69ab270480 depends: `cxx 1.0.92` 2023-03-17 20:32:01 +00:00
str4d 6ebf01fa83
Merge pull request #6459 from str4d/zcash_primitives-0.10
Migrate to `zcash_primitives 0.10`
2023-03-17 20:03:37 +00:00
str4d 0e7d61d6dc
Adjust documentation
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-03-17 17:16:33 +00:00
Daira Emma Hopwood 1da8a545d8 Adjust indentation to be consistent without changing existing code.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-03-17 16:55:51 +00:00
Greg Pfeil 77a26692bb
Don’t permit user-provided “internal” payments
The `Payment` type had an `isInternal` field, but it is (and should always be) `false`.
`ResolvedPayment` is the corresponding type internal to the transaction builder that can be either
internal (for change) or external (for user-requested payments).
2023-03-16 19:49:38 -06:00
Jack Grigg 7f35a0da5c Migrate to `zcash_primitives 0.10`
Closes zcash/zcash#6398.
2023-03-17 00:09:45 +00:00
str4d e9e160c7e2
Merge pull request #6474 from str4d/wallet-zcash_note_encryption
Migrate in-wallet Sapling output decryption to `zcash_note_encryption`
2023-03-16 23:19:27 +00:00
Greg Pfeil d90ca22be7
Clarify `AddressResolutionError`
- document and rename the enum cases,
- rewrite some of the exception messages, and
- restructure the UA recipient case.
2023-03-16 17:18:47 -06:00
Greg Pfeil 9f84ce2858
Update WalletTxBuilder based on review
Some of the more significant changes are
- remove release note entry for already-released feature;
- rephrase some error messages and comments;
- add a missing case to `EstimateTxSize`;
- don’t return a selector when we don’t have a UFVK for a UA, which allows some
  simplifications (and elimination of a failure case) to happen; and
- remove a redundant `InsufficientFundsError`.
2023-03-16 13:57:57 -06:00