Commit Graph

10616 Commits

Author SHA1 Message Date
Kris Nuttycombe 44eb07a2bb Guard against invalid coercion of int to u32 in FindSpendableInputs 2022-03-28 19:46:21 -06:00
Kris Nuttycombe e07e355e01 Fix overzealous matching of Orchard FVKs to addresses.
It is possible for an address to be generated for a UFVK that
contains an Orchard FVK, but where the address does not contain
an Orchard receiver. Cache restoration was failing on startup
because we failed to allow for this case.
2022-03-28 19:46:21 -06:00
Kris Nuttycombe 66756d1a13 Improve error logging in walletdb.cpp 2022-03-28 19:46:21 -06:00
Jack Grigg 1e9bdcd0a2 test: Fix `WalletTests.GetConflictedOrchardNotes` gtest
The test was creating a fake shielding transaction, but by using a
single null `COutPoint` it was accidentally trying to create a coinbase
transaction, which was then rejected by the consistency checks on the
Rust side (which require that no inputs be provided for a coinbase
transaction, which by definition has no real inputs).
2022-03-29 00:26:22 +00:00
Jack Grigg ba7d3c41bf rust: Improve `PrecomputedTransactionData` construction errors
We now log separate errors for "provided inputs when signing a coinbase
transaction" and "provided the wrong number of inputs to a transaction".
2022-03-29 00:26:22 +00:00
Jack Grigg 7892888379 test: Improve gtest handling of `TransactionBuilderResult::GetTxOrThrow`
We can't directly use `EXPECT_NO_THROW` on a function that returns a
result; instead we manually call `GTEST_FAIL` if the builder result is
an error.
2022-03-29 00:26:22 +00:00
Jack Grigg 52e039ebd8 builder: Handle `std::ios_base::failure` exceptions during sighash
These can occur if e.g. `PrecomputedTransactionData` encounters an error
during parsing of its inputs on the Rust side.
2022-03-29 00:26:22 +00:00
Jack Grigg 8b68d73802 test: Print all logged errors to stdout during gtests
This makes it easier to figure out test failures caused by errors on the
Rust side, for which we generally log the error and then return a simple
failure condition (`false` or `nullptr`) which obscures the error on the
C++ side.

We add similar logic to the Boost test framework, but commented out by
default because it results in very verbose test output.
2022-03-29 00:26:22 +00:00
Kris Nuttycombe 0daa540128 Merge remote-tracking branch 'upstream/master' into nu5-consensus 2022-03-28 10:13:51 -06:00
Kris Nuttycombe 021a8d1b4b Improve error message for when a UA is only usable after a future NU.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-03-27 09:26:36 -06:00
Steven Smith e375f4ace2 Remove the fExperimentalOrchardWallet flag and related logic 2022-03-25 21:46:09 -07:00
Kris Nuttycombe c73f4b3fda
Merge branch 'master' into typos 2022-03-25 22:05:26 -06:00
Kris Nuttycombe 79b0490661
Merge pull request #5732 from therealyingtong/test-conflicted-orchard-notes
Fix handling of Orchard notes in `CWallet::GetConflicts`.
2022-03-25 22:02:55 -06:00
Kris Nuttycombe 46190bca23
Merge pull request #5751 from nuttycom/feature/fix_rpc_docs
Add undocumented attributes to getinfo API help text.
2022-03-25 22:01:15 -06:00
Kris Nuttycombe 74f770426b
Apply suggestions from code review 2022-03-25 18:37:31 -06:00
str4d 696a49b30d
Merge pull request #5745 from str4d/orchard-shielded-coinbase-tests
Test Orchard shielded coinbase rules
2022-03-25 23:04:39 +00:00
sasha d10c0553f3
Merge pull request #5750 from nuttycom/defensive/scanwallet_nullptr_check
Assert that pindexStart cannot be null in CWallet::ScanForWalletTransactions
2022-03-25 16:02:05 -07:00
sasha d250b8cd88 Disallow testnet peers with a protocol version older than 170040 2022-03-25 15:02:32 -07:00
Kris Nuttycombe ecc1e5da0c Add missing filter to ensure only fully-transparent transactions end up in mapOrphans. 2022-03-25 15:10:44 -06:00
Kris Nuttycombe dc4afca405 Correctly return p2pkh/p2sh labels for z_listunifiedreceivers 2022-03-25 10:44:18 -06:00
Kris Nuttycombe 8630891c5a Improve consistency of RPC parameter and result attribute naming.
Make consistent use of "pool", "address type" and "receiver type",
in RPC documentaion, and deprecate bare uses of "type" in RPC APIs.

Fixes #5534

Co-authored-by: str4d <thestr4d@gmail.com>
2022-03-25 10:44:18 -06:00
Kris Nuttycombe 1d73567f42 Add undocumented components to getinfo API. 2022-03-25 09:25:46 -06:00
Kris Nuttycombe 881e0f2ca8 Rename unifiedaddress->address in z_getaddressforaccount results
Fixes #5432
2022-03-25 08:29:56 -06:00
Kris Nuttycombe b9b5d47523 Assert that pindexStart cannot be null in CWallet::ScanForWalletTransactions 2022-03-25 08:23:51 -06:00
Marshall Gaucher 4a9bd59fef
Merge pull request #5743 from daira/no-banlist-on-reindex
Start with an empty banlist if -reindex is set
2022-03-25 06:37:11 -07:00
ying tong 2ef41824ff
orchard_wallet_get_potential_spends: Do not use uint256 type.
We don't want to depend on the C++ uint256 type in the C FFI.

Co-authored-by: str4d <thestr4d@gmail.com>
2022-03-25 12:07:46 +08:00
therealyingtong 637592ebd5 Introduce OrchardWallet::GetPotentialSpendsFromNullifier method. 2022-03-25 10:41:05 +08:00
therealyingtong 7b51afd840 Fix GetConflictedOrchardNotes test. 2022-03-25 10:38:30 +08:00
Jack Grigg def5a0be38 Test Orchard shielded coinbase rules
Also fixes a bug in `z_sendmany` transaction size estimation (we were
using the wrong size of a `CompactSize`).
2022-03-25 02:12:42 +00:00
Daira Hopwood 50d4be17cf Start with an empty banlist if -reindex is set. fixes #5739
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-25 01:07:44 +00:00
Kris Nuttycombe dd578cb290 Restore legacy default Sapling addresses to the keystore.
Prior to zcash/zcash@90e59c3be0 Sapling
default payment addresses were added to the in-memory keystore whenever
a full viewing key was added, or loaded from disk. After that change,
the Sapling address was no longer being restored to the in-memory
keystore on wallet load; instead, z_getnewaddress and
z_getnewaddressforaccount both persist the address to the keystore
directly. This commit adds handling to `LoadCaches` to correctly persist
the default address to the wallet database, and add it to the in-memory
keystore, when this condition is detected.
2022-03-24 17:02:43 -06:00
Daira Hopwood d17c981013
Merge pull request #5738 from daira/wallet-backup-warning
zcashd-wallet-tool: warn that wallet.dat still needs to be backed up, and add man page
2022-03-24 20:29:25 +00:00
Jack Grigg 639e97ed4a Merge branch 'master' into nu5-consensus 2022-03-24 18:09:17 +00:00
Daira Hopwood 6b836ce7e5 zcashd-wallet-tool: warn that wallet.dat needs to be backed up. fixes #5704
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-24 14:24:43 +00:00
therealyingtong bd6a34b0ea test_wallet: Test GetConflictedOrchardNotes. 2022-03-24 18:52:30 +08:00
sasha cc05712e7f Prevent a pindex == NULL case in the ScanForWalletTransactions traversal 2022-03-23 12:15:45 -07:00
Jack Grigg e5210d50c9 Set NU5 protocol version for regtest to 170040, bump protocol version
We need to bump the `zcashd` protocol version because the new rules are
not compatible with existing rules followed by 170015 nodes, but we
_also_ need to ensure we can still bump it again once we set the testnet
reactivation height (changing node network behaviour again). This commit
also enables RPC tests to run (because previously the nodes considered
each other to be too old for NU5 to be active, and were disconnecting).
2022-03-23 18:37:56 +00:00
Jack Grigg d9c1b05a83 builder: Use correct `PrecomputedTransactionData` for transparent sigs
Before merging 4.7.0-rc1 into the nu5-consensus branch, we were in a
split state:

- 4.7.0-rc1 included Orchard support in the transaction builder, which
  required special handling of Orchard bundles when computing sighashes.
  The `PrecomputedTransactionData` structure could be shared, because
  its digests were only relevant to transparent signatures (as shielded
  signatures signed the txid directly even in shielding transactions).

- nu5-consensus included the changes to ZIP 244, which required passing
  around a `PrecomputedTransactionData` that contained the set of all
  transparent inputs being spent, because shielding transactions now also
  need to commit to transparent inputs.

In the merge commit, we incorrectly handled the resolution: we correctly
derived a fresh `PrecomputedTransactionData` when signing the Orchard
bundle, but we reused the `PrecomputedTransactionData` that was
previously derived before checking whether or not we even had an Orchard
bundle, for transparent inputs. This meant that its commitments didn't
commit to the Orchard bundle, and so transparent signatures on
transactions with Orchard bundles would fail to verify.

Incidentally, this is the exact inverse of a bug we encounted while
implementing the ZIP 244 changes on the nu5-consensus branch: we were
correctly computing the transparent sighash, but we were relying on the
initial `TxDigests` derived within `PrecomputedTransactionData` for the
Orchard sighash, even though we were actively rewriting the transaction
to include the Orchard bundle. The fix there was similarly to re-compute
the `TxDigests` before computing the sighash.
2022-03-23 18:27:12 +00:00
Jack Grigg 85b5595519 Fix logical merge conflicts after merging 4.7.0-rc1
The merge commit includes changes to address direct merge conflicts.
This commit makes the remaining changes necessary to integrate the
Orchard wallet changes with the NU5 consensus changes.
2022-03-23 03:19:39 +00:00
Jack Grigg 9e9f58b26f Merge branch 'master' into unify-nu5-consensus-changes 2022-03-23 02:57:16 +00:00
Jack Grigg 77a971fbc1 Migrate to latest `zcash/librustzcash` revision
This includes:
- `orchard =0.1.0-beta.3` which includes the final circuit changes.
- The new NU5 consensus branch ID.
- Updated ZIP 244 test vectors (which use the NU5 consensus branch ID).
2022-03-23 02:05:06 +00:00
sasha 5cfaea5dd4 Add missing gtest/test_transaction_builder.h to Makefile.gtest.include
Like 562f5add87, the missing header ref
means that the make dist step of gitian builds don't include it in the
tarball, causing an error upon build.
2022-03-22 17:38:32 -07:00
sasha c85fae833e Add missing wallet/orchard.h to src/Makefile.am
Like 562f5add87, the missing header ref
means that the make dist step of gitian builds don't include it in the
tarball, causing an error upon build.
2022-03-22 17:03:16 -07:00
Jack Grigg 96edba2e41 make-release.py: Versioning changes for 4.7.0-rc1. 2022-03-22 21:04:37 +00:00
Dimitris Apostolou 234867d270
Fix typos 2022-03-22 23:01:25 +02:00
Charlie O'Keefe 7b7ac148ac
Merge pull request #5681 from LarryRuane/2022-02-listaddresses
Update the listaddresses RPC endpoint to correctly report unified addresses
2022-03-22 12:55:41 -06:00
Jack Grigg c21890af8d wallet: Fix expected `listaddresses` sources in `rpc_wallet_tests` 2022-03-22 17:18:30 +00:00
Jack Grigg d4e47e4720 wallet: Fix Sapling address bug in `listaddresses`
`CWallet::FindUnifiedAddressByReceiver` is a wrapper around the visitor
`UnifiedAddressForReceiver`, which looks up the Unified Address (if any)
corresponding to the given receiver. However, this only returns external
UAs, and returns `std::nullopt` both if the receiver does not correspond
to a UFVK, and if it does but is derived from an internal FVK. By using
this method as a filter, `listaddresses` was not filtering out internal
Sapling receivers, and thus was leaking Sapling change addresses for
accounts (which we do not want revealed in the UI anywhere).

Instead, we now check for UFVK metadata directly, which verifies that
the Sapling receiver is derived from a UFVK without any extra filtering.
2022-03-22 14:55:40 +00:00
Jack Grigg 24089109b2 wallet: Fix bugs in `listaddresses`
- Legacy transparent addresses derived from the mnemonic seed are no
  longer duplicated in the `legacy_random` source.
- Legacy transparent change addresses derived from the mnemonic seed are
  now shown under that source.
- Sapling addresses that aren't part of a UA are now identified
  correctly when derived from the mnemonic seed, rather than being
  assumed to be derived from the legacy HD seed.
2022-03-22 14:55:40 +00:00
Larry Ruane e575e0f217 update listaddresses RPC for UAs, Orchard
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-03-22 14:55:17 +00:00