diff --git a/qa/rpc-tests/wallet_shieldcoinbase.py b/qa/rpc-tests/wallet_shieldcoinbase.py index 7d2d63e62..e4990cd9f 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase.py +++ b/qa/rpc-tests/wallet_shieldcoinbase.py @@ -19,11 +19,11 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework): initialize_chain_clean(self.options.tmpdir, 4) def setup_network(self, split=False): - args = ['-regtestprotectcoinbase', '-debug=zrpcunsafe'] + args = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', '-experimentalfeatures', '-zshieldcoinbase'] self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, args)) self.nodes.append(start_node(1, self.options.tmpdir, args)) - args2 = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', "-mempooltxinputlimit=7"] + args2 = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', '-experimentalfeatures', '-zshieldcoinbase', "-mempooltxinputlimit=7"] self.nodes.append(start_node(2, self.options.tmpdir, args2)) connect_nodes_bi(self.nodes,0,1) connect_nodes_bi(self.nodes,1,2) diff --git a/src/init.cpp b/src/init.cpp index 84f64dc07..3797e806d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -790,6 +790,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (!fExperimentalMode) { if (mapArgs.count("-developerencryptwallet")) { return InitError(_("Wallet encryption requires -experimentalfeatures.")); + } else if (mapArgs.count("-zshieldcoinbase")) { + return InitError(_("RPC call z_shieldcoinbase requires -experimentalfeatures.")); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 38bf7a274..55669f74f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3525,9 +3525,16 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return NullUniValue; + bool fEnableShieldCoinbase = fExperimentalMode && GetBoolArg("-zshieldcoinbase", false); + std::string strDisabledMsg = ""; + if (!fEnableShieldCoinbase) { + strDisabledMsg = "\nWARNING: z_shieldcoinbase is DISABLED but can be enabled as an experimental feature.\n"; + } + if (fHelp || params.size() < 2 || params.size() > 3) throw runtime_error( "z_shieldcoinbase \"fromaddress\" \"tozaddress\" ( fee )\n" + + strDisabledMsg + "\nShield transparent coinbase funds by sending to a shielded zaddr. This is an asynchronous operation and utxos" "\nselected for shielding will be locked. If there is an error, they are unlocked. The RPC call `listlockunspent`" "\ncan be used to return a list of locked utxos. The number of coinbase utxos selected for shielding is limited by" @@ -3549,6 +3556,10 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) "}\n" ); + if (!fEnableShieldCoinbase) { + throw JSONRPCError(RPC_WALLET_ERROR, "Error: z_shieldcoinbase is disabled."); + } + LOCK2(cs_main, pwalletMain->cs_wallet); // Validate the from address