<p>From <a href="https://github.com/bitcoin/bitcoin/blob/master/src/rpcprotocol.h#L34" rel="nofollow">the source code</a> (<code>rpcprotocol.h</code>):</p>

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

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

<pre><code>bitcoind [...] -help | grep walletlock
</code></pre>

<p>The <code>walletlock</code> RPC command becomes only available (in the <code>-help</code> list) after encrypting your wallet.</p>

CC BY-SA 3.0
2014-04-14T05:24:12.177Z
2014-04-14T19:04:26.727Z
2014-04-14T19:04:26.727Z
Jori
<p>How can one check if their wallet is encrypted through the RPC API without receiving an exception?</p>
<p>I went through the <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow noreferrer">Original Bitcoin client API calls list</a> but didn't find any command that could facilitate this functionality without resulting into an error in the response.</p>
<p>Any ideas or workarounds?</p>

<wallet><bitcoind><api><json-rpc><encryption>
Check if wallet is encrypted or not through RPC API
Doug Peters
# Check if wallet is encrypted or not through RPC API

(Asked by: username_0 on 2014-04-14)

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](https://en.bitcoin.it/wiki/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?

**Tags:** wallet, bitcoind, api, json-rpc, encryption


---

## 1 answers

### Answer by username_1 on 2014-04-14. Score: 0 | Accepted answer

From [the source code](https://github.com/bitcoin/bitcoin/blob/master/src/rpcprotocol.h#L34) (`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.


---

