-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wallet] Reopen CDBEnv after encryption instead of shutting down #2648
[wallet] Reopen CDBEnv after encryption instead of shutting down #2648
Conversation
According to the BerkeleyDB docs, the DbEnv handle may not be accessed after close() has been called. This change ensures that we create a new handle after close() is called. This avoids a segfault when the first connection attempt fails and then a second connection attempt tries to call open() on the already closed DbEnv handle.
Instead of having the object destroy itself, having the caller destroy it.
Adds a ReloadDbEnv function to BerkeleyEnvironment in order to close all Db instances, closes the environment, resets it, and then reopens the BerkeleyEnvironment. Also adds a ReloadDbEnv function to BerkeleyDatabase that calls BerkeleyEnvironment's ReloadDbEnv.
Calls ReloadDbEnv after encrypting the wallet so that the database environment is flushed, closed, and reopened to prevent unencrypted keys from being saved on disk.
Since the database environment is flushed, closed, and reopened during EncryptWallet, there is no need to shut down the software anymore. Adaptation of btc@c1dde3a949b36ce9c2155777b3fa1372e7ed97d8
7af11b3
to
6e03bf2
Compare
dd111b8
to
3d8f54f
Compare
Took me a while to find the problem, ready now. |
87e56e2
to
28d17a1
Compare
There are tests, like the ones that uses the wallet encryption, that need access to a real wallet database and not to a mock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK c5340ec
maybe unrelated, but when doing this via the GUI with an already large wallet, the animation screen didn't fully load, so the wallet could be perceived as "frozen"/"unresponsive", but the process did eventually finish...so some follow-up may be needed. A smaller wallet did not display this issue.
yep, unrelated to this change. Could work on it on a follup-up work for sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK c5340ec
An improvement for the wallet UX: Stop requiring a wallet shutdown after the initial encryption. Now the process can safely continue running without any fear of leaking unencrypted keys.
PRs backported from upstream: