aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-06-05 12:47:26 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2019-06-05 12:49:35 +0200
commit52ec4c64e89f478cd2134dbf25f5987d39e9b8bc (patch)
tree747503752d31919c5b7cd252b5d2de38cb0199c4 /src
parent5d37c1bde01a7c43ed7ac1ab50cc41ff7d849ca9 (diff)
parent7860c98bd59cd8f56e9b2b4ae45265c046e7cfd9 (diff)
downloadbitcoin-52ec4c64e89f478cd2134dbf25f5987d39e9b8bc.tar.xz
Merge #16144: wallet: do not encrypt wallets with disabled private keys
7860c98bd wallet: do not encrypt wallets with disabled private keys (whythat) Pull request description: Fix for #15635. Throw an `RPC_WALLET_ENCRYPTION_FAILED` error when attempting to encrypt wallet with disabled private keys. Changed `test/function/wallet_createwallet.py` to test new behavior. ACKs for commit 7860c9: achow101: utACK 7860c98bd59cd8f56e9b2b4ae45265c046e7cfd9 meshcollider: utACK https://github.com/bitcoin/bitcoin/pull/16144/commits/7860c98bd59cd8f56e9b2b4ae45265c046e7cfd9 Tree-SHA512: d0cc40efd303a00d0b4d3cb2de59d8d2d7dd35647e7f3fe9d4a8986589499c1f567c5780c83a129e1ab8dbe601279c459c6ebce3b48b1d81d47a28616ef4a369
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcwallet.cpp4
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.");
}