diff options
author | whythat <whythat@protonmail.com> | 2019-06-04 13:33:39 +0300 |
---|---|---|
committer | whythat <whythat@protonmail.com> | 2019-06-04 16:39:34 +0300 |
commit | 7860c98bd59cd8f56e9b2b4ae45265c046e7cfd9 (patch) | |
tree | 2be6410322f87ecb4f068856fb74b96c8bf09473 /src/wallet/rpcwallet.cpp | |
parent | d3a1c2502bb19d667c692937784fe027fd8d32da (diff) | |
download | bitcoin-7860c98bd59cd8f56e9b2b4ae45265c046e7cfd9.tar.xz |
wallet: do not encrypt wallets with disabled private keys
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r-- | src/wallet/rpcwallet.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 71d62a47dc..c158cd4e20 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2124,6 +2124,10 @@ static UniValue encryptwallet(const JSONRPCRequest& request) auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); + if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { + throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: wallet does not contain private keys, nothing to encrypt."); + } + if (pwallet->IsCrypted()) { throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called."); } |