Commit Graph

9111 Commits

Author SHA1 Message Date
Kris Nuttycombe 9119ca8f86 Rename KeyInfo -> KeyConstants and move out of Consensus namespace. 2020-07-09 18:19:13 -06:00
Kris Nuttycombe 07ff0d19a0 Make evident the relationship between chainparams and key IO. 2020-07-09 17:48:47 -06:00
Daira Hopwood 8121e874e2 Change getblocksubsidy RPC to take into account funding streams.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-07-09 23:33:14 +01:00
Daira Hopwood 6bd85925e7 Tests for changes to getblocksubsidy.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-07-09 23:33:14 +01:00
Daira Hopwood 50c1d5cee6 Add GetActiveFundingStreams function.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2020-07-09 18:32:39 +01:00
Kris Nuttycombe e456d87cbf Merge remote-tracking branch 'upstream/master' into zip-207 2020-07-09 08:23:57 -06:00
Homu 701adc38cb Auto merge of #4578 - therealyingtong:zip212-impl, r=str4d
ZIP212 implementation

Closes #4557.
(description by @ebfull, taken from #4575)

* The `SaplingNote` structure has a new enum called `zip212Enabled`. This
  member is private and reflects whether the note was or is being created
  using the derivation method of ZIP 212 (i.e., `BeforeZip212` or `AfterZip212`).
* The `SaplingNotePlaintext` structure has a new unsigned char member
  `leadbyte`. This member is private and contains the leading byte of the
  plaintext (e.g. `0x01`, `0x02`).
* The serialization of `SaplingNotePlaintext` sets `zip212Enabled` to
  `BeforeZip212` iff the serialized note plaintext version is not `0x01`.
* The `r`/`rcm` fields have been removed and replaced with a private field
  `rseed`. `SaplingNote` and `SaplingNotePlaintext` now have a helper method
  `rcm()` which returns the `rcm` either by deriving it with `rseed`
  (if `zip212Enabled` is `AfterZip212`) or returning `rseed` by interpreting
  `rseed` as `rcm`.
* All the methods of obtaining a `SaplingNote` account for these changes:
  - The `SaplingNote` constructor that is used by e.g. the transaction builder,
    and internally samples random `rcm`, now takes a `zip212Enabled` argument
    to decide whether to sample `rcm` the "old" way or the "new" way.
  - The bare constructor for `SaplingNote` is removed.
  - The other constructor which takes the raw contents of the note is only used
    in tests or in `Note.cpp`, but now also takes a `zip212Enabled` argument.
  - The other way of obtaining a note, by calling `SaplingNotePlaintext::note()`,
    has been adjusted.
* The `SaplingNotePlaintext` class now has an `generate_or_derive_esk()` method
  that either samples a random `esk` or derives it using the local `rseed`
  depending on the value of `leadbyte`.
* The encryption routine is modified to consult `generate_or_derive_esk()` and
  provide it to the note encryption object.
* The note encryption objects now take an optional `esk` as input and otherwise
  sample a random `esk` internally. This API functionality is preserved to allow
  for testing.
* The `SaplingNotePlaintext` decryption routines are modified:
  - The out and enc decryption routines now check that `epk` is consistent with
    the derived `esk`.
  -  The out decryption routine for plaintexts also checks that `esk` is
    consistent with what is derived by the note.
* The miner and transaction builder consult the activation of Canopy when
  creating `SaplingNote`s.
* The consensus rules are modified so that shielded outputs (miner rewards)
  must have `v2` note plaintexts after Canopy has activated.
2020-07-09 00:29:07 +00:00
Kris Nuttycombe ca3f5df607 Remove assertion that was breaking regtest in the case that blossom activates after the halving. 2020-07-08 17:02:28 -06:00
Kris Nuttycombe 436dee90de Merge remote-tracking branch 'upstream/master' into zip-207 2020-07-08 15:04:32 -06:00
Kris Nuttycombe 06789f99d3 Fix ordering of transparent outputs such that miner reward is vout[0] 2020-07-08 11:04:47 -06:00
therealyingtong dde5cc87b7 Directly call RegtestActivate* in gtests
Co-authored by Jack Grigg (jack@electriccoin.co)
2020-07-08 12:53:03 +08:00
therealyingtong 1020254b6a Pass nHeight instead of pindex to AddToWalletIfInvolvingMe()
Co-authored by Jack Grigg (jack@electriccoin.co) and Sean Bowe (ewillbefull@gmail.com)
2020-07-08 12:53:03 +08:00
therealyingtong 119bae082c Remove old SaplingNote() constructor 2020-07-08 12:53:03 +08:00
therealyingtong 31020d6fc9 Minor changes
Co-authored by Daira Hopwood (daira@jacaranda.org) and Jack Grigg (jack@electriccoin.co)
2020-07-08 12:53:01 +08:00
Kris Nuttycombe 502896e130 Fix incorrect subtraction of Halving(blossomActivationHeight) from halvingIndex 2020-07-07 16:32:18 -06:00
Homu 1192116598 Auto merge of #4581 - ebfull:zip215-impl-2, r=str4d
ZIP 215 Implementation

This is accompanied by 8c97acde89.
2020-07-07 21:39:49 +00:00
Kris Nuttycombe ea987f5577 Use uint32_t for vFundingStreams indexing. 2020-07-07 09:53:18 -06:00
Kris Nuttycombe 37b4faab6a
Pass by const reference where possible.
Co-authored-by: Larry Ruane <larry@z.cash>
2020-07-07 09:41:32 -06:00
Kris Nuttycombe 88c5bf7217
Minor help message correction.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-07-06 15:41:28 -06:00
Kris Nuttycombe f9b10b866e Trivial comment correction. 2020-07-06 13:15:27 -06:00
Kris Nuttycombe 90fc879492 Move test-only code into test sources. 2020-07-06 13:09:49 -06:00
Kris Nuttycombe 0141aacc67 Add `RegtestDeactivateCanopy` calls to restore shared regtest params. 2020-07-06 12:47:12 -06:00
Kris Nuttycombe 8b363e9a70 Fix funding stream end-height-exclusion bugs 2020-07-06 10:52:41 -06:00
Sean Bowe 249de0808d
Remove outdated comment. 2020-07-03 10:24:35 -06:00
Sean Bowe a9d80b0750
Hash "Zcash" to align tests with ZIP 215 test vectors. 2020-07-03 10:20:37 -06:00
Sean Bowe c3b3e07160
Change LIBSODIUM_ERROR to -1.
We only relied on success being 0 and our code was otherwise agnostic to the
actual return code in the event of failed signature verification, but this
change keeps the API consistent.
2020-07-03 09:37:34 -06:00
Sean Bowe 394947de3a
Migrate ZIP 215 test vectors to gtest suite. 2020-07-03 09:36:34 -06:00
therealyingtong c4821ddceb Refactor bool is_zip_212 to enum Zip212Enabled
Co-authored by Kris Nuttycombe (@nuttycom)
2020-07-03 06:59:21 +08:00
therealyingtong eeda663ff7 Remove plaintext check from GetFilteredNotes
Co-authored by Sean Bowe (ewillbefull@gmail.com)
2020-07-03 06:59:06 +08:00
therealyingtong ee83424c6f Remove plaintext check from AddSaplingSpend
Co-authored by Sean Bowe (ewillbefull@gmail.com)
2020-07-03 06:57:57 +08:00
Homu 602e88ddb9 Auto merge of #4489 - therealyingtong:4479-remove-sprout-shielding, r=str4d
[ZIP 211] Disabling Addition of New Value to the Sprout Value Pool

Disables Sprout outputs after NU4 by checking for nonzero `vpub_old` in transactions after NU4 activation height.

Adds gtests to check expected behaviour before and after NU4 activation height.

edit:
Also modifies `z_` methods in `rpcwallet`, and adds a matching RPC test.

Implements [ZIP 211](https://zips.z.cash/zip-0211), closes #4479
2020-07-02 21:53:51 +00:00
Kris Nuttycombe 834911c0d7 Update HalvingHeight documentation. 2020-07-02 14:30:06 -06:00
Kris Nuttycombe 49ea02925e Merge branch 'zip-207' of github.com:str4d/zcash into zip-207 2020-07-02 13:33:09 -06:00
Kris Nuttycombe d9088ab050
Record-constructor syntax for funding stream initialization.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-07-02 13:32:23 -06:00
Kris Nuttycombe 4d223f9797 Merge remote-tracking branch 'upstream/master' into zip-207 2020-07-02 13:24:45 -06:00
Kris Nuttycombe 5f20ef3c9d Minor naming change FundingStreamShare -> FundingStreamElement 2020-07-02 12:15:26 -06:00
Kris Nuttycombe b17f263c20
Capitalization fixes from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-07-02 09:58:12 -06:00
therealyingtong 19d4c47b66 Pass pindex to AddToWalletIfInvolvingMe() 2020-07-02 15:37:37 +08:00
therealyingtong 2f4d7e35c9 Throw error in plaintext deserialization 2020-07-02 15:37:37 +08:00
therealyingtong f24e706079 Replace leadByte in SaplingNote with is_zip_212 2020-07-02 15:37:32 +08:00
Kris Nuttycombe aff38f75f3
Qualified imports of std:: types
Co-authored-by: str4d <thestr4d@gmail.com>
2020-07-01 16:06:27 -06:00
Kris Nuttycombe bf381ad580
Replace BOOST_FOREACH with for..:
Co-authored-by: str4d <thestr4d@gmail.com>
2020-07-01 16:05:30 -06:00
therealyingtong 1c59f06df0 Add checks to z_ methods in rpcwallet
Disallow Sprout shielding after Canopy in z_sendmany, z_shieldcoinbase, z_mergetoaddress, and zc_raw_joinsplit (deprecated)
2020-07-01 23:47:36 +08:00
therealyingtong 2a2fc2a16f Add gtests
Should accept Sprout shielding before NU4 but reject it afterwards
2020-07-01 23:31:41 +08:00
therealyingtong 01cdea54ee Add contextual check to main.cpp
Reject transactions with nonzero vpub_old after NU4
2020-07-01 23:31:36 +08:00
Rod Vagg a106c15a19
Add joinSplitPubKey and joinSplitSig to RPC
These two properties are required to fully reconstruct a Zcash
transaction's binary form from the RPC data.

Co-authored-by: str4d <thestr4d@gmail.com>
2020-06-30 21:47:51 +10:00
Kris Nuttycombe 92cec200ee Minor fixes for ZIP-207 review comments. 2020-06-29 16:13:08 -06:00
Kris Nuttycombe 074d054e84
Trivial error message fix.
Co-authored-by: str4d <thestr4d@gmail.com>
2020-06-29 15:54:07 -06:00
Kris Nuttycombe 665b8c647b
Use for..: rather than BOOST_FOREACH
Co-authored-by: str4d <thestr4d@gmail.com>
2020-06-29 15:53:41 -06:00
Kris Nuttycombe 1c00a0b541
Identify `-fundingstream` parameter as being regtest-only
Co-authored-by: str4d <thestr4d@gmail.com>
2020-06-29 15:42:45 -06:00