Disable wallet encryption

Closes #1552
This commit is contained in:
Jack Grigg 2016-10-18 17:47:17 -05:00
parent 1218603f73
commit 62c0aa9e58
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
1 changed files with 12 additions and 1 deletions

View File

@ -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 does nothing.\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) {
return false;
}
if (pwalletMain->IsCrypted())
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");