I've looked through the various questions and answers regarding this topic but I can't find the answers to mine.

I lost access to my wallet since calling encryptwallet which crashed the bitcoin software. I did many scans with all the tools available on github and also some that I wrote.

My wallet contains 4 masterkeys (m path) of which 2 can be decrypted with the password of the wallet and contains more than 1500 addresses. Only around 200 can be decrypted with the password.

I found the xpriv for these two decrypted masterkeys by importing them into bitcoin core with the sethdseed function.

I found in the hexadecimal chains of the portfolio 20 addresses which have not been encrypted and of which I therefore know the private key, the encrypted key, the pub key, the derivation.

I can't find any way to find the xpub of the other two mastrkeys which will have allowed me to find all the other private keys. The Chaincode is missing and can't find it in wallet.dat.

I tried to modify the Bitcoin code to convert according to the same logic as for the WIF key import but without success.

My questions are:

  • Is there a way to convert the public key like I did for the private key?
  • Can I find the sibling keys with the amount of private keys that I have recovered?
  • Do you see another way to recover my funds?

I anticipate a generous reward. Thank You

  • You seem to know what you are doing but don't mention backups. Is there some problem with backup recovery we need to know about to avoid the same issue? Aug 26, 2022 at 11:16
  • I only have the wallet.dat and the end of the debug.log, to avoid the same problem, never start encryptwallet without having a local copy of your wallet. Also the crash occurs when a large number of keys are present in the wallet. I don't know this so well, I've been trying to recover my wallet for 1 year, I've read a lot of subject since all this time. Thanks for your help
    – Maxbird
    Aug 26, 2022 at 11:22
  • how would finding the xpub allow you find all other private keys?
    – Mike D
    Aug 26, 2022 at 14:10
  • I invite you to consult this post where everything is much better explained than I could do. bitcoin.stackexchange.com/questions/56916/…
    – Maxbird
    Aug 26, 2022 at 16:16

1 Answer 1


From what you've stated, there is no way to recover those private keys.

Bitcoin Core's wallet does not store xpubs, or even xprvs. It derives the private keys as needed from the seed. Furthermore, for the type of wallet you are using, Bitcoin Core uses exclusively hardened derivation, so the vulnerability you are referring to does not apply.

Additionally, it sounds like your wallet is in a state that should not occur. The wallet encryption for Bitcoin Core was specifically written to avoid having both encrypted and unencrypted data in the wallet. If encryption fails, it's supposed to crash which should force the database to revert to its previous state with nothing encrypted. It may be that you are looking at only the database file and not also with the database journal which can contain additional data (although it's supposed to be that the journal contains the encrypted data and the db only what is committed, and if it crashed, then the data was not committed).

However if you are looking at the database with it's journal, then you might also be looking at it in the uncommitted state and unencrypted keys are not actually deleted, just hidden as they are marked for deletion, but not yet actually deleted.

  • Thank you Andrew for taking the time to answer my questions so precisely, I do not have the database of this wallet having no knowledge of cryptographic blockchain at the time. The branch paths are m/0'/0'/n+'. The software version was 0.18. The wallet crashed because there was a maxrpctime argument of 10 seconds I think. I found the tool gist.github.com/fivepiece/e3293733d99c4935332f8c5959d7472b
    – Maxbird
    Aug 27, 2022 at 1:07
  • I had another wallet.bak in the directory, and the encrypted mkey matches that wallet in my main wallet.dat. It is as if the two wallets had merged. I will look for another solution and try to find out why some keys are not uncrypred. I saw that it was impossible to find the masterkey (Key) with all the other informations (IV, cipher, plain text) in AES-256-CBC. I am not optimistic about recovering the wallet. But again thank you for answering with all your knowledge
    – Maxbird
    Aug 27, 2022 at 1:19

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