When processing a new transaction, in addition to spending the Coins of its txin's it creates a new Coins for its outputs. The existing ModifyCoins function will first make sure this Coins does not already exist. It can not exist due to BIP 30, but because of that the lookup can't be cached and always has to go to the database. Since we are creating the coins to match the new tx anyway, there is no point in checking if they exist first anyway.
Zcash: Modified to account for the fact that BIP 30 and BIP 34 have applied
from the beginning.
Closes#3467. Add benchmarks for Sapling spends and outputs.
Four new benchmarks are added to RPC zcbenchmark:
- createsaplingspend
- createsaplingoutput
- verifysaplingspend
- verifysaplingoutput
Remove GetUnspentFilteredNotes
Closes#3580
This PR generalized `GetFilteredNotes`, expanding its functionality to also do what we do in `GetUnspentFilteredNotes`. This enables us to remove the latter.
Make it clear that CWallet::GenerateNewZKey is Sprout specific
Closes https://github.com/zcash/zcash/issues/3577
When adding sapling support we had considered making the method `GenerateNewZKey` generic, but it ended up making more sense to add a second method `GenerateNewSaplingZKey` for sapling support.
This PR changes the name of `GenerateNewZKey` to `GenerateNewSproutZKey` and changes the return type from `libzcash::PaymentAddress` to `libzcash::SproutPaymentAddress` to make it more clear that this is what the method does.
Clarify in sendmany/z_sendmany rpc docs that amounts are not FP
Fixes#3539
I clarified in the docs that only 8 digits of precision are allowed. For example, if you try 9 digits you will get:
```
zcash-cli z_sendmany $TADDR "[{\"address\":\"$ZADDR\",\"amount\":0.123456789}]"
error code: -3
error message:
Invalid amount
```
Better error message when sending to both sprout and sapling
When trying to send to both Sprout and Sapling (not currently supported with z_sendmany) we were getting the following error in our operation result: `general exception: boost::bad_get: failed value get using boost::get`.
This PR changes this to fail with a better error message before the async operation begins:
```
error code: -8
error message:
Cannot send to both Sprout and Sapling addresses using z_sendmany
```
During a rescan, a CWalletTx was persisted to disk before it had its
note data set. This meant that upon restart, the CWalletTx would
potentially be missing its nullifiers causing the wallet's balance
to include notes which had already been spent.
The resolution is to ensure that after a rescan, a CWalletTx is
persisted after it has had its nullifiers set correctly.
Co-authored-by: Eirik Ogilvie-Wigley <eirik@z.cash>
The original commitments were SHA256 outputs, and some were outside the
scalar field. This didn't affect the Merkle hash, which drops the high
bit from each commitment, but it does affect the creation of the Merkle
path in Rust, which requires path nodes to be valid scalars.
Here, we explicitly drop the high bit of all test vector commitments,
as well as reducing the two that remain outside the field. The test
vectors still pass, and can now also be used in the Rust implementation.
The undecoded wallet transaction is logged before proceeding, so later
recovery of metadata might be possible. But the fact that the user is
using -zapwallettxes is a clear indicator that they want
transactions removed from their wallet, so this is the priority.
If 2.0.0 nodes upgrade to 2.0.1 after Sapling has activated, the v4 Sapling
transactions in their wallet will be treated as corrupt, and a rescan will be
triggered which will overwrite the old-format transactions with the new
Sapling-aware format.
Allow minimum-difficulty blocks on testnet
This is a consensus rule change on testnet that will result in a chain split (leaving the stuck chain, as desired).
Reverts #2766 and part of #1338.
Closes#3552.
It isn't clear how a boost::optional that holds 0 (which is the case for
regtest) is coerced to a boolean, unless you pore over the Boost
documentation. An explicit check is clearer.
The min-difficulty change is a bilateral consensus rule change, and so
must be conditionally enabled in order for the earlier section of the
chain to synchronise.
Technically this could be implemented as a network upgrade, but as this will
never be deployed to mainnet, a targeted fork will suffice.
A block may be mined with nBits set to the minimum difficulty if its
nTime is set more than six block intervals (15 minutes) after its parent
block.
This is a consensus rule change on testnet that will result in a chain
split (as desired).
This helps prevent users from triggering an assert if they pass in
Sapling addresses to RPC calls: z_mergetoaddress, z_importviewingkey
and z_exportviewingkey.
Fix signing raw transactions with unsynced offline nodes
This PR address the issue in two different ways:
- In `signrawtransaction` we determine the consensus branch ID (which we then later use to construct the transaction) using the chain height. We now also consider the `APPROX_RELEASE_HEIGHT` as this is a better estimation than 0 for the height of the chain if we are unsynced. (This in and of itself solves the Overwinter signing issue).
- We have added an additional parameter to `signrawtransaction` to allow manually overriding the consensus branch ID that zcashd determines we are on. This allows users to work around corner cases where the first strategy is still insufficient.
Closes#3327.
Test peer banning logic in both pre- and post-initial block download states
The DoS ban scores are different for each, and it's nice to test both.
Follow-on from #3410.