How can one check if their wallet is encrypted through the RPC API without receiving an exception?

I went through the Original Bitcoin client API calls list but didn't find any command that could facilitate this functionality without resulting into an error in the response.

Any ideas or workarounds?

1 Answer 1


From the source code (rpcprotocol.h):

RPC_WALLET_ERROR                = -4,  // Unspecified problem with wallet (key not found etc.)

So you could check for a JSON-RPC return value of -4, or if you want to be absolutely sure, you can use:

bitcoind [...] -help | grep walletlock

The walletlock RPC command becomes only available (in the -help list) after encrypting your wallet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.