Commit Graph

1029 Commits

Author SHA1 Message Date
Kris Nuttycombe 822ab78edc Revert "Make `-reindex` and `-reindex-chainstate` imply `-rescan`"
This reverts commit af7d883854.
2022-05-26 12:45:22 -06:00
Kris Nuttycombe 9691d86047 Add a CLI flag to preferentially send V4 tx.
Since the wallet ecosystem may not be fully updated to handle
v5 transaction parsing at the point of NU5 activation, some
nodes may prefer to construct V4 transactions when not including
Orchard transaction components.

This change adds a CLI flag that allows node users to specify
that preference.
2022-05-26 07:26:38 -06:00
str4d 09b02bedc9
Merge pull request #5057 from str4d/sync-backports
Sync backports
2022-05-14 04:36:37 +01:00
Russell Yanofsky fcd0b28616 scripted-diff: Small locking rename
Call sync.h primitives "locks" and "mutexes" instead of "blocks" and "waitable
critical sections" to match current coding conventions and c++11 standard
names.

This PR does not rename the "CCriticalSection" class (though this could be done
as a followup) because it is used everywhere and would swamp the other changes
in this PR. Plain mutexes should mostly be preferred instead of recursive
mutexes in new code anyway.

-BEGIN VERIFY SCRIPT-
set -x
set -e
ren() { git grep -l $1 | xargs sed -i s/$1/$2/; }
ren CCriticalBlock           UniqueLock
ren CWaitableCriticalSection Mutex
ren CConditionVariable       std::condition_variable
ren cs_GenesisWait           g_genesis_wait_mutex
ren condvar_GenesisWait      g_genesis_wait_cv
perl -0777 -pi -e 's/.*typedef.*condition_variable.*\n\n?//g' src/sync.h
-END VERIFY SCRIPT-

(cherry picked from commit bitcoin/bitcoin@190bf62be1)
2022-05-14 01:25:08 +00:00
Russell Yanofsky f17e43d61e Use LOCK macros for non-recursive locks
Instead of std::unique_lock.

Zcash: Excluding locks in code we haven't backported yet.

(cherry picked from commit bitcoin/bitcoin@9c4dc597dd)
2022-05-14 01:25:08 +00:00
Matt Corallo 327807e05a Fix fast-shutdown hang on ThreadImport+GenesisWait
If the user somehow manages to get into ShutdownRequested before
ThreadImport gets to ActivateBestChain() we may hang waiting on
condvar_GenesisWait forever. A simple wait_for and
ShutdownRequested resolves this case.

(cherry picked from commit bitcoin/bitcoin@1c9394ad47)
2022-05-14 01:25:08 +00:00
Matt Corallo 8164dc35d7 Fix -Wthread-safety-analysis warnings. Change the sync.h primitives to std from boost.
Commit 1.

This code was written by @TheBlueMatt in the following branch:
* https://github.com/TheBlueMatt/bitcoin/commits/2017-08-test-10923

This commit message was written by me (@practicalswift) who also squashed
@TheBlueMatt's commits into one and tried to summarize the changes made.

Commit 2.

Remove boost include. Remove boost mentions in comments.

(cherry picked from commit bitcoin/bitcoin@7e319d6393)
2022-05-14 01:25:08 +00:00
Pieter Wuille 8489f27afa Do diskspace check before import thread is started
(cherry picked from commit bitcoin/bitcoin@9d4eb9ad99)
2022-05-14 01:25:08 +00:00
Pieter Wuille 084906c845 Use a signal to continue init after genesis activation
Zcash: We set the Sprout tree root on the genesis block's index file in
InitBlockIndex because we were implicitly relying on this occurring via
ActivateBestChain previously.

(cherry picked from commit bitcoin/bitcoin@0fd2a33648)
2022-05-14 01:25:08 +00:00
Jack Grigg 1f1810c37d Name currently-unnamed threads that we can rename
After this, the only threads that aren't named are the LevelDB
background threads.
2022-05-14 00:07:34 +00:00
Jack Grigg 6aa7c187d1 Shorten thread name prefix
Threads can be a maximum of 15 characters, so using `zc-` instead of
`zcash-` as a prefix means we can fit more information into the thread
names.
2022-05-13 21:18:20 +00:00
Kris Nuttycombe 28040f9ce4 scripted-diff: Add 2016-2022 copyright headers for files added/modified in 2016
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM bitcoin-v0.11.2..94f427a211bb337200c29a1e19be0f5ad2f171b0 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2016-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:23:09 -06:00
Kris Nuttycombe 75055882d4 Add missing parenthesis to -reindex help. 2022-05-09 10:13:39 -06:00
Charlie O'Keefe 92d2a87053
Merge pull request #5905 from nuttycom/feature/disable_legacy_privacy_strategy
Allow deprecated wallet features to be preemptively disabled.
2022-05-04 16:05:45 -06:00
Kris Nuttycombe d80935a8fd Use ERROR level logging for fatal errors in main/init
Fixes #5922
2022-05-03 16:12:19 -06:00
Larry Ruane ed988b55a3 ThreadStartWalletNotifier: wait until !IBD, rather than !reindex
The -reindex option causes the node to first read the block files,
adding each block to the block index, then reset the reindexing flag,
then build the best chain (the "UpdateTip: new best" logging messages).
Before the wallet notification thread begins to actually do
notifications, it should wait until we're no longer in initial block
download, rather than waiting until the reindexing flag is reset (which
is too early).
2022-05-02 13:26:06 -06:00
Kris Nuttycombe d6d3be9bf2 Allow deprecated wallet features to be preemptively disabled.
This adds an `-allowdeprecated` CLI parameter whose value is a flag
indicating a deprecated feature that should be explicitly enabled.
Multiple instances of this argument may be provided. In the case that
this parameter is not provided, all currently deprecated RPC methods
that are not slated for removal in the next release remain available.
A user may disable all deprecated features entirely by providing the
string "none" as the argument to this parameter, or enable all
deprecated features, including those slated for removal, by providing
the string "all" as the argument to this parameter. In the case that
"all" or "none" is specified, multiple invocations of `-allowdeprecated`
are not permitted.

To explicitly enable only a specific set of deprecated features, use
`-allowdeprecated=<flag1> -allowdeprecated=<flagN> ...` when starting
zcashd. The following flags are recognized:

- "all" - enables all deprecated features.
- "none" - disables all deprecated features.
- "legacy_privacy" - enables the use of the deprecated "legacy" privacy
  policy for z_sendmany. This causes the default behavior to conform to
  the `FullPrivacy` directive in all cases instead of just for
  transactions involving unified addresses.
- "getnewaddress" - enables the `getnewaddress` RPC method.
- "z_getnewaddress" - enables the `z_getnewaddress` RPC method.
- "zcrawreceive" - enables the `zcrawreceive` RPC method.
- "zcrawjoinsplit" - enables the `zcrawjoinsplit` RPC method.
- "zcrawkeygen" - enables the `zcrawkeygen` RPC method.
- "addrtype" - when this option is set, the deprecated `type` attribute
  is returned in addition to `pool` or `address_type` (which contain the
  same information) in the results of RPC methods that return address metadata.
2022-04-28 15:20:05 -06:00
Daira Hopwood af7d883854 Make `-reindex` and `-reindex-chainstate` imply `-rescan`
(provided that the wallet is enabled and pruning is disabled,
and unless `-rescan=0` is specified explicitly).

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-04-14 14:53:29 +01:00
Kris Nuttycombe 72fc17ffc7 Don't advance the wallet init timer until past reindex. 2022-04-12 09:39:45 -06:00
Kris Nuttycombe 21de7f1108 Fix uninitialized sleep variable. 2022-04-11 12:39:52 -06:00
Kris Nuttycombe 7ede9af587 Fix missing null initialization of `pindexLastTip` pointer in ThreadStartWalletNotifier 2022-04-11 11:36:15 -06:00
Kris Nuttycombe c342e7d712
Merge pull request #5847 from nuttycom/bug/wallet_bestchain_init
Fix assertion in wallet initialization when wallet best block is ahead of the main chain.
2022-04-08 07:48:19 -06:00
Kris Nuttycombe f553ae3320 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: ying tong <yingtong@z.cash>
2022-04-07 23:05:05 -06:00
Kris Nuttycombe 773c2b515a Fix assertion in wallet initialization when wallet best block is ahead of the main chain.
In #5809, we attempted to fix the assumption that on startup, the
wallet's best chain was at the same position as the node's chain tip.
This did not account for a condition where the node's block index
might not contain the block corresponding to the wallet's best chain,
because the node had crashed before the block index containing that
block could be written to disk.

This commit adds handling so that the `ThreadNotifyWallets` thread
will not start until the wallet's best block has been restored
to the node's block index and we're able to obtain a pointer to
that state.
2022-04-07 17:23:13 -06:00
therealyingtong 1ab4da3f2c Use height of latest network upgrade in -mineraddress validation.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-04-07 18:49:44 +08:00
Jack Grigg 098a70ed89 wallet: Rename `CWallet::GetBestBlock` to `GetPersistedBestBlock`
This more accurately reflects its meaning, as it corresponds to the most
recently persisted best chain (i.e. the chain tip that the wallet will
return to on restart), rather than the chain tip to which the in-memory
wallet state has been synced.
2022-04-04 17:43:17 +00:00
Jack Grigg 3a1261efda wallet: Initialise ThreadNotifyWallets with wallet's best block
The previous code assumed that the last chain tip notified to the wallet
was equal to the node's chain tip at startup. However, this assumption
fails if the node shuts down uncleanly, or if a wallet file is moved
from one node to another.

We now try to start notifying from the wallet's best block, and if the
node doesn't have that block we fall back to the node's chain tip like
before.

Closes zcash/zcash#5805.
2022-04-02 00:38:26 +00:00
Steven Smith e375f4ace2 Remove the fExperimentalOrchardWallet flag and related logic 2022-03-25 21:46:09 -07:00
Kris Nuttycombe 80324bc653 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard-merge_master 2022-03-17 16:52:49 -06:00
Kris Nuttycombe 9d8c20ed78 Add UnifiedAddress variant to ZTXOSelector
When a user supplies a unified address as the source of funds
for z_sendmany, the previous behavior could have risked user
privacy by spending transparent UTXOs belonging to different
diversified addresses in the same transaction, thereby linking
those addresses, and consequently any diversified shielded
receivers of unified addresses containing those transparent
receivers.

This change limits selection of transparent UTXOs to only those
explicitly associated with the unified receivers of the provided
source UA. Also, if a UA is provided as the source, the behavior
is maintained that only shielded notes in pools corresponding to
the receivers of that UA will be selected.
2022-03-17 11:38:44 -06:00
Daira Hopwood 3e36252d9a Document that '~' cannot be used in `-datadir` (see #5661).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-03-11 18:35:52 +00:00
Jack Grigg 3fa58149b0 Select Orchard receivers from UA miner addresses once NU5 activates
Closes zcash/zcash#5023.
2022-03-03 15:57:40 +00:00
Pieter Wuille c079a518c0 Modernize best block mutex/cv/hash variable naming
(cherry picked from commit bitcoin/bitcoin@4a6c0e3dcf)
2022-03-01 17:09:19 -07:00
Kris Nuttycombe bf79be2b57 Replace z_getbalanceforaddress with z_getbalanceforviewingkey 2022-02-09 16:58:55 -07:00
Kris Nuttycombe c15f6a9cad Rename ZTXOSelector::SpendingKeysAvailable -> RequireSpendingKeys 2022-01-25 07:39:22 -07:00
Kris Nuttycombe a43dbb4925 Replace `HaveSpendingKeyForAddress` with checks at ZTXOSelector construction. 2022-01-19 14:37:54 -07:00
Kris Nuttycombe cc392c70a6 Merge branch 'master' into feature/wallet_unified_addresses 2022-01-12 16:54:12 -07:00
Kris Nuttycombe 41eebce355 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <jack@electriccoin.co>
2022-01-10 19:46:06 -07:00
Kris Nuttycombe 20266ac911 Remove uses of KeyIO::DecodeDestination 2022-01-07 11:49:07 -07:00
Kris Nuttycombe 890e1d841d Add raw transparent address types to PaymentAddress
The addition of `UnifiedAddress` to the `PaymentAddress` type
introduced the need for methods that interact with payment addresses
to support transparent receivers as shielded ones, which is somewhat
inconsistent with previous uses of the `PaymentAddress` type.

This commit adds both `CKeyID` and `CScriptID` as new variants
of the `PaymentAddress` type. Following commits will shift encoding
and decoding to use the `PaymentAddress` type exclusively wherever
possible, rather than the current mix of `CDestination` and
`PaymentAddress` that complicates the wallet codebase.
2022-01-06 13:44:45 -07:00
Kris Nuttycombe b305ad2892 Remove the `InvalidEncoding` type from key & address variants.
The presence of this variant results in a situation where more
of the code than necessary needs to be aware of and handle
decoding failures. This change moves all handling of decoding
failures to the point of decoding.
2022-01-06 13:44:45 -07:00
Kris Nuttycombe 98967e2ec7 Merge remote-tracking branch 'upstream/master' into feature/wallet_unified_addresses 2022-01-05 18:20:31 -07:00
Larry Ruane cc70cd2c46 add -orchardwallet experimental feature flag
Also, temporarily don't allow -orchardwallet if running mainnet.
2021-12-14 14:42:08 -07:00
Larry Ruane 7fa0e1a6a9 test: automatically add missing nuparams
This test-only change allows python (rpc) tests to specify, for example,
that NU5 should be activated at height X, without having to specify all
the previous network upgrades. Previous upgrades can (and must) still be
specified if they activate at different block heights (than, in this
example, NU5). This makes tests easier to write (and read), especially
as the number of network upgrades increases over time.

Note that this change only affects zcashd behavior in regtest mode. For
the other network modes (testnet and mainnet), the activation heights
are hard-coded in chainparams.cpp.
2021-12-06 17:32:18 -07:00
Kris Nuttycombe 9202b127d0 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard 2021-11-23 18:38:07 -07:00
Dimitris Apostolou e05c1ddf8a
Fix typos 2021-11-14 16:27:09 +02:00
Kris Nuttycombe 2885ae7643 Derive transparent keys from mnemonic seed. 2021-10-19 17:51:14 -06:00
Kris Nuttycombe 68c3bd8eaa Add BIP 44 coin type to persisted wallet state. 2021-09-29 10:15:43 -06:00
Wladimir J. van der Laan 25e125a5d3 Move mempool rejections to new debug category
Move mempool rejections to debug category `mempoolrej`, to make it possible
to show them without enabling the entire category `mempool` which is
high volume.

(cherry picked from commit bitcoin/bitcoin@7f1f8f5edf)
2021-08-13 16:24:09 +01:00
Jack Grigg c173a26a2d Revert "Remove reference to -reindex-chainstate"
This reverts commit f42cde3c30.
2021-08-09 20:58:49 +01:00