Change "protect" terminology to "shield"

This commit is contained in:
Dimitris Apostolou 2019-11-28 23:36:29 +02:00
parent 868c63f92d
commit f0003239f8
No known key found for this signature in database
GPG Key ID: 4B5D20E938204A8A
13 changed files with 37 additions and 37 deletions

View File

@ -18,7 +18,7 @@ testScripts=(
'wallet_changeaddresses.py'
'wallet_changeindicator.py'
'wallet_import_export.py'
'wallet_protectcoinbase.py'
'wallet_shieldingcoinbase.py'
'wallet_shieldcoinbase_sprout.py'
'wallet_shieldcoinbase_sapling.py'
'wallet_listreceived.py'

View File

@ -23,14 +23,14 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 1)
# Start nodes with -regtestprotectcoinbase to set fCoinbaseMustBeProtected to true.
# Start nodes with -regtestshieldcoinbase to set fCoinbaseMustBeShielded to true.
def setup_network(self, split=False):
self.nodes = start_nodes(1, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase','-debug=zrpc']] )
self.nodes = start_nodes(1, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase','-debug=zrpc']] )
self.is_network_split=False
def add_second_node(self):
initialize_datadir(self.options.tmpdir, 1)
self.nodes.append(start_node(1, self.options.tmpdir, extra_args=['-regtestprotectcoinbase','-debug=zrpc']))
self.nodes.append(start_node(1, self.options.tmpdir, extra_args=['-regtestshieldcoinbase','-debug=zrpc']))
self.nodes[1].setmocktime(starttime + 9000)
connect_nodes_bi(self.nodes,0,1)
self.sync_all()
@ -38,7 +38,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
def restart_second_node(self, extra_args=[]):
self.nodes[1].stop()
bitcoind_processes[1].wait()
self.nodes[1] = start_node(1, self.options.tmpdir, extra_args=['-regtestprotectcoinbase','-debug=zrpc'] + extra_args)
self.nodes[1] = start_node(1, self.options.tmpdir, extra_args=['-regtestshieldcoinbase','-debug=zrpc'] + extra_args)
self.nodes[1].setmocktime(starttime + 9000)
connect_nodes_bi(self.nodes, 0, 1)
self.sync_all()

View File

@ -17,9 +17,9 @@ class WalletAnchorForkTest (BitcoinTestFramework):
print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 4)
# Start nodes with -regtestprotectcoinbase to set fCoinbaseMustBeProtected to true.
# Start nodes with -regtestshieldcoinbase to set fCoinbaseMustBeShielded to true.
def setup_network(self, split=False):
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase', '-debug=zrpc']] * 3 )
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase', '-debug=zrpc']] * 3 )
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
@ -64,7 +64,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
# Relaunch nodes and partition network into two:
# A: node 0
# B: node 1, 2
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase', '-debug=zrpc']] * 3 )
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase', '-debug=zrpc']] * 3 )
connect_nodes_bi(self.nodes,1,2)
# Partition B, node 1 mines an empty block
@ -94,7 +94,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
wait_bitcoinds()
# Relaunch nodes and reconnect the entire network
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase', '-debug=zrpc']] * 3 )
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase', '-debug=zrpc']] * 3 )
connect_nodes_bi(self.nodes,0, 1)
connect_nodes_bi(self.nodes,1, 2)
connect_nodes_bi(self.nodes,0, 2)

View File

@ -27,15 +27,15 @@ def check_value_pool(node, name, total):
assert_equal(pool['chainValueZat'], total * COIN)
assert(found)
class WalletProtectCoinbaseTest (BitcoinTestFramework):
class WalletShieldingCoinbaseTest (BitcoinTestFramework):
def setup_chain(self):
print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 4)
# Start nodes with -regtestprotectcoinbase to set fCoinbaseMustBeProtected to true.
# Start nodes with -regtestshieldcoinbase to set fCoinbaseMustBeShielded to true.
def setup_network(self, split=False):
self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase', '-debug=zrpcunsafe']] * 4 )
self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase', '-debug=zrpcunsafe']] * 4 )
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
@ -86,7 +86,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
wait_and_assert_operationid_status(self.nodes[3], myopid, "failed", "Insufficient funds, no UTXOs found for taddr from address.", 10)
# This send will fail because our wallet does not allow any change when protecting a coinbase utxo,
# This send will fail because our wallet does not allow any change when shielding a coinbase utxo,
# as it's currently not possible to specify a change address in z_sendmany.
recipients = []
recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')})
@ -365,4 +365,4 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
assert_equal(Decimal(resp), sum_of_notes)
if __name__ == '__main__':
WalletProtectCoinbaseTest().main()
WalletShieldingCoinbaseTest().main()

View File

@ -19,9 +19,9 @@ class WalletTreeStateTest (BitcoinTestFramework):
print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 4)
# Start nodes with -regtestprotectcoinbase to set fCoinbaseMustBeProtected to true.
# Start nodes with -regtestshieldcoinbase to set fCoinbaseMustBeShielded to true.
def setup_network(self, split=False):
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestprotectcoinbase','-debug=zrpc']] * 3 )
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-regtestshieldcoinbase','-debug=zrpc']] * 3 )
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)

View File

@ -23,14 +23,14 @@ class JoinSplitTest(BitcoinTestFramework):
zcaddress = zckeypair["zcaddress"]
(total_in, inputs) = gather_inputs(self.nodes[0], 40)
protect_tx = self.nodes[0].createrawtransaction(inputs, {})
joinsplit_result = self.nodes[0].zcrawjoinsplit(protect_tx, {}, {zcaddress:39.99}, 39.99, 0)
shield_tx = self.nodes[0].createrawtransaction(inputs, {})
joinsplit_result = self.nodes[0].zcrawjoinsplit(shield_tx, {}, {zcaddress:39.99}, 39.99, 0)
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])
assert_equal(receive_result["exists"], False)
protect_tx = self.nodes[0].signrawtransaction(joinsplit_result["rawtxn"])
self.nodes[0].sendrawtransaction(protect_tx["hex"])
shield_tx = self.nodes[0].signrawtransaction(joinsplit_result["rawtxn"])
self.nodes[0].sendrawtransaction(shield_tx["hex"])
self.nodes[0].generate(1)
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])

View File

@ -84,7 +84,7 @@ public:
strNetworkID = "main";
strCurrencyUnits = "ZEC";
bip44CoinType = 133; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md
consensus.fCoinbaseMustBeProtected = true;
consensus.fCoinbaseMustBeShielded = true;
consensus.nSubsidySlowStartInterval = 20000;
consensus.nPreBlossomSubsidyHalvingInterval = Consensus::PRE_BLOSSOM_HALVING_INTERVAL;
consensus.nPostBlossomSubsidyHalvingInterval = Consensus::POST_BLOSSOM_HALVING_INTERVAL;
@ -279,7 +279,7 @@ public:
strNetworkID = "test";
strCurrencyUnits = "TAZ";
bip44CoinType = 1;
consensus.fCoinbaseMustBeProtected = true;
consensus.fCoinbaseMustBeShielded = true;
consensus.nSubsidySlowStartInterval = 20000;
consensus.nPreBlossomSubsidyHalvingInterval = Consensus::PRE_BLOSSOM_HALVING_INTERVAL;
consensus.nPostBlossomSubsidyHalvingInterval = Consensus::POST_BLOSSOM_HALVING_INTERVAL;
@ -418,7 +418,7 @@ public:
strNetworkID = "regtest";
strCurrencyUnits = "REG";
bip44CoinType = 1;
consensus.fCoinbaseMustBeProtected = false;
consensus.fCoinbaseMustBeShielded = false;
consensus.nSubsidySlowStartInterval = 0;
consensus.nPreBlossomSubsidyHalvingInterval = Consensus::PRE_BLOSSOM_REGTEST_HALVING_INTERVAL;
consensus.nPostBlossomSubsidyHalvingInterval = Consensus::POST_BLOSSOM_REGTEST_HALVING_INTERVAL;
@ -553,8 +553,8 @@ void SelectParams(const std::string& network)
pCurrentParams = &Params(network);
// Some python qa rpc tests need to enforce the coinbase consensus rule
if (network == CBaseChainParams::REGTEST && mapArgs.count("-regtestprotectcoinbase")) {
regTestParams.SetRegTestCoinbaseMustBeProtected();
if (network == CBaseChainParams::REGTEST && mapArgs.count("-regtestshieldcoinbase")) {
regTestParams.SetRegTestCoinbaseMustBeShielded();
}
// When a developer is debugging turnstile violations in regtest mode, enable ZIP209

View File

@ -101,7 +101,7 @@ public:
CScript GetFoundersRewardScriptAtHeight(int height) const;
std::string GetFoundersRewardAddressAtIndex(int i) const;
/** Enforce coinbase consensus rule in regtest mode */
void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
void SetRegTestCoinbaseMustBeShielded() { consensus.fCoinbaseMustBeShielded = true; }
protected:
CChainParams() {}

View File

@ -97,7 +97,7 @@ struct Params {
uint256 hashGenesisBlock;
bool fCoinbaseMustBeProtected;
bool fCoinbaseMustBeShielded;
/** Needs to evenly divide MAX_SUBSIDY to avoid rounding errors. */
int nSubsidySlowStartInterval;

View File

@ -75,7 +75,7 @@ bool fPruneMode = false;
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
bool fCheckBlockIndex = false;
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
bool fCoinbaseEnforcedProtectionEnabled = true;
bool fCoinbaseEnforcedShieldingEnabled = true;
size_t nCoinCacheUsage = 5000 * 300;
uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS;
@ -2114,8 +2114,8 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
// Ensure that coinbases cannot be spent to transparent outputs
// Disabled on regtest
if (fCoinbaseEnforcedProtectionEnabled &&
consensusParams.fCoinbaseMustBeProtected &&
if (fCoinbaseEnforcedShieldingEnabled &&
consensusParams.fCoinbaseMustBeShielded &&
!tx.vout.empty()) {
return state.Invalid(
error("CheckInputs(): tried to spend coinbase with transparent outputs"),

View File

@ -172,7 +172,7 @@ extern bool fCheckBlockIndex;
extern bool fCheckpointsEnabled;
// TODO: remove this flag by structuring our code such that
// it is unneeded for testing
extern bool fCoinbaseEnforcedProtectionEnabled;
extern bool fCoinbaseEnforcedShieldingEnabled;
extern size_t nCoinCacheUsage;
extern CFeeRate minRelayTxFee;
extern bool fAlerts;

View File

@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
LOCK(cs_main);
fCheckpointsEnabled = false;
fCoinbaseEnforcedProtectionEnabled = false;
fCoinbaseEnforcedShieldingEnabled = false;
// We can't make transactions until we have inputs
// Therefore, load 100 blocks :)
@ -451,7 +451,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
delete tx;
fCheckpointsEnabled = true;
fCoinbaseEnforcedProtectionEnabled = true;
fCoinbaseEnforcedShieldingEnabled = true;
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -3147,11 +3147,11 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
fOnlyCoinbaseCoinsRet = vCoinsNoCoinbase.size() == 0 && vCoinsWithCoinbase.size() > 0;
// If coinbase utxos can only be sent to zaddrs, exclude any coinbase utxos from coin selection.
bool fProtectCoinbase = Params().GetConsensus().fCoinbaseMustBeProtected;
vector<COutput> vCoins = (fProtectCoinbase) ? vCoinsNoCoinbase : vCoinsWithCoinbase;
bool fShieldCoinbase = Params().GetConsensus().fCoinbaseMustBeShielded;
vector<COutput> vCoins = (fShieldCoinbase) ? vCoinsNoCoinbase : vCoinsWithCoinbase;
// Output parameter fNeedCoinbaseCoinsRet is set to true if coinbase utxos need to be spent to meet target amount
if (fProtectCoinbase && vCoinsWithCoinbase.size() > vCoinsNoCoinbase.size()) {
if (fShieldCoinbase && vCoinsWithCoinbase.size() > vCoinsNoCoinbase.size()) {
CAmount value = 0;
for (const COutput& out : vCoinsNoCoinbase) {
if (!out.fSpendable) {
@ -3393,7 +3393,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
bool fNeedCoinbaseCoins = false;
if (!SelectCoins(nTotalValue, setCoins, nValueIn, fOnlyCoinbaseCoins, fNeedCoinbaseCoins, coinControl))
{
if (fOnlyCoinbaseCoins && Params().GetConsensus().fCoinbaseMustBeProtected) {
if (fOnlyCoinbaseCoins && Params().GetConsensus().fCoinbaseMustBeShielded) {
strFailReason = _("Coinbase funds can only be sent to a zaddr");
} else if (fNeedCoinbaseCoins) {
strFailReason = _("Insufficient funds, coinbase funds can only be spent after they have been sent to a zaddr");