Commit Graph

8190 Commits

Author SHA1 Message Date
Alex Morcos 7335afabd4
ModifyNewCoins saves database lookups
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.
2018-10-24 19:28:39 +08:00
Pieter Wuille cf47f9550e
Don't wipe the sigcache in TestBlockValidity 2018-10-24 19:28:39 +08:00
Pieter Wuille e4734f2748
Evict sigcache entries that are seen in a block 2018-10-24 19:28:39 +08:00
Pieter Wuille 3a78872137
Make sigcache faster and more efficient 2018-10-24 19:28:39 +08:00
Homu dc3398fa88 Auto merge of #3611 - bitcartel:3467_add_sapling_benchmarks, r=bitcartel
Closes #3467. Add benchmarks for Sapling spends and outputs.

Four new benchmarks are added to RPC zcbenchmark:
- createsaplingspend
- createsaplingoutput
- verifysaplingspend
- verifysaplingoutput
2018-10-23 22:52:22 -07:00
Larry Ruane 19621a7993 sapling z_sendmany default memo 0xf6 + zeros 2018-10-23 15:13:41 -06:00
Homu d2019a4ccd Auto merge of #3581 - Eirik0:3580-unspent-note-cleanup, r=daira
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.
2018-10-22 22:36:05 -07:00
Eirik Ogilvie-Wigley 095eee4f4d Wrap long line and update comments 2018-10-22 10:01:17 -06:00
Homu 32c2c17a91 Auto merge of #3579 - Eirik0:3577-generate-sprout-zkey, r=bitcartel
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.
2018-10-18 19:47:46 -07:00
Simon 67d2b79783 Closes #3467. Add benchmarks for Sapling spends and outputs.
Four new benchmarks are added to RPC zcbenchmark:
- createsaplingspend
- createsaplingoutput
- verifysaplingspend
- verifysaplingoutput
2018-10-18 19:10:59 -07:00
Homu e077fb321b Auto merge of #3541 - leto:amount_docs, r=bitcartel
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
```
2018-10-18 15:36:34 -07:00
Eirik Ogilvie-Wigley e92414f91e Remove GetUnspentFilteredNotes 2018-10-18 15:52:13 -06:00
Eirik Ogilvie-Wigley ef27d7e4b3 Add functionality from GetUnspentFilteredNotes to GetFilteredNotes 2018-10-18 15:52:13 -06:00
Eirik Ogilvie-Wigley 9396b85db8 Remove unspent note entry structs 2018-10-18 15:52:07 -06:00
Simon 0cabb007ae make-release.py: Versioning changes for 2.0.1. 2018-10-14 13:39:40 -07:00
Homu 89f5ee5dec Auto merge of #3599 - bitcartel:update_checkpoints_201, r=bitcartel
Update mainnet checkpoint for block 410100.
2018-10-13 18:19:49 -07:00
Simon 85809c75ad Update mainnet checkpoint for block 410100. 2018-10-13 08:55:38 -07:00
Simon 61caa46619 For #3359. Return error if Sapling addresses passed to RPC z_mergetoaddress.
RPC z_mergetoaddress does not support Sapling yet but the existing error
reporting was not clear to users.
2018-10-13 08:10:10 -07:00
Simon de1b86a429 For #3359. RPCs transferring funds return error if Sapling addresses are used before Sapling activation. 2018-10-12 23:14:06 -07:00
Homu 527b7feef5 Auto merge of #3592 - Eirik0:z-sendmany-better-error, r=bitcartel
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
```
2018-10-12 15:30:34 -07:00
Eirik Ogilvie-Wigley 0917c84d9a Better error message when sending to both sprout and sapling
Co-authored-by mdr0id <marshall@z.cash>
2018-10-12 14:12:21 -06:00
Simon cd10562c73 Resolves Sapling nullifier persistence issue when importing a key.
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>
2018-10-11 21:25:53 -07:00
Eirik Ogilvie-Wigley 3f824a908b Fix HDSeed comment 2018-10-10 16:00:59 -06:00
Jack Grigg 9aab383508
Update IncrementalMerkleTree test vectors to use valid commitments
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.
2018-10-10 20:55:50 +01:00
Eirik Ogilvie-Wigley 6829be1902 Remove unnecessary call to IsValidPaymentAddress 2018-10-08 16:25:29 -06:00
Eirik Ogilvie-Wigley d6ad8cef2c GenerateNewSproutZKey can return a SproutPaymentAddress 2018-10-08 14:52:58 -06:00
Eirik Ogilvie-Wigley 92fc29a3f4 Rename GenerateNewZKey to include Sprout 2018-10-08 14:23:03 -06:00
mdr0id 94360cd098 make-release.py: Versioning changes for 2.0.1-rc1. 2018-10-08 12:23:18 -07:00
Homu c2bb0ec67f Auto merge of #3517 - mdr0id:3388_persist_wallet, r=str4d
Sapling support for persisting wallet to disk

Closes #3388. Closes #3061.
2018-10-08 09:53:34 -07:00
Jack Grigg 5513faccf6
Ignore decoding errors during -zapwallettxes
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.
2018-10-06 12:18:56 +01:00
Simon cb9cff5fdc Fix deadlock from calling CWallet::AddSaplingIncomingViewingKey instead of CBasicKeyStore::AddSaplingIncomingViewingKey 2018-10-05 21:15:08 -07:00
Homu 72f6925de1 Auto merge of #3567 - bitcartel:3546_estimate_tx_size, r=bitcartel
For #3546. Improve estimated tx size for Sapling outputs.
2018-10-05 20:33:38 -07:00
Homu a513798710 Auto merge of #3566 - bitcartel:3546_prohibit_sapling_map_orphans, r=bitcartel
For #3546. Shielded tx with missing inputs are not treated as orphans.
2018-10-05 17:09:29 -07:00
Jack Grigg 3e471410f1
Persist Sapling payment address to IVK map
This ensures we remember any diversified addresses manually generated
outside the wallet.
2018-10-06 00:45:39 +01:00
mdr0id 9ce6f8425b
Add gtest coverage of Sapling wallet persistence 2018-10-06 00:01:22 +01:00
mdr0id fe92bc700a
Adding in rpc wallet sap for test_bitcoin 2018-10-06 00:01:21 +01:00
mdr0id 48a93fd2e0
Serialize Sapling data in CWalletTx
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.
2018-10-06 00:01:20 +01:00
mdr0id 2fcf06077f
Persist Sapling key material in the wallet to disk 2018-10-06 00:01:14 +01:00
Jack Grigg 1b79de781c
Store ExtFVK with encrypted Sapling spending key instead of FVK
This ensures that even when the wallet is encrypted, we can derive the default
Sapling payment address for our spending keys.
2018-10-05 23:13:32 +01:00
Homu aede10d3c2 Auto merge of #3559 - str4d:3552-testnet-min-difficulty-blocks, r=bitcartel
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.
2018-10-05 12:24:42 -07:00
Simon 4dcc48b8cb For #3546. Improve estimated tx size for Sapling outputs. 2018-10-05 11:16:20 -07:00
Simon c94f4477e8 For #3546. Shielded tx with missing inputs are not treated as orphans. 2018-10-05 10:48:03 -07:00
mdr0id 87ae893d75
Revert "wallet: Comment out HDSeed and CHDChain persistence to disk"
This reverts commit b7f9a7ae02.
2018-10-05 17:46:43 +01:00
Homu 625797a037 Auto merge of #3518 - str4d:3216-z_shieldcoinbase, r=str4d
Add Sapling support to z_shieldcoinbase

Part of #3216.
2018-10-05 03:33:16 -07:00
Jack Grigg 2b47b0de7d
Position PoW.MinDifficultyRules test after rule activates 2018-10-05 00:10:17 +01:00
Homu 967bbbc486 Auto merge of #3561 - bitcartel:3560_update_sapling_note_data, r=bitcartel
Closes #3560. Update Sapling note data correctly when importing a key.
2018-10-04 15:37:34 -07:00
Jack Grigg 4c90270469
Explicitly check the min-difficulty flag against boost::none
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.
2018-10-04 23:29:11 +01:00
Jack Grigg 1f7ee4af70
Rename min-difficulty flag to remove off-by-one in the name 2018-10-04 23:26:05 +01:00
Homu 4ba35551d4 Auto merge of #3510 - arcalinea:3378_z_listunspent, r=bitcartel
Sapling support for z_listunspent

Closes #3378.
2018-10-04 11:39:14 -07:00
Larry Ruane 27a6a99cb0 fix z_listunspent includeWatchonly logic 2018-10-04 12:26:36 -06:00
Jack Grigg b86dc98047
Only enable min-difficulty blocks on testnet from a particular height
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.
2018-10-04 14:05:27 +01:00
Homu 325ba00336 Auto merge of #3542 - Eirik0:3511-update-address-mapping, r=bitcartel
Add newly discovered sapling addresses to the wallet when decrypting

Closes #3511
2018-10-03 21:49:32 -07:00
Simon f0dcfceb81 Closes #3560. Update Sapling note data correctly when importing a key. 2018-10-03 15:40:50 -07:00
Jack Grigg 1702a86455
Allow minimum-difficulty blocks on testnet and regtest
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).
2018-10-03 17:50:17 +01:00
Jack Grigg 639e46b4d7
Revert "Remove testnet-only difficulty rules"
This reverts commit 333ea3c426.
2018-10-03 16:15:03 +01:00
Jack Grigg 5ead4b1713
Revert "Get rid of consensus.fPowAllowMinDifficultyBlocks."
This reverts commit dffc025d38.
2018-10-03 16:08:00 +01:00
Jack Grigg 5f91a95641
Add Sapling support to z_shieldcoinbase
Part of #3216.
2018-10-03 12:16:18 +01:00
Jack Grigg ba63dacbbb
Use the correct empty memo for Sapling outputs 2018-10-03 12:14:50 +01:00
Homu bcdb4344f0 Auto merge of #3548 - Eirik0:3546-sapling-coin-priority, r=bitcartel
Use max priority for all shielded transactions

Addresses https://github.com/zcash/zcash/issues/3546#issuecomment-425184034
2018-10-01 10:13:15 -07:00
Eirik Ogilvie-Wigley a4ecd0fa72 Add newly discovered sapling addresses to the wallet 2018-10-01 09:34:25 -06:00
Simon 5f57babd08 Cleanup to address review comments. 2018-09-28 22:11:05 -07:00
Simon c0f7e4059d Fix rebasing of CWallet::GetNullifiersForAddresses 2018-09-28 22:08:07 -07:00
Jay Graber 27b3cce94f Modify GetNullifiersForAddresses for Sapling 2018-09-28 15:23:21 -07:00
Jay Graber cd1c6e3767 Modify comments 2018-09-28 15:19:10 -07:00
Jay Graber 66795a408b z_listunspent sapling support - needs refactor 2018-09-28 15:19:05 -07:00
Jay Graber 06f2a8f9b6 s/jsoutindex/outindex for sapling outputs 2018-09-28 15:13:29 -07:00
Eirik Ogilvie-Wigley 51e6ed6110 Move FIXME comment to where the fix should happen 2018-09-28 12:16:05 -06:00
Eirik Ogilvie-Wigley a13492744d Use max priority for all shielded transfers 2018-09-28 10:32:30 -06:00
Larry Ruane e4f0d6a8de Sapling support for z_listreceivedbyaddress 2018-09-27 16:59:29 -06:00
Eirik Ogilvie-Wigley 83c4e360da Address need not be optional when adding sapling keys 2018-09-27 15:44:04 -06:00
Jonathan "Duke" Leto 92b42d287e Clarify in sendmany/z_sendmany rpc docs that amounts are not floating point 2018-09-23 06:18:22 -07:00
Homu e6f6c5d08c Auto merge of #3535 - bitcartel:fix_regtest_signrawtransaction, r=str4d
Do not use APPROX_RELEASE_HEIGHT to get consensus branch id in regtest mode.

Closes #3534
2018-09-22 11:35:27 -07:00
Homu fbbbb1cc82 Auto merge of #3537 - str4d:enable-sapling-features, r=bitcartel
Enable Sapling features on mainnet

Reverts the last commit from #3458.
2018-09-21 17:32:56 -07:00
Jack Grigg 34e222c18e
Revert "Disable Sapling features on mainnet"
This reverts commit 554e00e8f9.
2018-09-21 23:43:31 +01:00
Simon f1cb49ac86 For #3533. Replace asserts with JSON errors.
This helps prevent users from triggering an assert if they pass in
Sapling addresses to RPC calls: z_mergetoaddress, z_importviewingkey
and z_exportviewingkey.
2018-09-21 15:01:45 -07:00
Simon 18f8abb62d Closes #3534. Do not use APPROX_RELEASE_HEIGHT to get consensus branch
id when in regtest mode.

Co-authored-by: Larry Ruane <larryruane@gmail.com>
2018-09-21 11:10:15 -07:00
Homu 36243f41f1 Auto merge of #3520 - Eirik0:3327-sign-offline, r=bitcartel
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.
2018-09-19 15:02:52 -07:00
Homu 25c3f903c1 Auto merge of #3491 - Eirik0:3218-sapling-import-export-wallet, r=str4d
Add Sapling support to z_importwallet and z_exportwallet

Includes code adapted from upstream PR https://github.com/bitcoin/bitcoin/pull/8323

Closes #3218.
2018-09-19 12:15:48 -07:00
Homu 75c1dbc5eb Auto merge of #3452 - LarryRuane:3399-peer-ban-test, r=bitcartel
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.
2018-09-19 10:25:23 -07:00
Homu 4fc1066b6f Auto merge of #3516 - str4d:3506-sendmany-sapling-t-ovk, r=ebfull
Generate an ovk to encrypt outCiphertext for t-addr senders

Closes #3506.
2018-09-18 18:10:52 -07:00
Jack Grigg bb4b6982e3
Generate an ovk to encrypt outCiphertext for t-addr senders
Closes #3506.
2018-09-19 00:51:30 +01:00
Jack Grigg bd3c860cb4
Use ovk directly in the TransactionBuilder API instead of fvk 2018-09-18 23:26:31 +01:00
Homu e95bdeabbf Auto merge of #3521 - bitcartel:sapling_json_data, r=str4d
Add Sapling fields to JSON RPC output using TxToJSON.

Related to #3063 to add Sapling support to wallet RPCs.
2018-09-18 12:13:14 -07:00
Homu 49356ed798 Auto merge of #3512 - str4d:3487-nu-peer-management, r=ebfull
Make NU peer management logic upgrade-agnostic

Closes #3487.
2018-09-18 04:25:54 -07:00
Simon 9ba7479de1 Add Sapling fields to JSON RPC output using TxToJSON. 2018-09-17 09:44:43 -07:00
Eirik Ogilvie-Wigley 36a490677c Allow passing branchId when calling signrawtransaction 2018-09-17 10:27:39 -06:00
Eirik Ogilvie-Wigley 40b9527301 Incorporate APPROX_RELEASE_HEIGHT when determining what consensus branch to sign with 2018-09-17 10:27:39 -06:00
Eirik Ogilvie-Wigley b37dc4e22f Don't export empty zip32 metadata 2018-09-14 18:36:24 -06:00
Eirik Ogilvie-Wigley 2fe39561ec Export zip32 metadata with sapling keys 2018-09-14 17:27:20 -06:00
Eirik Ogilvie-Wigley ae807af413 Export comment on HDSeed and fingerprint with wallet 2018-09-14 17:26:02 -06:00
Jonas Schnelli 002753ae64 [Wallet] ensure CKeyMetadata.hdMasterKeyID will be cleared during SetNull()
Zcash: modified for zip32
2018-09-14 17:17:24 -06:00
Jonas Schnelli 82e71233b0 [Wallet] print hd masterkeyid in getwalletinfo
Zcash: modified for zip32
2018-09-14 16:59:56 -06:00
Jonas Schnelli b6d1af89f2 [Wallet] extend CKeyMetadata with HD keypath
Zcash: modified for zip32
2018-09-14 16:59:51 -06:00
Eirik Ogilvie-Wigley 9bcf90e2de Add sapling support to z_importwallet 2018-09-14 16:16:03 -06:00
Eirik Ogilvie-Wigley 0f03de5536 Return more information when adding a spending key 2018-09-14 16:00:47 -06:00
Eirik Ogilvie-Wigley fcab001b1e Move AddSpendingKeyToWallet 2018-09-14 15:44:03 -06:00
Eirik Ogilvie-Wigley a0783bb957 Rename AddZKey to include sprout 2018-09-14 15:07:15 -06:00
Eirik Ogilvie-Wigley 5e360fb29f Add sapling spending keys to z_exportwallet 2018-09-14 15:07:15 -06:00
Eirik Ogilvie-Wigley d6b31d59b5 Rename map to include sprout 2018-09-14 15:07:15 -06:00
Larry Ruane 6206d86237 Test peer banning logic in both pre- and post-initial block download states 2018-09-12 13:30:01 -06:00