Merge pull request #5905 from nuttycom/feature/disable_legacy_privacy_strategy
Allow deprecated wallet features to be preemptively disabled.
This commit is contained in:
commit
92d2a87053
|
@ -3,9 +3,11 @@
|
|||
[zcashd](README.md)
|
||||
- [User Documentation](user.md)
|
||||
- [Metrics](user/metrics.md)
|
||||
- [Deprecated Features](user/deprecation.md)
|
||||
- [Developer Documentation](dev.md)
|
||||
- [Rust in `zcashd`](dev/rust.md)
|
||||
- [Regtest tips and hints](dev/regtest.md)
|
||||
- [Deprecation Procedure](dev/deprecation.md)
|
||||
- [Design](design.md)
|
||||
- [Chain state](design/chain-state.md)
|
||||
- ["Coins" view](design/coins-view.md)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
Deprecation Procedure
|
||||
=====================
|
||||
|
||||
From time to time, features of `zcashd` and its associated wallet and RPC API are
|
||||
deprecated to allow eventual removal of functionality that has been superseded
|
||||
by more recent improvements. Deprecation follows a process whereby deprecate
|
||||
features can be explicitly turned on or off using the
|
||||
`-allowdeprecated=<feature>` CLI argument.
|
||||
|
||||
`zcashd` internally supports two sets of deprecated feature flags in
|
||||
`src/deprecation.h`:
|
||||
- `DEFAULT_ALLOW_DEPRECATED` contains the set of features that remain available
|
||||
for use without having to be specifically enabled using `-allowdeprecated`.
|
||||
- `DEFAULT_DENY_DEPRECATED` contains the set of features that are not enabled
|
||||
by default, and must be explicitly enabled using `-allowdeprecated`.
|
||||
|
||||
Deprecation of a feature occurs as a 3-step process:
|
||||
|
||||
1. A deprecation flag is selected for the feature, and added to
|
||||
`DEFAULT_ALLOW_DEPRECATED`. The fact of its deprecation is announced, and
|
||||
any functionality that supersedes the deprecated feature (if any) is
|
||||
documented, in the release notes. The string `DEPRECATED` is added to
|
||||
user-facing API documentation and CLI help text.
|
||||
2. The deprecation flag is removed from `DEFAULT_ALLOW_DEPRECATED` and added to
|
||||
`DEFAULT_DENY_DEPRECATED`.
|
||||
3. The deprecated feature is removed entirely, and its deprecation flag is
|
||||
removed.
|
||||
|
||||
Features that enter Stage 1 in a particular release should be disabled by
|
||||
default after no fewer than 3 releases that update `zcashd`'s
|
||||
minor-version, and features should only be fully removed after a total of 6 minor-version
|
||||
updates. `zcashd`'s release schedule intends to produce a release that updates
|
||||
the minor version every 6 weeks, so deprecated features remain accessible by
|
||||
default for approximately 18 weeks, and then can be expected to be removed no
|
||||
less than 36 weeks from their initial deprecation. The deprecation timeline for
|
||||
each newly deprecated feature should be documented in
|
||||
[../user/deprecation.md](../user/deprecation.md).
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
Deprecated Features
|
||||
===================
|
||||
|
||||
In order to support the continuous improvement of `zcashd`, features are
|
||||
periodically deprecated and removed when they have been superseded or are no
|
||||
longer useful. Deprecation follows a 3-stage process:
|
||||
|
||||
1. Initially, a feature will be marked as DEPRECATED in the release notes and
|
||||
user-facing documentation, but no other changes are made; the feature
|
||||
continues to be available and function as normal. While features at this
|
||||
stage remain enabled by default, they may be explicitly disabled by
|
||||
specifying `-allowdeprecated=none` on the command line when starting the
|
||||
node, or by including `allowdeprecated=none` as a line in the `zcash.conf`
|
||||
file.
|
||||
2. In the next stage of deprecation, the feature will be disabled by default.
|
||||
Disabled features may be reenabled via use of the `-allowdeprecated` flag.
|
||||
3. In the third stage, the feature is fully removed and is no longer available.
|
||||
|
||||
Features that enter Stage 1 in a particular release will be disabled by default
|
||||
after no fewer than 3 releases that update `zcashd`'s minor-version, and
|
||||
features will only be fully removed after a total of at least 6 minor-version updates.
|
||||
`zcashd`'s release schedule intends to produce a release that updates the minor
|
||||
version every 6 weeks, so deprecated features remain accessible by default for
|
||||
approximately 18 weeks, and then can be expected to be removed no less than 36
|
||||
weeks after their initial deprecation. Deprecation and removal timelines might
|
||||
be extended beyond this on a case-by-case basis to satisfy user requirements.
|
||||
|
||||
Currently Deprecated
|
||||
====================
|
||||
|
||||
Stage 1
|
||||
-------
|
||||
|
||||
The following features are deprecated, but remain enabled by default. These features
|
||||
will be disabled if `-allowdeprecated=none` is added to the CLI arguments when starting
|
||||
the node, or if an `allowdeprecated=none` line is added to `zcash.conf`.
|
||||
|
||||
### Deprecated in 5.0.0
|
||||
|
||||
The following features are deprecated as of release 5.0.0 and will be disabled by
|
||||
default as of release 5.3.0.
|
||||
|
||||
- `legacy_privacy` - The default "legacy" privacy policy for z_sendmany is
|
||||
deprecated. Use `-allowdeprecated=none` to require the default behavior to
|
||||
conform to the `FullPrivacy` directive in all cases instead of just for
|
||||
transactions involving unified addresses.
|
||||
- `getnewaddress` - The `getnewaddress` RPC method is deprecated.
|
||||
- `z_getnewaddress` - The `z_getnewaddress` RPC method is deprecated.
|
||||
- `addrtype` - The `type` attribute is deprecated in the results of RPC
|
||||
methods that return address metadata. It is recommended that applications
|
||||
using this metadata be updated to use the `pool` or `address_type`
|
||||
attributes, which have replaced the `type` attribute, as appropriate.
|
||||
|
||||
Stage 2
|
||||
-------
|
||||
|
||||
Each feature in the lists below may be enabled by adding `-allowdeprecated=<feature>`
|
||||
to the CLI arguments when starting the node, or by adding an `allowdeprecated=<feature>`
|
||||
line to `zcash.conf`.
|
||||
|
||||
### Disabled in 5.0.0
|
||||
|
||||
The following features are disabled by default, and will be removed in release 5.3.0.
|
||||
|
||||
- `zcrawreceive` - The `zcrawreceive` RPC method is disabled.
|
||||
- `zcrawjoinsplit` - The `zcrawjoinsplit` RPC method is disabled.
|
||||
- `zcrawkeygen` - The `zcrawkeygen` RPC method is disabled.
|
|
@ -4,6 +4,53 @@ release-notes at release time)
|
|||
Notable changes
|
||||
===============
|
||||
|
||||
Feature Deprecation and removal
|
||||
-------------------------------
|
||||
|
||||
`zcashd` now has a [process](https://zcash.github.io/zcash/user/deprecation.html)
|
||||
for how features of the public API may be deprecated and removed. Feature
|
||||
deprecation follows a series of steps whereby, over a series of releases,
|
||||
features first remain enabled by default (but may be explicitly disabled), then
|
||||
switch to being disabled by default, and eventually are removed entirely.
|
||||
|
||||
A new string-valued option, `-allowdeprecated` has been introduced to allow a
|
||||
user to explicitly manage the availability of deprecated `zcashd` features. This
|
||||
flag makes it possible for users to reenable deprecated methods and features
|
||||
api that are currently disabled by default, or alternately to explicitly
|
||||
disable all deprecated features if they so choose. Multiple instances of this
|
||||
argument may be provided. A user may disable deprecated features entirely
|
||||
by providing the string `none` as the argument to this parameter. In the case
|
||||
that `none` is specified, multiple invocations of `-allowdeprecated` are not
|
||||
permitted.
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
|
||||
As of this release, the following features are deprecated, but remain
|
||||
available by default. These features may be disabled by setting
|
||||
`-allowdeprecated=none`. After release 5.3.0, these features will be
|
||||
disabled by default and the following flags to `-allowdeprecated` will
|
||||
be required to permit their continued use:
|
||||
|
||||
- `legacy_privacy` - the default "legacy" privacy policy for z_sendmany
|
||||
is deprecated. When disabled, the default behavior of z_sendmany will
|
||||
conform to the `FullPrivacy` directive (introduced in 4.7.0) in all cases
|
||||
instead of just for transactions involving unified addresses.
|
||||
- `getnewaddress` - controls availability of the `getnewaddress` RPC method.
|
||||
- `z_getnewaddress` - controls availability of the `z_getnewaddress` RPC method.
|
||||
- `addrtype` - controls availability of the deprecated `type` attribute
|
||||
returned by RPC methods that return address metadata.
|
||||
|
||||
As of this release, the following previously deprecated features are disabled
|
||||
by default, but may be be reenabled using `-allowdeprecated=<feature>`.
|
||||
|
||||
- The `zcrawreceive` RPC method is disabled. It may be reenabled with
|
||||
`allowdeprecated=zcrawreceive`
|
||||
- The `zcrawjoinsplit` RPC method is disabled. It may be reenabled with
|
||||
`allowdeprecated=zcrawjoinsplit`
|
||||
- The `zcrawkeygen` RPC method is disabled. It may be reenabled with
|
||||
`allowdeprecated=zcrawkeygen`
|
||||
|
||||
Option handling
|
||||
---------------
|
||||
|
||||
|
@ -11,6 +58,13 @@ Option handling
|
|||
(provided that the wallet is enabled and pruning is disabled, and unless
|
||||
`-rescan=0` is specified explicitly).
|
||||
|
||||
RPC Changes
|
||||
-----------
|
||||
|
||||
- The deprecated `zcrawkeygen`, `zcrawreceive`, and `zcrawjoinsplit` RPC
|
||||
methods are now disabled by default. Use `-allowdeprecated=<feature>`
|
||||
to select individual features if you wish to continue using these APIs.
|
||||
|
||||
Build system
|
||||
------------
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ BASE_SCRIPTS= [
|
|||
'wallet_addresses.py',
|
||||
'wallet_anchorfork.py',
|
||||
'wallet_changeindicator.py',
|
||||
'wallet_deprecation.py',
|
||||
'wallet_doublespend.py',
|
||||
'wallet_import_export.py',
|
||||
'wallet_isfromme.py',
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2022 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
start_nodes,
|
||||
stop_nodes,
|
||||
wait_bitcoinds,
|
||||
)
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
# Test wallet address behaviour across network upgrades
|
||||
class WalletDeprecationTest(BitcoinTestFramework):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.num_nodes = 1
|
||||
|
||||
def setup_network(self):
|
||||
self.setup_network_internal([])
|
||||
|
||||
def setup_network_internal(self, allowed_deprecated = []):
|
||||
dep_args = ["-allowdeprecated=" + v for v in allowed_deprecated]
|
||||
|
||||
self.nodes = start_nodes(
|
||||
self.num_nodes, self.options.tmpdir,
|
||||
extra_args=[dep_args] * self.num_nodes)
|
||||
|
||||
def run_test(self):
|
||||
# z_getnewaddress is deprecated, but enabled by default so it should succeed
|
||||
self.nodes[0].z_getnewaddress()
|
||||
|
||||
# zcrawkeygen is deprecated, and not enabled by default so it should fail
|
||||
errorString = ''
|
||||
try:
|
||||
self.nodes[0].zcrawkeygen()
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert "DEPRECATED" in errorString
|
||||
|
||||
# restart with a specific selection of deprecated methods enabled
|
||||
stop_nodes(self.nodes)
|
||||
wait_bitcoinds()
|
||||
self.setup_network_internal(["getnewaddress","zcrawkeygen"])
|
||||
|
||||
# z_getnewaddress is enabled by default, so it should succeed
|
||||
self.nodes[0].z_getnewaddress()
|
||||
|
||||
# getnewaddress and zcrawkeygen are enabled so they should succeed.
|
||||
self.nodes[0].getnewaddress()
|
||||
self.nodes[0].zcrawkeygen()
|
||||
|
||||
# restart with no deprecated methods enabled
|
||||
stop_nodes(self.nodes)
|
||||
wait_bitcoinds()
|
||||
self.setup_network_internal(["none"])
|
||||
|
||||
errorString = ''
|
||||
try:
|
||||
self.nodes[0].z_getnewaddress()
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert "DEPRECATED" in errorString
|
||||
|
||||
errorString = ''
|
||||
try:
|
||||
self.nodes[0].zcrawkeygen()
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert "DEPRECATED" in errorString
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletDeprecationTest().main()
|
|
@ -17,7 +17,9 @@ class JoinSplitTest(BitcoinTestFramework):
|
|||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.is_network_split = False
|
||||
self.nodes.append(start_node(0, self.options.tmpdir))
|
||||
self.nodes.append(start_node(0, self.options.tmpdir,
|
||||
["-allowdeprecated=zcrawkeygen", "-allowdeprecated=zcrawjoinsplit", "-allowdeprecated=zcrawreceive"]
|
||||
))
|
||||
|
||||
def run_test(self):
|
||||
zckeypair = self.nodes[0].zcrawkeygen()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, connect_nodes, \
|
||||
gather_inputs, sync_blocks
|
||||
gather_inputs, start_nodes, sync_blocks
|
||||
|
||||
import time
|
||||
|
||||
|
@ -16,6 +16,10 @@ class JoinSplitTest(BitcoinTestFramework):
|
|||
# Start with split network:
|
||||
return super(JoinSplitTest, self).setup_network(True)
|
||||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(self.num_nodes, self.options.tmpdir,
|
||||
extra_args = [["-allowdeprecated=zcrawjoinsplit", "-allowdeprecated=zcrawkeygen", "-allowdeprecated=zcrawreceive"]] * self.num_nodes)
|
||||
|
||||
def txid_in_mempool(self, node, txid):
|
||||
exception_triggered = False
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
#include "clientversion.h"
|
||||
#include "deprecation.h"
|
||||
#include "fs.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
|
@ -92,6 +93,14 @@ bool AppInit(int argc, char* argv[])
|
|||
return true;
|
||||
}
|
||||
|
||||
// Handle setting of allowed-deprecated features as early as possible
|
||||
// so that it's possible for other initialization steps to respect them.
|
||||
auto deprecationError = SetAllowedDeprecatedFeaturesFromCLIArgs();
|
||||
if (deprecationError.has_value()) {
|
||||
fprintf(stderr, "%s", deprecationError.value().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!fs::is_directory(GetDataDir(false)))
|
||||
|
|
|
@ -11,6 +11,17 @@
|
|||
#include "util.h"
|
||||
#include "chainparams.h"
|
||||
|
||||
// Flags that enable deprecated functionality.
|
||||
#ifdef ENABLE_WALLET
|
||||
bool fEnableGetNewAddress = true;
|
||||
bool fEnableZGetNewAddress = true;
|
||||
bool fEnableLegacyPrivacyStrategy = true;
|
||||
bool fEnableZCRawReceive = true;
|
||||
bool fEnableZCRawJoinSplit = true;
|
||||
bool fEnableZCRawKeygen = true;
|
||||
bool fEnableAddrTypeField = true;
|
||||
#endif
|
||||
|
||||
static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
|
||||
|
||||
void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
|
||||
|
@ -46,3 +57,59 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
|
|||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> SetAllowedDeprecatedFeaturesFromCLIArgs() {
|
||||
auto args = GetMultiArg("-allowdeprecated");
|
||||
std::set<std::string> allowdeprecated(args.begin(), args.end());
|
||||
|
||||
if (allowdeprecated.count("none") > 0) {
|
||||
if (allowdeprecated.size() > 1)
|
||||
return "When using -allowdeprecated=none no other values may be provided for -allowdeprecated.";
|
||||
allowdeprecated = {};
|
||||
} else {
|
||||
allowdeprecated.insert(DEFAULT_ALLOW_DEPRECATED.begin(), DEFAULT_ALLOW_DEPRECATED.end());
|
||||
}
|
||||
|
||||
std::set<std::string> unrecognized;
|
||||
for (const auto& flag : allowdeprecated) {
|
||||
if (DEFAULT_ALLOW_DEPRECATED.count(flag) == 0 && DEFAULT_DENY_DEPRECATED.count(flag) == 0)
|
||||
unrecognized.insert(flag);
|
||||
}
|
||||
|
||||
if (unrecognized.size() > 0) {
|
||||
std::string unrecMsg;
|
||||
for (const auto& value : unrecognized) {
|
||||
if (unrecMsg.size() > 0) unrecMsg += ", ";
|
||||
unrecMsg += "\"" + value + "\"";
|
||||
}
|
||||
|
||||
return strprintf(
|
||||
"Unrecognized argument(s) to -allowdeprecated: %s;\n"
|
||||
"Please select from the following values: %s",
|
||||
unrecMsg, GetAllowableDeprecatedFeatures());
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
fEnableLegacyPrivacyStrategy = allowdeprecated.count("legacy_privacy") > 0;
|
||||
fEnableGetNewAddress = allowdeprecated.count("getnewaddress") > 0;
|
||||
fEnableZGetNewAddress = allowdeprecated.count("z_getnewaddress") > 0;
|
||||
fEnableZCRawReceive = allowdeprecated.count("zcrawreceive") > 0;
|
||||
fEnableZCRawJoinSplit = allowdeprecated.count("zcrawjoinsplit") > 0;
|
||||
fEnableZCRawKeygen = allowdeprecated.count("zcrawkeygen") > 0;
|
||||
fEnableAddrTypeField = allowdeprecated.count("addrtype") > 0;
|
||||
#endif
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string GetAllowableDeprecatedFeatures() {
|
||||
std::string result = "\"none\"";
|
||||
for (const auto& value : DEFAULT_ALLOW_DEPRECATED) {
|
||||
result += ", \"" + value + "\"";
|
||||
}
|
||||
for (const auto& value : DEFAULT_DENY_DEPRECATED) {
|
||||
result += ", \"" + value + "\"";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,37 @@ static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + ACTIVATION_TO_DEPR
|
|||
// Number of blocks before deprecation to warn users
|
||||
static const int DEPRECATION_WARN_LIMIT = 14 * 24 * EXPECTED_BLOCKS_PER_HOUR;
|
||||
|
||||
//! Defaults for -allowdeprecated
|
||||
static const std::set<std::string> DEFAULT_ALLOW_DEPRECATED{{
|
||||
// Node-level features
|
||||
|
||||
// Wallet-level features
|
||||
#ifdef ENABLE_WALLET
|
||||
"legacy_privacy",
|
||||
"getnewaddress",
|
||||
"z_getnewaddress",
|
||||
"addrtype"
|
||||
#endif
|
||||
}};
|
||||
static const std::set<std::string> DEFAULT_DENY_DEPRECATED{{
|
||||
#ifdef ENABLE_WALLET
|
||||
"zcrawreceive",
|
||||
"zcrawjoinsplit",
|
||||
"zcrawkeygen",
|
||||
#endif
|
||||
}};
|
||||
|
||||
// Flags that enable deprecated functionality.
|
||||
#ifdef ENABLE_WALLET
|
||||
extern bool fEnableGetNewAddress;
|
||||
extern bool fEnableZGetNewAddress;
|
||||
extern bool fEnableLegacyPrivacyStrategy;
|
||||
extern bool fEnableZCRawReceive;
|
||||
extern bool fEnableZCRawJoinSplit;
|
||||
extern bool fEnableZCRawKeygen;
|
||||
extern bool fEnableAddrTypeField;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Checks whether the node is deprecated based on the current block height, and
|
||||
* shuts down the node with an error if so (and deprecation is not disabled for
|
||||
|
@ -30,4 +61,19 @@ static const int DEPRECATION_WARN_LIMIT = 14 * 24 * EXPECTED_BLOCKS_PER_HOUR;
|
|||
*/
|
||||
void EnforceNodeDeprecation(int nHeight, bool forceLogging=false, bool fThread=true);
|
||||
|
||||
/**
|
||||
* Checks command-line arguments for enabling and/or disabling of deprecated
|
||||
* features and sets flags that enable deprecated features accordingly.
|
||||
*
|
||||
* @return std::nullopt if successful, or an error message indicating what
|
||||
* values are permitted for `-allowdeprecated`.
|
||||
*/
|
||||
std::optional<std::string> SetAllowedDeprecatedFeaturesFromCLIArgs();
|
||||
|
||||
/**
|
||||
* Returns a comma-separated list of the valid arguments to the -allowdeprecated
|
||||
* CLI option.
|
||||
*/
|
||||
std::string GetAllowableDeprecatedFeatures();
|
||||
|
||||
#endif // ZCASH_DEPRECATION_H
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "compat/sanity.h"
|
||||
#include "consensus/upgrades.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "deprecation.h"
|
||||
#include "experimental_features.h"
|
||||
#include "fs.h"
|
||||
#include "httpserver.h"
|
||||
|
@ -332,6 +333,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||
strUsage += HelpMessageOpt("-?", _("This help message"));
|
||||
strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
|
||||
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
|
||||
strUsage += HelpMessageOpt("-allowdeprecated=<feature>", strprintf(_("Explicitly allow the use of the specified deprecated feature. Multiple instances of this parameter are permitted; values for <feature> must be selected from among {%s}"), GetAllowableDeprecatedFeatures()));
|
||||
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-blocksonly", strprintf(_("Whether to reject transactions from network peers. Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled, unless '-whitelistforcerelay' is '1', in which case whitelisted peers' transactions will be relayed. RPC transactions are not affected. (default: %u)"), DEFAULT_BLOCKSONLY));
|
||||
|
|
12
src/util.cpp
12
src/util.cpp
|
@ -78,7 +78,7 @@ const char * const BITCOIN_PID_FILENAME = "zcashd.pid";
|
|||
|
||||
CCriticalSection cs_args;
|
||||
map<string, string> mapArgs;
|
||||
map<string, vector<string> > mapMultiArgs;
|
||||
map<string, vector<string>> mapMultiArgs;
|
||||
bool fDebug = false;
|
||||
bool fDaemon = false;
|
||||
bool fServer = false;
|
||||
|
@ -161,6 +161,15 @@ bool GetBoolArg(const std::string& strArg, bool fDefault)
|
|||
return fDefault;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetMultiArg(const std::string& strArg)
|
||||
{
|
||||
if (mapMultiArgs.count(strArg)) {
|
||||
return mapMultiArgs[strArg];
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool SoftSetArg(const std::string& strArg, const std::string& strValue)
|
||||
{
|
||||
LOCK(cs_args);
|
||||
|
@ -378,6 +387,7 @@ void ReadConfigFile(const std::string& confPath,
|
|||
|
||||
const vector<string> allowed_duplicates = {
|
||||
"addnode",
|
||||
"allowdeprecated",
|
||||
"bind",
|
||||
"connect",
|
||||
"debug",
|
||||
|
|
12
src/util.h
12
src/util.h
|
@ -129,6 +129,18 @@ int64_t GetArg(const std::string& strArg, int64_t nDefault);
|
|||
*/
|
||||
bool GetBoolArg(const std::string& strArg, bool fDefault);
|
||||
|
||||
/**
|
||||
* Return the values provided for a multiargument parameter.
|
||||
* Multiargument parameters are provided via repetition of
|
||||
* single-argument parameters, e.g. "-foo=value1 -foo=value2"
|
||||
* will result in the vector `{"value1", "value2"}` returned
|
||||
* for `GetMultiArg("-foo")`.
|
||||
*
|
||||
* @param strArg Argument to get values for (e.g. "-foo")
|
||||
* @return each value provided for the parameter.
|
||||
*/
|
||||
std::vector<std::string> GetMultiArg(const std::string& strArg);
|
||||
|
||||
/**
|
||||
* Set an argument if it doesn't already have a value
|
||||
*
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "chain.h"
|
||||
#include "core_io.h"
|
||||
#include "deprecation.h"
|
||||
#include "key_io.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
|
@ -794,7 +795,9 @@ UniValue z_importkey(const UniValue& params, bool fHelp)
|
|||
auto addrInfo = std::visit(libzcash::AddressInfoFromSpendingKey{}, spendingkey.value());
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.pushKV("address_type", addrInfo.first);
|
||||
result.pushKV("type", addrInfo.first); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
result.pushKV("type", addrInfo.first); //deprecated
|
||||
}
|
||||
result.pushKV("address", keyIO.EncodePaymentAddress(addrInfo.second));
|
||||
|
||||
// Sapling support
|
||||
|
@ -893,7 +896,9 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
|||
UniValue result(UniValue::VOBJ);
|
||||
const string strAddress = keyIO.EncodePaymentAddress(addrInfo.second);
|
||||
result.pushKV("address_type", addrInfo.first);
|
||||
result.pushKV("type", addrInfo.first); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
result.pushKV("type", addrInfo.first); //deprecated
|
||||
}
|
||||
result.pushKV("address", strAddress);
|
||||
|
||||
auto addResult = std::visit(AddViewingKeyToWallet(pwalletMain, true), viewingkey.value());
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "consensus/upgrades.h"
|
||||
#include "consensus/params.h"
|
||||
#include "core_io.h"
|
||||
#include "deprecation.h"
|
||||
#include "experimental_features.h"
|
||||
#include "init.h"
|
||||
#include "key_io.h"
|
||||
|
@ -156,6 +157,13 @@ UniValue getnewaddress(const UniValue& params, bool fHelp)
|
|||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (!fEnableGetNewAddress)
|
||||
throw runtime_error(
|
||||
"getnewaddress is DEPRECATED and will be removed in a future release\n"
|
||||
"\nUse z_getnewaccount and z_getaddressforaccount instead, or restart \n"
|
||||
"with `-allowdeprecated=getnewaddress` if you require backward compatibility.\n"
|
||||
"See https://zcash.github.io/zcash/user/deprecation.html for more information.");
|
||||
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error(
|
||||
"getnewaddress ( \"\" )\n"
|
||||
|
@ -173,7 +181,6 @@ UniValue getnewaddress(const UniValue& params, bool fHelp)
|
|||
+ HelpExampleRpc("getnewaddress", "")
|
||||
);
|
||||
|
||||
|
||||
const UniValue& dummy_value = params[0];
|
||||
if (!dummy_value.isNull() && dummy_value.get_str() != "") {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "dummy first argument must be excluded or set to \"\".");
|
||||
|
@ -2569,7 +2576,9 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
|
|||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("txid", entry.op.hash.ToString());
|
||||
obj.pushKV("pool", ADDR_TYPE_SAPLING);
|
||||
obj.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
obj.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
}
|
||||
obj.pushKV("outindex", (int)entry.op.n);
|
||||
obj.pushKV("confirmations", entry.confirmations);
|
||||
bool hasSaplingSpendingKey = pwalletMain->HaveSaplingSpendingKeyForAddress(entry.address);
|
||||
|
@ -2857,6 +2866,12 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp)
|
|||
return NullUniValue;
|
||||
}
|
||||
|
||||
if (!fEnableZCRawReceive)
|
||||
throw runtime_error(
|
||||
"zcrawreceive is DEPRECATED and will be removed in a future release\n"
|
||||
"\nrestart with `-allowdeprecated=zcrawreceive` if you require backward compatibility.\n"
|
||||
"See https://zcash.github.io/zcash/user/deprecation.html for more information.");
|
||||
|
||||
if (fHelp || params.size() != 2) {
|
||||
throw runtime_error(
|
||||
"zcrawreceive zcsecretkey encryptednote\n"
|
||||
|
@ -2945,6 +2960,12 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
return NullUniValue;
|
||||
}
|
||||
|
||||
if (!fEnableZCRawJoinSplit)
|
||||
throw runtime_error(
|
||||
"zcrawjoinsplit is DEPRECATED and will be removed in a future release\n"
|
||||
"\nrestart with `-allowdeprecated=zcrawjoinsplit` if you require backward compatibility.\n"
|
||||
"See https://zcash.github.io/zcash/user/deprecation.html for more information.");
|
||||
|
||||
if (fHelp || params.size() != 5) {
|
||||
throw runtime_error(
|
||||
"zcrawjoinsplit rawtx inputs outputs vpub_old vpub_new\n"
|
||||
|
@ -3161,6 +3182,12 @@ UniValue zc_raw_keygen(const UniValue& params, bool fHelp)
|
|||
return NullUniValue;
|
||||
}
|
||||
|
||||
if (!fEnableZCRawKeygen)
|
||||
throw runtime_error(
|
||||
"zcrawkeygen is DEPRECATED and will be removed in a future release\n"
|
||||
"\nrestart with `-allowdeprecated=zcrawkeygen` if you require backward compatibility.\n"
|
||||
"See https://zcash.github.io/zcash/user/deprecation.html for more information.");
|
||||
|
||||
if (fHelp || params.size() != 0) {
|
||||
throw runtime_error(
|
||||
"zcrawkeygen\n"
|
||||
|
@ -3193,6 +3220,13 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp)
|
|||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (!fEnableZGetNewAddress)
|
||||
throw runtime_error(
|
||||
"z_getnewaddress is DEPRECATED and will be removed in a future release\n"
|
||||
"\nUse z_getnewaccount and z_getaddressforaccount instead, or restart \n"
|
||||
"with `-allowdeprecated=z_getnewaddress` if you require backward compatibility.\n"
|
||||
"See https://zcash.github.io/zcash/user/deprecation.html for more information.");
|
||||
|
||||
std::string defaultType = ADDR_TYPE_SAPLING;
|
||||
|
||||
if (fHelp || params.size() > 1)
|
||||
|
@ -4424,7 +4458,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_SPROUT);
|
||||
entry.pushKV("type", ADDR_TYPE_SPROUT); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_SPROUT); //deprecated
|
||||
}
|
||||
entry.pushKV("js", (int)i);
|
||||
entry.pushKV("jsSpend", (int)j);
|
||||
entry.pushKV("txidPrev", jsop.hash.GetHex());
|
||||
|
@ -4448,7 +4484,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_SPROUT);
|
||||
entry.pushKV("type", ADDR_TYPE_SPROUT); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_SPROUT); //deprecated
|
||||
}
|
||||
entry.pushKV("js", (int)jsop.js);
|
||||
entry.pushKV("jsOutput", (int)jsop.n);
|
||||
entry.pushKV("address", keyIO.EncodePaymentAddress(pa));
|
||||
|
@ -4532,7 +4570,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_SAPLING);
|
||||
entry.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
}
|
||||
entry.pushKV("spend", (int)i);
|
||||
entry.pushKV("txidPrev", op.hash.GetHex());
|
||||
entry.pushKV("outputPrev", (int)op.n);
|
||||
|
@ -4586,7 +4626,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_SAPLING);
|
||||
entry.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_SAPLING); //deprecated
|
||||
}
|
||||
entry.pushKV("output", (int)op.n);
|
||||
entry.pushKV("outgoing", isOutgoing);
|
||||
entry.pushKV("walletInternal", addr.second == RecipientType::WalletInternalAddress);
|
||||
|
@ -4618,7 +4660,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_ORCHARD);
|
||||
entry.pushKV("type", ADDR_TYPE_ORCHARD); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_ORCHARD); //deprecated
|
||||
}
|
||||
entry.pushKV("action", (int) actionIdx);
|
||||
entry.pushKV("txidPrev", outpoint.hash.GetHex());
|
||||
entry.pushKV("actionPrev", (int) outpoint.n);
|
||||
|
@ -4646,7 +4690,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.pushKV("pool", ADDR_TYPE_ORCHARD);
|
||||
entry.pushKV("type", ADDR_TYPE_ORCHARD); //deprecated
|
||||
if (fEnableAddrTypeField) {
|
||||
entry.pushKV("type", ADDR_TYPE_ORCHARD); //deprecated
|
||||
}
|
||||
entry.pushKV("action", (int) actionIdx);
|
||||
entry.pushKV("outgoing", orchardActionOutput.IsOutgoing());
|
||||
entry.pushKV("walletInternal", addr.second == RecipientType::WalletInternalAddress);
|
||||
|
@ -5074,7 +5120,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
// evaluating the strategy.
|
||||
TransactionStrategy strategy = maybeStrategy.value_or(
|
||||
// Default privacy policy is "LegacyCompat".
|
||||
involvesUnifiedAddress ?
|
||||
(involvesUnifiedAddress || !fEnableLegacyPrivacyStrategy) ?
|
||||
TransactionStrategy(PrivacyPolicy::FullPrivacy) :
|
||||
TransactionStrategy(PrivacyPolicy::AllowFullyTransparent)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue