Auto merge of #1569 - str4d:1552-disable-wallet-encryption, r=daira
Disable wallet encryption Closes #1552
This commit is contained in:
@@ -1090,6 +1090,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_zkeys)
|
||||
Array arr = retValue.get_array();
|
||||
BOOST_CHECK(arr.size() == n);
|
||||
|
||||
// Verify that the wallet encryption RPC is disabled
|
||||
BOOST_CHECK_THROW(CallRPC("encryptwallet passphrase"), runtime_error);
|
||||
|
||||
// Encrypt the wallet (we can't call RPC encryptwallet as that shuts down node)
|
||||
SecureString strWalletPass;
|
||||
strWalletPass.reserve(100);
|
||||
|
||||
@@ -1979,10 +1979,18 @@ Value encryptwallet(const Array& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return Value::null;
|
||||
|
||||
|
||||
auto fEnableWalletEncryption = GetBoolArg("-developerencryptwallet", false);
|
||||
|
||||
std::string strWalletEncryptionDisabledMsg = "";
|
||||
if (!fEnableWalletEncryption) {
|
||||
strWalletEncryptionDisabledMsg = "\nWARNING: Wallet encryption is DISABLED. This call always fails.\n";
|
||||
}
|
||||
|
||||
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
|
||||
throw runtime_error(
|
||||
"encryptwallet \"passphrase\"\n"
|
||||
+ strWalletEncryptionDisabledMsg +
|
||||
"\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n"
|
||||
"After this, any calls that interact with private keys such as sending or signing \n"
|
||||
"will require the passphrase to be set prior the making these calls.\n"
|
||||
@@ -2008,6 +2016,9 @@ Value encryptwallet(const Array& params, bool fHelp)
|
||||
|
||||
if (fHelp)
|
||||
return true;
|
||||
if (!fEnableWalletEncryption) {
|
||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: wallet encryption is disabled.");
|
||||
}
|
||||
if (pwalletMain->IsCrypted())
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user