<p>This behaviour has been resolved by <a href="https://github.com/bitcoin/bitcoin/pull/12493" rel="nofollow noreferrer">12493</a>. As stated by Andrew Chow in the pull request, this was previously done to:</p>

<blockquote>
  <p>...prevent the BDB environment from
  writing unencrypted private keys to disk in the database log files, as
  was noted here. This PR replaces the shutdown behavior with a CDBEnv
  flush, close, and reopen which achieves the same effect: everything is
  cleanly flushed and closed, the log files are removed, and then the
  environment reopened to continue normal operation.</p>
  
  <p>To ensure that no unencrypted private keys are in the log files after
  encrypting the wallet, I wrote this script to pull private keys from
  the original wallet file and searches for these keys in the log files
  (note that you will have to change your file paths to make it work on
  your own machine).</p>
  
  <p>As for concerns about private keys being written to slack space or
  being kept in memory, these behaviors no longer exist after the
  original wallet encryption PR and the shutting down solution from
  2011.</p>
</blockquote>

CC BY-SA 4.0
2018-12-13T14:24:43.517Z
2018-12-13T14:24:43.517Z
Raghav Sood
<p>As mentioned in the <code>bitcoin-cli</code> document for <code>encryptwallet</code> command, bitcoin daemon will shut down after encrypting a new or unencrypted wallet. My question is about the reason for shutting the node down?</p>

<p>Also, I want to create another bitcoin wallet and it's very strange if I need to start after adding a new wallet. <a href="https://github.com/bitcoin/bitcoin/pull/11678" rel="nofollow noreferrer">this pull request</a> tried to remove shutdown after encrypting a wallet. is it safe? and what's the best way to deal with this problem? </p>

<blockquote>
  <p>encryptwallet "passphrase"</p>
  
  <p>Encrypts the wallet with 'passphrase'. This is for first time
  encryption. After this, any calls that interact with private keys such
  as sending or  signing</p>
  
  <p>will require the passphrase to be set prior the making these calls.
  Use the walletpassphrase call for this, and then walletlock call. If
  the wallet is already encrypted, use the walletpassphrasechange call.
  Note that this will shutdown the server.</p>
</blockquote>

<bitcoind><bitcoin-cli><encryption>
Why bitcoind will shutdown after encryptwallet?
Vahid Kharazi
# Why bitcoind will shutdown after encryptwallet?

(Asked by: username_0 on 2018-12-13)

As mentioned in the `bitcoin-cli` document for `encryptwallet` command, bitcoin daemon will shut down after encrypting a new or unencrypted wallet. My question is about the reason for shutting the node down?

Also, I want to create another bitcoin wallet and it's very strange if I need to start after adding a new wallet. [this pull request](https://github.com/bitcoin/bitcoin/pull/11678) tried to remove shutdown after encrypting a wallet. is it safe? and what's the best way to deal with this problem?

> encryptwallet "passphrase"
>
> Encrypts the wallet with 'passphrase'. This is for first time
> encryption. After this, any calls that interact with private keys such
> as sending or signing
>
> will require the passphrase to be set prior the making these calls.
> Use the walletpassphrase call for this, and then walletlock call. If
> the wallet is already encrypted, use the walletpassphrasechange call.
> Note that this will shutdown the server.

**Tags:** bitcoind, bitcoin-cli, encryption


---

## 1 answers

### Answer by username_1 on 2018-12-13. Score: 2 | Accepted answer

This behaviour has been resolved by [12493](https://github.com/bitcoin/bitcoin/pull/12493). As stated by Andrew Chow in the pull request, this was previously done to:

> ...prevent the BDB environment from
> writing unencrypted private keys to disk in the database log files, as
> was noted here. This PR replaces the shutdown behavior with a CDBEnv
> flush, close, and reopen which achieves the same effect: everything is
> cleanly flushed and closed, the log files are removed, and then the
> environment reopened to continue normal operation.
>
> To ensure that no unencrypted private keys are in the log files after
> encrypting the wallet, I wrote this script to pull private keys from
> the original wallet file and searches for these keys in the log files
> (note that you will have to change your file paths to make it work on
> your own machine).
>
> As for concerns about private keys being written to slack space or
> being kept in memory, these behaviors no longer exist after the
> original wallet encryption PR and the shutting down solution from
> 2011.


---

