zcashd/src/deprecation.h

77 lines
2.8 KiB
C
Raw Normal View History

// Copyright (c) 2017 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_DEPRECATION_H
#define ZCASH_DEPRECATION_H
#include "consensus/params.h"
// Deprecation policy:
// Per https://zips.z.cash/zip-0200
// Shut down nodes running this version of code, 16 weeks' worth of blocks after the estimated
// release block height. A warning is shown during the 14 days' worth of blocks prior to shut down.
static const int APPROX_RELEASE_HEIGHT = 1540976;
static const int RELEASE_TO_DEPRECATION_WEEKS = 16;
static const int EXPECTED_BLOCKS_PER_HOUR = 3600 / Consensus::POST_BLOSSOM_POW_TARGET_SPACING;
static_assert(EXPECTED_BLOCKS_PER_HOUR == 48, "The value of Consensus::POST_BLOSSOM_POW_TARGET_SPACING was chosen such that this assertion holds.");
static const int ACTIVATION_TO_DEPRECATION_BLOCKS = (RELEASE_TO_DEPRECATION_WEEKS * 7 * 24 * EXPECTED_BLOCKS_PER_HOUR);
static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + ACTIVATION_TO_DEPRECATION_BLOCKS;
// Number of blocks before deprecation to warn users
static const int DEPRECATION_WARN_LIMIT = 14 * 24 * EXPECTED_BLOCKS_PER_HOUR;
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-21 15:47:56 -07:00
//! Defaults for -allowdeprecated
static const std::set<std::string> DEFAULT_ALLOW_DEPRECATED{{
#ifdef ENABLE_WALLET
"legacy_privacy",
"getnewaddress",
"z_getnewaddress",
"zcrawreceive",
"zcrawjoinsplit",
"zcrawkeygen",
"addrtype"
#endif
}};
static const std::set<std::string> DEFAULT_DENY_DEPRECATED{{
#ifdef ENABLE_WALLET
#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
* the current client version). Warning and error messages are sent to the debug
* log, the metrics UI, and (if configured) -alertnofity.
*
* fThread means run -alertnotify in a free-running thread.
*/
void EnforceNodeDeprecation(int nHeight, bool forceLogging=false, bool fThread=true);
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-21 15:47:56 -07:00
/**
* 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