Commit Graph

7941 Commits

Author SHA1 Message Date
Jack Grigg 3af4633b4b
Add hashFinalSaplingRoot to getblockheader and getblock output 2018-06-15 13:59:28 +12:00
Sean Bowe c03e22612d Prevent nonce reuse in Sapling note encryption API. 2018-06-14 12:21:28 -06:00
Sean Bowe 90073aeca5 Swap types in OutputDescription to use new NoteEncryption interfaces. 2018-06-14 12:08:37 -06:00
Sean Bowe 9e1c2c4049 Implementation of Sapling in-band secret distribution. 2018-06-14 11:58:45 -06:00
Jay Graber 052d640cb0 Add json test vectors for Sapling key components. 2018-06-13 10:38:32 -07:00
Homu 4f18c693c3 Auto merge of #3272 - bitcartel:3061_sapling_add_notes, r=bitcartel
Add SaplingNote class

Part of #3061, adding SaplingNote class.
2018-06-12 16:58:38 -07:00
Simon 268e5dfa50 Return optional for Sapling commitments and nullifiers.
Unlike Sprout, they are not always computable in Sapling.
2018-06-12 14:40:17 -07:00
Simon d17f8d1cc7 Refactor and replace factory method random() with constructor. 2018-06-12 14:37:15 -07:00
Simon 36e2e7cc32 Add SaplingNote class and test_sapling_note unit test. 2018-06-12 14:37:05 -07:00
Homu 524171de1f Auto merge of #3137 - str4d:2943-remove-auto-senescence-option, r=ebfull
Remove config option -disabledeprecation

Closes #2943.
2018-06-12 08:51:13 -07:00
Jack Grigg 69aa0d8f28
Use CChainParams::Bech32HRP() in zs_address_test 2018-06-12 18:38:36 +12:00
Jack Grigg f59093935c
Add examples of ConvertBits transformation 2018-06-12 16:51:59 +12:00
Jack Grigg dd7417c8d0
Add comment about size calculations for converted serialized keys 2018-06-12 15:47:56 +12:00
Jack Grigg c74ab3356a Remove config option -disabledeprecation
Closes #2943.
2018-06-11 10:38:12 -07:00
Ariel Gabizon e1a3461cc2 Improve/Fix variable names
ZCProof was too general. pubKeyHash was actually the JoinSplit pubkey
itself.
2018-06-09 20:27:35 -07:00
Homu de1bc2d389 Auto merge of #3321 - bitcartel:remove_librustcash_xor, r=str4d
Remove now redundant Rust call to librustzcash_xor.

Related to https://github.com/zcash/librustzcash/pull/17 which removes librustzcash_xor from library.
2018-06-07 20:37:07 -07:00
Simon 10a7d55a03 Remove now redundant Rust call to librustzcash_xor. 2018-06-06 23:24:21 -07:00
Jack Grigg 2802e321c1
Fix cached_witnesses_empty_chain test failure on MacOS
Assertion error format is different, so match only on the assertion.
2018-06-07 17:49:05 +12:00
Jack Grigg bec3e62bc1
Implement encoding and decoding of Sapling keys and addresses 2018-06-07 17:28:50 +12:00
Jack Grigg c8511dfc07
Fix bech32::Encode() error handling
Previously, an input with invalid characters would result in out-of-bounds
reads, potentially exposing up to 224 bytes of memory following the location of
the CHARSET constant. This commit fixes the function to return an empty string,
which is what was originally documented as happening.
2018-06-07 17:19:44 +12:00
Pieter Wuille 6a2cc8ddc0
Simplify Base32 and Base64 conversions 2018-06-07 17:19:43 +12:00
Pieter Wuille ac70f76c5d
Generalize ConvertBits 2018-06-07 17:19:34 +12:00
Jack Grigg 6b759fb092
ConvertBits() - convert from one power-of-2 number base to another.
Function extracted from upstream:
  PR bitcoin/bitcoin#11167
  Commit c091b99379b97cb314c9fa123beabdbc324cf7a4
2018-06-07 16:42:01 +12:00
Jack Grigg 7e45636707
chainparams: Add Sapling Bech32 HRPs 2018-06-07 16:41:59 +12:00
Homu 80338c07e5 Auto merge of #3237 - str4d:std-array, r=str4d
Replace boost::array with std::array
2018-06-06 19:36:57 -07:00
Jack Grigg 4fb3d05ce9
Whitespace cleanup 2018-06-07 14:35:56 +12:00
Homu ffba08b0e0 Auto merge of #3318 - Eirik0:3298-fix-getnetworksolps-params, r=bitcartel
Fix parsing parameters in getnetworksolps

This fixes https://github.com/zcash/zcash/issues/3298. The parameters were not correctly being converted.
2018-06-06 10:00:21 -07:00
Homu d18212b1d6 Auto merge of #3299 - Eirik0:3248-update-getblocktemplate, r=str4d
Add hashFinalSaplingRoot to getblocktemplate

Closes #3248
2018-06-06 05:00:58 -07:00
Matthew King d28d3d20de
Use portable #! in python scripts (/usr/bin/env) 2018-06-05 21:56:13 +12:00
Eirik Ogilvie-Wigley c61ed9acfb Fix parsing parameters in getnetworksolps 2018-06-04 16:45:12 -06:00
Jay Graber 87c9994cb2 Make diversifier functions return option 2018-06-04 07:47:46 -07:00
Jay Graber 0da9aac63e s/SaplingInViewingKey/SaplingIncomingViewingKey 2018-06-04 04:59:07 -07:00
Eirik Ogilvie-Wigley 25c13ef702 Add hashFinalSaplingRoot to getblocktemplate 2018-06-01 15:47:30 -06:00
Jay Graber dd099401a3 Fix default_address() 2018-06-01 04:03:27 -07:00
Jay Graber 521a6f1fc0 Minimal sapling key test 2018-06-01 02:32:17 -07:00
Jay Graber 52d81ff794 Update librustzcash dependency, address comments 2018-06-01 01:48:28 -07:00
Jay Graber 84e3a2212f Change librustzcash dependency hash to work for new Sapling classes 2018-06-01 00:04:13 -07:00
Jay Graber 11acfe6e9f Add Sapling key classes to wallet, with new librustzcash APIs 2018-06-01 00:04:13 -07:00
Homu 73fea25404 Auto merge of #3300 - bitcartel:3277_add_comment_deprecated_txdb_prefixes, r=str4d
Part of #3277. Add comment about deprecated txdb prefixes.
2018-05-25 18:42:05 -07:00
Jack Grigg a6bbb26e08
Replace boost::array with std::array 2018-05-26 00:12:57 +12:00
Simon c290f8f263 Update release height to block 332000. 2018-05-24 23:09:02 -07:00
Jack Grigg d670db7164
Sapling testnet activation height 2018-05-25 16:05:25 +12:00
Jack Grigg 40c33db2f4
make-release.py: Versioning changes for 1.1.1. 2018-05-25 15:38:43 +12:00
Simon 47db75426f Closes #3301. Non-void function should not have empty definition. 2018-05-23 21:04:51 -07:00
Simon f9840089db Part of #3277. Add comment about deprecated txdb prefixes. 2018-05-23 20:37:34 -07:00
Simon d3ff27c0a6 make-release.py: Versioning changes for 1.1.1-rc2. 2018-05-23 09:27:59 -07:00
Jack Grigg 8bf890abac make-release.py: Versioning changes for 1.1.1-rc1. 2018-05-19 09:50:15 +12:00
Sean Bowe 3577de83aa Change txdb prefixes for sapling and avoid writing unnecessary information. 2018-05-18 13:26:39 -06:00
Sean Bowe 8f5429a13a Update merkle tree and pedersen hash tests to account for new encoding 2018-05-18 13:26:39 -06:00
Homu f62fff80d5 Auto merge of #3255 - str4d:sapling-value-pool, r=ebfull
Track net value entering and exiting the Sapling circuit
2018-05-16 10:46:32 -07:00
Eirik Ogilvie-Wigley 3182b4abc3 Add tests for sapling anchors 2018-05-16 10:31:53 -06:00
Alex Morcos bbff8631f5
Output line to debug.log when IsInitialBlockDownload latches to false 2018-05-15 22:18:11 +12:00
Gregory Maxwell f04a90afb2
IsInitialBlockDownload no longer uses header-only timestamps.
This avoids a corner case (mostly visible on testnet) where bogus
 headers can keep nodes in IsInitialBlockDownload.
2018-05-15 22:18:04 +12:00
Gregory Maxwell e41632c9fb
IBD check uses minimumchain work instead of checkpoints.
This introduces a 'minimum chain work' chainparam which is intended
 to be the known amount of work in the chain for the network at the
 time of software release.  If you don't have this much work, you're
 not yet caught up.

This is used instead of the count of blocks test from checkpoints.

This criteria is trivial to keep updated as there is no element of
subjectivity, trust, or position dependence to it. It is also a more
reliable metric of sync status than a block count.
2018-05-15 21:25:19 +12:00
Kaz Wesley 02eedeeb69
IsInitialBlockDownload: usually avoid locking
Optimistically test the latch bool before taking the lock.
For all IsInitialBlockDownload calls after the first to return false,
this avoids the need to lock cs_main.
2018-05-15 21:25:19 +12:00
Wladimir J. van der Laan 29aaf13b0a
Make max tip age an option instead of chainparam
After discussion in #7164 I think this is better.

Max tip age was introduced in #5987 to make it possible to run
testnet-in-a-box. But associating this behavior with the testnet chain
is wrong conceptually, as it is not needed in normal usage.
Should aim to make testnet test the software as-is.

Replace it with a (debug) option `-maxtipage`, which can be
specified only in the specific case.
2018-05-15 21:24:58 +12:00
Jack Grigg f55029e7d1 Correctly serialize Groth16 JSDescription for verifyjoinsplit benchmark 2018-05-14 16:29:02 -06:00
Sean Bowe 34f6ea95dc Adjust tests and benchmarks 2018-05-14 16:29:02 -06:00
Sean Bowe b7a6c32178 Integrate Groth16 verification and proving. 2018-05-14 16:26:23 -06:00
Jack Grigg e5eab182b5
Use boost::variant to represent shielded addresses and keys
libzcash::PaymentAddress has been renamed to libzcash::SproutPaymentAddress,
and a new typedef boost::variant is now libzcash::PaymentAddress. Similarly
for ViewingKey and SpendingKey.

A new class InvalidEncoding is introduced as the default boost::variant
option for each address and key type; it is used during decoding instead
of boost::optional.

All address and key storage functions in the wallet have been modified to
refer specifically to the Sprout types, as they are used very precisely.
In most other cases, the more general type is leveraged as much as possible,
and we convert to the Sprout type when necessary. This will be subsequently
wrapped in, or replaced with, context-specific functions once Sapling
types are implemented.
2018-05-11 17:14:49 -04:00
Homu 1942f7a42b Auto merge of #3242 - str4d:3058-key-encoding-refactor, r=str4d
Key encoding refactor

Includes code cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#11372
  - Only the first three commits (the fourth commit depends on #2390)

Part of #3058.
2018-05-11 12:21:29 -07:00
Jonathan "Duke" Leto 30bf78ca23 Clarify help that signmessage only works on taddrs 2018-05-10 17:25:13 -07:00
Homu ae6c2587d3 Auto merge of #3232 - ebfull:3207-sapling-validation, r=str4d
Sapling validation

**Also review https://github.com/zcash/librustzcash/pull/7**

This is an attempt to tackle much of https://github.com/zcash/zcash/issues/3065
2018-05-10 10:21:15 -07:00
Homu 73f5cb1213 Auto merge of #3257 - bitcartel:3250_fix_segfault_memo, r=ebfull
Closes #3250. Memo getter should return by reference, not by value.
2018-05-10 08:47:06 -07:00
Homu 677b5b3b8b Auto merge of #3247 - str4d:3207-valuebalance, r=str4d
Add valueBalance to value balances

Part of #3065 and #3207.
2018-05-10 07:12:00 -07:00
Jack Grigg 0fe0ca7948
Add contextual comment for GetValueOut() and GetShieldedValueIn() 2018-05-10 09:34:19 -04:00
Simon 67f3577239 Closes #3250. Memo getter should return by reference, not by value. 2018-05-09 21:52:33 -07:00
Homu 08f74ed026 Auto merge of #3240 - str4d:remove-obsolete-binaries, r=str4d
Remove obsolete CreateJoinSplit and GenerateParams binaries
2018-05-09 13:50:25 -07:00
Jack Grigg ae97177c86
Track net value entering and exiting the Sapling circuit 2018-05-09 16:02:23 -04:00
Jack Grigg 97b46f00cc
Add valueBalance to value balances, and enforce its consensus rules 2018-05-09 11:34:41 +01:00
Homu f0daf3915f Auto merge of #3233 - str4d:3164-sapling-sighash, r=str4d
ZIP 243: Sapling SignatureHash

Closes #3164.
2018-05-08 16:59:33 -07:00
Jack Grigg 93bd00a0d5
Add key_io includes to Zcash-specific code 2018-05-08 21:39:56 +01:00
Pieter Wuille 3d31e09cbb
Split key_io (address/key encodings) off from base58 2018-05-08 21:39:56 +01:00
Pieter Wuille 3e60c9fabd
Stop using CBase58Data for ext keys 2018-05-08 21:39:55 +01:00
Jack Grigg aa333ee8f2
Implement {Encode,Decode}PaymentAddress etc. without CZCEncoding 2018-05-08 21:39:55 +01:00
Jack Grigg 8bf3a3d700
Introduce wrappers around CZCViewingKey 2018-05-08 21:39:55 +01:00
Jack Grigg 472f75bc2d
Introduce wrappers around CZCSpendingKey 2018-05-08 21:39:55 +01:00
Jack Grigg 80ed13d545
Introduce wrappers around CZCPaymentAddress
This patch removes the need for the intermediary Base58 type
CZCPaymentAddress, by providing {Encode,Decode}PaymentAddress
functions that directly operate on the conversion between strings
and libzcash::PaymentAddress.
2018-05-08 21:39:55 +01:00
Pieter Wuille f146029b0a
Replace CBitcoinSecret with {Encode,Decode}Secret 2018-05-08 21:39:54 +01:00
Sean Bowe b4db32f53c Check Sapling Spend/Output proofs and signatures. 2018-05-08 14:30:26 -06:00
Sean Bowe 55fabd8272 Refactor so that dataToBeSigned can be used later in the function for other purposes. 2018-05-08 14:28:01 -06:00
Sean Bowe 6eea48bf96 Remove unnecessary IsCoinbase() check. Coinbases are guaranteed to have empty vjoinsplit. 2018-05-08 14:23:09 -06:00
Homu b1d2a69908 Auto merge of #3202 - str4d:3058-sapling-bech32, r=str4d
Bech32 encoding support

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#8578
- bitcoin/bitcoin#11167
  - Only the second and third commits (first is in #3228, fourth depends on #2390, later ones are SegWit-specific).
- bitcoin/bitcoin#12757
  - Only the change to `src/bech32.h`

Part of #3058.
2018-05-08 09:08:37 -07:00
Homu 0c1adf8281 Auto merge of #3201 - Eirik0:3190-dumpprivkey-help-text, r=str4d
Clarify help text of dumpprivkey

Closes #3190
2018-05-08 06:02:17 -07:00
Jack Grigg 50284985e9
Update sighash tests 2018-05-08 11:45:41 +01:00
Jack Grigg b391b70736
Implement Sapling signature hash (ZIP 243) 2018-05-08 11:45:38 +01:00
Homu 0a98b97524 Auto merge of #3236 - str4d:3192-jsoutpoint-constructor, r=str4d
Change JSOutPoint constructor to have js argument be uint64_t

Closes #3192.
2018-05-08 02:50:04 -07:00
Homu 333b9a0d0b Auto merge of #3170 - ebfull:sapling-merkle-tree, r=ebfull
Sapling merkle tree implementation

Closes #3056.

Please also review https://github.com/zcash/librustzcash/pull/8

This PR:

1. Introduces ZCSaplingIncrementalMerkleTree using Pedersen hashes.
2. Adds support for Sapling anchors into consensus rules. (Adds commitments, checks anchors are correct, handles block (dis)connects, etc.)
3. Handles mempool eviction for obsolete anchors.
4. Enforces correctness of block's Sapling root field
5. Changes miner to correctly apply the Sapling root to the block header
6. Handles mempool consistency checks for anchors
2018-05-07 20:37:46 -07:00
Sean Bowe 40bfb9e5b9 Swap bit endianness of test vectors 2018-05-07 18:57:04 -06:00
Jack Grigg e935beb810
wallet: Make some arguments const that can be 2018-05-07 22:13:26 +01:00
Jack Grigg b87e271a9a
wallet: Change IsLockedNote to take a JSOutPoint
This removes the uint64_t -> size_t -> uint64_t round trip, as well as the
JSOutPoint -> parts -> JSOutPoint round trip.
2018-05-07 21:56:57 +01:00
Sean Bowe f6f97dfb1c Fix miner tests 2018-05-07 14:37:46 -06:00
Sean Bowe 8c57bbac15 Fix broken error messages. 2018-05-07 14:37:46 -06:00
Sean Bowe e390a475c1 Fix outdated comment 2018-05-07 14:37:46 -06:00
Sean Bowe 98d2f090ca Evict transactions with obsolete anchors from the mempool 2018-05-07 14:37:46 -06:00
Sean Bowe 673a0a79b3 Adjust tests to handle Sapling anchor cache 2018-05-07 14:37:46 -06:00
Sean Bowe 31a04d2875 Calculate the correct hashFinalSaplingRoot in the miner. 2018-05-07 14:37:46 -06:00
Sean Bowe b4ff707605 Add support for Sapling anchor checks in mempool consistency checks. 2018-05-07 14:37:46 -06:00
Sean Bowe 1f8be05b63 Add consensus support for Sapling merkle trees. 2018-05-07 14:37:46 -06:00
Sean Bowe 85b39f57bb Add `PushSaplingAnchor` 2018-05-07 14:37:46 -06:00
Sean Bowe c643ff0b51 Add support for PopAnchor(.., SPROUT/SAPLING) 2018-05-07 14:37:46 -06:00
Sean Bowe 27616b9a04 Add support for Sapling anchors in coins/txdb. 2018-05-07 14:37:46 -06:00
Sean Bowe e814be60fe Rename hashSproutAnchorEnd to hashFinalSproutRoot to be consistent. 2018-05-07 14:37:46 -06:00
Sean Bowe f2c6d214e5 Rename hashSaplingAnchorEnd to hashFinalSaplingRoot to match spec. 2018-05-07 14:37:46 -06:00
Sean Bowe 7b62078782 Remove underscores from gtest test names. 2018-05-07 14:37:46 -06:00
Sean Bowe 7703a673ea Generalize the PushAnchor implementation behavior. 2018-05-07 14:37:43 -06:00
Sean Bowe 9ea4e387b2 Generalize the PopAnchor implementation behavior. 2018-05-07 13:46:06 -06:00
Sean Bowe 18322f074c Introduce support for GetBestAnchor(SAPLING). 2018-05-07 13:46:06 -06:00
Sean Bowe 2bd59e1473 Rename PushAnchor to PushSproutAnchor. 2018-05-07 13:46:06 -06:00
Sean Bowe 008f4ee8e7 Rename GetAnchorAt to GetSproutAnchorAt. 2018-05-07 13:46:06 -06:00
Sean Bowe 8b8d70cad9 Rename DB_ANCHOR to DB_SPROUT_ANCHOR. 2018-05-07 13:46:06 -06:00
Sean Bowe 30325eebf5 Add primitive implementation of GetSaplingAnchorEnd. 2018-05-07 13:46:06 -06:00
Sean Bowe 691a3fa2e9 Rename hashReserved to hashSaplingAnchorEnd. 2018-05-07 13:46:06 -06:00
Sean Bowe 08f0728884 Rename hashAnchor to hashSproutAnchor. 2018-05-07 13:46:06 -06:00
Sean Bowe d455828fdc Specifically describe anchors as Sprout anchors. 2018-05-07 13:46:06 -06:00
Sean Bowe 28d20bdb11 Rename NullifierType to ShieldedType. 2018-05-07 13:46:06 -06:00
Sean Bowe 2f23a656fb Add regression tests and test vectors for Sapling merkle tree 2018-05-07 13:46:06 -06:00
Sean Bowe 2b002a7e60 Add implementation of Sapling merkle tree 2018-05-07 13:46:06 -06:00
Sean Bowe a7cbb8475f Abstract `uncommitted` and depth personalization for IncrementalMerkleTree. 2018-05-07 13:46:06 -06:00
Homu 1d4235dce7 Auto merge of #3239 - str4d:sapling-default-tx-version, r=str4d
Update CreateNewContextualCMutableTransaction for Sapling

Part of #3063.
2018-05-07 12:27:47 -07:00
Jack Grigg e1d41f21f3
Update tests for CreateNewContextualCMutableTransaction changes 2018-05-07 20:21:55 +01:00
Jack Grigg ef1678bf0f
Add some more checkpoints, up to the 1.1.0 release 2018-05-07 15:15:41 +01:00
Homu 265eca3f47 Auto merge of #3212 - str4d:2864-sapling-tx-size-limit, r=str4d
Raise 100kB transaction size limit from Sapling activation

Closes #2864.
2018-05-07 02:20:42 -07:00
Homu 8ef1d333b5 Auto merge of #2894 - per-gron:dont-export-unless-needed, r=str4d
Make some globals static that can be

I wrote this patch as part of making a Bazel build system but it really is independent from that so I'm putting this as a separate PR.

External linkage does not help and just encourages sloppy dependencies (ie using symbols only declared in a cpp file in some other cpp file) and can lead to weird issues when there are name collisions.
2018-05-04 15:05:43 -07:00
Jack Grigg e1dbec49b7
Add test of Sapling transaction size boundary 2018-05-04 11:17:30 +01:00
Jack Grigg 892ae945f7
Rework z_sendmany z-address recipient limit
From Sapling, the z-address recipients could require either JSDescriptions or
OutputDescriptions. Instead of trying to give an exact number in the help text,
rely on transaction size estimation to guide user behaviour.
2018-05-04 11:17:30 +01:00
Jack Grigg 25fee3509a
Rename MAX_TX_SIZE to MAX_TX_SIZE_AFTER_SAPLING 2018-05-04 11:17:30 +01:00
Jack Grigg ddcee7e13a
Benchmark the largest valid Sapling transaction in validatelargetx
11130 inputs results in a transaction between 1992301 and 2003431 bytes.
2018-05-04 11:17:30 +01:00
Jack Grigg 15ec5525e3
Raise 100kB transaction size limit from Sapling activation
Closes #2864.
2018-05-04 11:17:30 +01:00
Jack Grigg 768cd14cf9
Add missing include guard
Extracted from bitcoin/bitcoin#12757
- Commit 8fd6af89a0c061d79bb3fd2ba704b61dcc2e9211
2018-05-04 10:37:14 +01:00
Pieter Wuille 488d43dd8f
Convert base58_tests from type/payload to scriptPubKey comparison 2018-05-04 10:27:11 +01:00
Pieter Wuille 10e5357e8b
Import Bech32 C++ reference code & tests
This includes a reformatted version of the Bech32 reference code
(see https://github.com/sipa/bech32/tree/master/ref/c%2B%2B), with
extra documentation.
2018-05-04 10:27:11 +01:00
MarcoFalke 57be66d30e
[test] Remove unused code
Zcash: left createArgs() as we still have rpc_wallet_tests which uses it.
2018-05-04 10:27:11 +01:00
Homu d97bfb766b Auto merge of #3228 - str4d:3058-taddr-encoding-refactor, r=str4d
Refactor t-address encoding

Includes code cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#11117
- bitcoin/bitcoin#11259
  - Only the second commit (first is for QT code)
- bitcoin/bitcoin#11167
  - Only the first commit (the rest are not part of the t-address encoding refactor).

Part of #3058. Precursor to #3202.
2018-05-03 18:12:22 -07:00
Homu 2d1a3cf8f5 Auto merge of #3183 - bitcartel:least_authority_issue_d, r=str4d
Closes #3182 - Least Authority Issue D

Prevent undefined behaviour when null pointer is passed in as parameter to function

Includes a backport of bitcoin/bitcoin#10250.
2018-05-03 16:39:10 -07:00
Homu c7f5d5ce1c Auto merge of #3227 - str4d:3191-nullifier-macos-fix, r=str4d
Fix -Wstring-plus-int warning on clang
2018-05-03 14:36:39 -07:00
Jack Grigg 11aa594440
Remove obsolete CreateJoinSplit and GenerateParams binaries 2018-05-03 13:18:03 +01:00
Jack Grigg fa70084c87
Expire Overwinter transactions before the Sapling activation height 2018-05-03 12:27:56 +01:00
Jack Grigg dc889d7f52
Update CreateNewContextualCMutableTransaction to create Sapling transactions 2018-05-03 12:02:51 +01:00
Jack Grigg daed9ba7cc
Change JSOutPoint constructor to have js argument be uint64_t
Closes #3192.
2018-05-03 10:47:22 +01:00
Pieter Wuille c8f9c87bf1
Implement {Encode,Decode}Destination without CBitcoinAddress 2018-05-03 01:13:04 +01:00
João Barbosa 6939c994ef
Remove unused GetKeyID and IsScript methods from CBitcoinAddress 2018-05-03 01:13:04 +01:00
Pieter Wuille 56c43a36bf
Move CBitcoinAddress to base58.cpp 2018-05-03 01:13:04 +01:00
Jack Grigg b6be3e88bb
Use CBitcoinAddress wrappers in Zcash-specific code 2018-05-03 01:13:04 +01:00
Pieter Wuille 07444da1db
Introduce wrappers around CBitcoinAddress
This patch removes the need for the intermediary Base58 type
CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination
function that directly operate on the conversion between strings
and CTxDestination.
2018-05-03 01:12:57 +01:00
Homu 9e5398686c Auto merge of #3206 - bitcartel:3194_polymorphic_note_class, r=str4d
Update note classes to be polymorphic

Closes #3194.  Lays foundation for introduction of Sapling notes through refactoring and creation of a class hierarchy for Sprout notes.  This PR updates some tests, but otherwise is a no-op.
2018-05-02 08:07:35 -07:00
Homu 53fa6f1315 Auto merge of #3179 - bitcartel:backport_transaction_details_in_getblock_v2bitcartel, r=str4d
Add improvements to getblock RPC output

Includes and supercedes #3095. Includes code cherry-picked from bitcoin/bitcoin#8704.
2018-05-01 10:19:10 -07:00
Homu 0a8d0c25e8 Auto merge of #3220 - Eirik0:3209-fix-CheckTransaction, r=str4d
Implement consensus rules about the number of Spend and Output Descriptions in a transaction

Closes #3209.
Part of #3065.
2018-05-01 07:09:52 -07:00
Jack Grigg 1f9dfbb9f0
Fix -Wstring-plus-int warning on clang 2018-05-01 14:55:47 +01:00
Homu 90304c4214 Auto merge of #3213 - str4d:3202-precursor, r=str4d
Upstream encoding cleanups

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7922
- bitcoin/bitcoin#7825
- bitcoin/bitcoin#8317
- bitcoin/bitcoin#9804
  - Only the commit that changed `base58.cpp`

Precursor to #3202.
2018-05-01 05:22:38 -07:00
Homu 23f8b30c88 Auto merge of #3193 - str4d:b9856-badalloc-terminate, r=bitcartel
Terminate immediately when allocation fails

Backport of bitcoin/bitcoin#9856

Closes #1498.
2018-05-01 02:09:51 -07:00
Simon 54a872f0fa Fix undefined behaviour, calling memcpy with NULL pointer.
Identified as part of audit: Least Authority, Issue D.
2018-04-30 16:41:02 -07:00
Simon 9bd8f092c6 Closes #3178 by adding verbosity level improvements to getblock RPC.
This is a follow-up commit for d0a1d833520d120bb5a2ac4cf4192047af6afe24
found in PR #3095 in order to fix nits and add a test.
2018-04-30 11:51:59 -07:00
Simon bf911b3038 Tweaks to d0a1d83 to complete backport of Bitcoin PR #8704 2018-04-30 09:55:30 -07:00
Peter Pratscher eb78a45a0c Backported Bitcoin PR #8704 to optionally return full tx details in the getblock rpc call 2018-04-30 09:55:30 -07:00
Marshall Gaucher b300118002
Merge pull request #2813 from str4d/2074-uacomment
Implement uacomment config parameter
2018-04-30 09:12:38 -06:00
Simon debf6af9f8 Move memo member varible from SproutNotePlaintext to BaseNotePlaintext.
Add memo() accessor to BaseNotePlaintext.
2018-04-26 15:05:30 -07:00
Simon d266f40393 Create class hierarchy for SproutNotePlaintext.
BaseNotePlaintext contains member variable for common attribute, value.
2018-04-26 15:05:30 -07:00
Simon 5020a93631 Refactoring: rename NotePlaintext --> SproutNotePlaintext
Also renames:
CNotePlaintextEntry --> CSproutNotePlaintextEntry
CUnspentNotePlaintextEntry --> CUnspentSproutNotePlaintextEntry
2018-04-26 15:05:30 -07:00
Simon 9354f8e568 Remove unused SproutNote variables. 2018-04-26 15:05:30 -07:00
Simon 5f4fa1a954 Add virtual destructor to SproutNote and BaseNote
Also add test to make sure default copy constructors are okay.
2018-04-26 15:05:30 -07:00
Simon 5d99e3e92f Refactoring: SproutNote member variable value moved to BaseNote.
All notes have a value, so the member variable has been moved to the
base class, and direct member access has been replaced with a getter.
2018-04-26 15:05:19 -07:00
Eirik Ogilvie-Wigley 812098256f Coinbase transactions can not have shielded spend or output 2018-04-26 15:53:26 -06:00
Eirik Ogilvie-Wigley 4b4662b06d Make sure transactions have non-empty outputs 2018-04-26 15:24:59 -06:00
Homu a2ff78620a Auto merge of #3191 - Eirik0:3057-sapling-nullifier-set, r=str4d
Add sapling nullifier set

PR for https://github.com/zcash/zcash/issues/3057
2018-04-26 05:28:39 -07:00
Jack Grigg aeb089ecc7
Attempt to log before terminating if prevector allocation fails 2018-04-26 11:30:33 +01:00
Jack Grigg 3c9dbf3ed8
Improve best-effort logging before termination on OOM
Suggested by @kallewoof in bitcoin/bitcoin#9856
2018-04-26 11:22:07 +01:00
Sean Bowe 6679855147
Check that duplicate Sapling nullifiers don't exist within a transaction. 2018-04-25 17:10:34 -06:00
Homu c6ab62191a Auto merge of #3205 - str4d:3173-missing-return, r=str4d
Return result of boost::apply_visitor

Not returning a value at the end of a non-void function is undefined behaviour.
Given that this managed to pass our full test suite, I guess that GCC looks for
un-returned values at the end of a function and uses them as the return value,
if the keyword is missing. Clang OTOH complains, which is how we spotted this:
https://ci.z.cash/#/builders/16/builds/282
2018-04-25 13:50:53 -07:00
Simon b230fe6836 Refactoring: Rename class libzcash::Note to libzcash::SproutNote. 2018-04-25 11:33:24 -07:00
Simon bef33bbc73 Refactoring: libzcash::Note is now a subclass of libzcash::BaseNote. 2018-04-25 11:33:16 -07:00
Eirik Ogilvie-Wigley 9669920f75 Rename nullifier caches and maps to indicate sprout nullifiers 2018-04-25 11:26:38 -06:00
Eirik Ogilvie-Wigley cab341e1a8 Add sapling nullifiers to db and mempool 2018-04-24 17:16:43 -06:00
Jack Grigg bf605b2644
Return result of boost::apply_visitor
Not returning a value at the end of a non-void function is undefined behaviour.
Given that this managed to pass our full test suite, I guess that GCC looks for
un-returned values at the end of a function and uses them as the return value,
if the keyword is missing. Clang OTOH complains, which is how we spotted this:
https://ci.z.cash/#/builders/16/builds/282
2018-04-24 23:04:09 +01:00
Homu f961e5c3c0 Auto merge of #3195 - str4d:3180-clang-warnings, r=str4d
Remove now-unshadowed serialization lines that do nothing

Previously we had both nVersion as a class parameter *and* a serialization
argument, and in several inherited serializers the latter was set to the former,
in order to pass the serialized object's version into underlying parsers. #3180
pulled in the upstream changes to clean this up, and in doing so these lines
became no-ops - setting the class parameter to itself. Clang throws warnings on
this, which turn into errors on the MacOS builder.

We can just remove these, because upstream already had done so in earlier PRs,
indicating that they were not being relied on by underlying parsers.
2018-04-24 14:03:57 -07:00
Eirik Ogilvie-Wigley 708c87f16d Add enum for nullifier type 2018-04-24 09:57:14 -06:00
Eirik Ogilvie-Wigley 685e936c31 Add sapling nullifier set 2018-04-24 09:57:14 -06:00
Eirik Ogilvie-Wigley df960a9ba7 Clarify help text of dumpprivkey 2018-04-23 15:14:56 -06:00
Jeremy Rubin 1b34996b21
Fix subscript[0] in base58.cpp 2018-04-23 22:12:53 +01:00
MarcoFalke b37b4b2fa3
[rpcwallet] Don't use floating point 2018-04-23 22:12:53 +01:00
Pedro Branco 181c511cd0
Prevent multiple calls to ExtractDestination 2018-04-23 22:12:53 +01:00
Kaz Wesley 63822fbc84
CBase58Data::SetString: cleanse the full vector
SetString seems to be passing the length of the wrong variable to
memory_cleanse, resulting in the last byte of the temporary buffer not being
securely erased.
2018-04-23 22:12:45 +01:00
Jack Grigg b1608eed82
Add a constant for Overwinter's transaction version 2018-04-23 20:39:04 +01:00
Jack Grigg b4f7174a88
Implement SpendDescription and OutputDescription datastructures
Co-authored-by: George Tankersley <george@z.cash>
2018-04-23 20:39:00 +01:00
Homu 0e65c245f7 Auto merge of #3181 - bitcartel:least_authority_issue_c, r=daira
Closes #1249 - Least Authority Issue C

Backports the first commit from https://github.com/bitcoin/bitcoin/pull/9512 to avoid unaligned access in crypto i/o.
2018-04-21 05:19:05 -07:00
Homu 77889933e7 Auto merge of #3173 - str4d:2907-sapling-v4-tx-shell, r=str4d
Initial support for Sapling v4 transactions

Part of #2907.
2018-04-20 12:35:47 -07:00
Jack Grigg 22ffe8ce44
Remove now-unshadowed serialization lines that do nothing
Previously we had both nVersion as a class parameter *and* a serialization
argument, and in several inherited serializers the latter was set to the former,
in order to pass the serialized object's version into underlying parsers. #3180
pulled in the upstream changes to clean this up, and in doing so these lines
became no-ops - setting the class parameter to itself. Clang throws warnings on
this, which turn into errors on the MacOS builder.

We can just remove these, because upstream already had done so in earlier PRs,
indicating that they were not being relied on by underlying parsers.
2018-04-20 09:48:33 +01:00
Homu 5821bb0a4d Auto merge of #3185 - ebfull:sapling-testnet-params, r=str4d
Load Sapling testnet parameters into memory

This PR depends on https://github.com/zcash/librustzcash/pull/4.

The parameters are not loaded into memory if `zcashd` is configured as a mainnet node -- this is something we can change in the weeks before `2.0.0`.
2018-04-20 01:28:13 -07:00
Jack Grigg 2d922b66b0
Pass transaction header into correct SignatureHash serialization level
We need to indicate whether PHGR or Groth proofs are expected to vjoinsplit,
which is serialized in an inner hash, not the outer hash.
2018-04-19 20:35:33 +01:00
Cory Fields d207b81d28
prevector: assert successful allocation 2018-04-19 16:49:12 +01:00
Cory Fields c10b69eb64
don't throw std::bad_alloc when out of memory. Instead, terminate immediately 2018-04-19 16:49:02 +01:00
Jack Grigg 72540cee4a
Add Sapling v4 transactions to IsStandard 2018-04-19 16:25:04 +01:00
Pieter Wuille 1878f3a759 Fix some empty vector references
streams.h has some methods that can be tricked into dereferencing
null pointers or end() iterators. Fix this.
2018-04-18 21:31:14 -07:00
Jack Grigg b7e75b17af
Implement basic Sapling v4 transaction parser
Details of Sapling datatypes will be filled in later; for now, they are treated
as binary blobs.

Includes code cherry-picked from upstream commit:
    7030d9eb47254499bba14f1c00abc6bf493efd91
    BIP144: Serialization, hashes, relay (sender side)
2018-04-19 05:01:47 +01:00
Jack Grigg 987b8ee60e
Adjust consensus rules to require v4 transactions from Sapling activation 2018-04-19 05:01:47 +01:00
Homu 0753a0e8a9 Auto merge of #3180 - str4d:transaction-serialization, r=ebfull
Upstream serialization improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#5264
- bitcoin/bitcoin#6914
- bitcoin/bitcoin#6215
- bitcoin/bitcoin#8068
  - Only the `COMPACTSIZE` wrapper commit
- bitcoin/bitcoin#8658
- bitcoin/bitcoin#8708
  - Only the serializer variadics commit
- bitcoin/bitcoin#9039
- bitcoin/bitcoin#9125
  - Only the first two commits (the last two block on other upstream PRs)

Part of #2074.
2018-04-18 19:08:34 -07:00
Cory Fields da96e3b71a
build: univalue subdir build fixups
- Force a rebuild if the headers change
- Only build the lib target
- Clean univalue on 'make clean'
2018-04-18 00:36:49 +01:00
Sean Bowe acfcdb94b9 Load Sapling testnet parameters into memory. 2018-04-17 15:04:46 -06:00
Pieter Wuille 0b6594f444 Avoid unaligned access in crypto i/o 2018-04-17 09:15:55 -07:00
Pieter Wuille c7d71985c9
Add deserializing constructors to CTransaction and CMutableTransaction 2018-04-17 13:29:51 +01:00