The wallet is damaged, I only have the encrypted master private key and password, is it possible to recover the wallet?
-
1Which wallet software application (and version) were you using? – RedGrittyBrick Jan 06 '23 at 10:53
-
Generally a master private key and password sounds good, but it is hard to say more without a bit more background information. – Murch Jan 06 '23 at 13:16
-
@Murch,I am using bitcoin core – nikon Jan 06 '23 at 14:12
-
@Murch, I am asking for help because I am a novice. – nikon Jan 06 '23 at 14:15
-
@RedGrittyBrick ,Using bitcoin core – nikon Jan 06 '23 at 14:16
-
Uh, in the above comment, was that your private key or just an example? I have deleted so that fewer people can see it, and will look to redact it, but I hope you did not just post your private key. – Murch Jan 06 '23 at 14:17
-
@Murch , It's just an example key, do you have a way to retrieve the private key? – nikon Jan 06 '23 at 14:24
-
Ah good. I restored your prior comment. Sorry, I do not know from the top of my head how to restore a wallet just from a single key. I expect that someone will be able to help you out, though – Murch Jan 06 '23 at 14:37
-
The version is not clear, around 2011 bitcoin core – nikon Jan 06 '23 at 14:42
-
How to use this way to restore private key?https://bitcointalk.org/index.php?topic=5093956.0 – nikon Jan 06 '23 at 15:00
-
The master private key is extracted from mine wallet.dat, now wallet.dat is damage and lost, who can help restore private key, can be rewarded – nikon Jan 06 '23 at 15:34
-
@RedGrittyBrick: Only the master private key similar to this example mkey:a978c07e3d05c91a5442ee2f8211e02e011f6abdec8e23032b7eb1298ed661fb9ebcd7388b3963b527a2923cce6800ea like salt:e4aa72cd2bfa00cd iterations: 60435 – nikon Jan 06 '23 at 16:14
3 Answers
The key that you have retrieved from Bitcoin Core is not a master private key. It is the master encryption key for the wallet. This is local to that wallet file only and does not have any relation to the private keys that are used to spend the Bitcoin. If you have only that, there is nothing that can be recovered as the actual private key material is not present.
- 67,209
- 5
- 76
- 149
So far as I can tell, Bitcoin core (as of v23.0) has no obvious facility to import a master private key and use that key as the basis of a hierarchical deterministic (HD) wallet.
It has a facility for importing ordinary private keys of the sort that were generated before implementation of HD key derivation, but I doubt that would do anything useful with a master private key.
As we all know, what Bitcoin Core's developers intended us to do is to use the "Backup Wallet" option in the "File" menu and put copies of that in safe places on other devices. Then restore from one of those backups if the active wallet is damaged or lost.
In the "File" menu under "Create Wallet" there is a checkbox option to "Make Blank Wallet" whose tooltip says
"Blank wallets do not initially have private keys or scripts. Private keys and addresses can be imported, or an HD seed can be set, at a later time".
However I believe you don't have the HD seed, only a master private key derived from such a seed (as I understand it from BIP32).
I suspect that in principle, it is theoretically possible to construct from a master private key, an empty wallet.dat file of the sort that Bitcoin core might create when first run and before it has started an initial blockchain download (IBD) or built any indexes or UTXO sets etc. Then that reconstructed wallet.dat file ought to be usable with Bitcoin core. However I do not know of any tool to do this.
Related:
Importing an arbitrarily created Master Private key to Bitcoin Core
Developer reference for
sethdseedArgument #2 - seed
Type: string, optional, default=random seed
The WIF private key to use as the new HD seed.
The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1
I find this confusing but I think the HD seed and master private key are different things
-
Note: S is not m and HMAC-SHA512 is not reversible
Decrypting encrypted keys:
- How to use OpenSSL to encrypt/decrypt files? especially the answers that mention the
-iter,-saltand-K(key) options. I have not tried this myself. A careful search may reveal other specialised tools more suited to your purpose.
- 24,039
- 3
- 23
- 47
-
Can the primary private key be turned to hdseed? And this primary key hash with the AES256CBC plus SALT and iterations, how to decrypt? – nikon Jan 08 '23 at 06:58
-
@nikon: The BIP32 diagram shows m is derived from S using HMAC-SHA512 which is not reversible. – RedGrittyBrick Jan 08 '23 at 10:00
-
@nikon: to decrypt encrypted data you need any tool that supports the encryption algorithm (AES-256CBC), the parameters you have and the encryption key (for the wallet) – RedGrittyBrick Jan 08 '23 at 10:02
Yes, it is possible to recover (replicate) the wallet if you have a BIP-32 master private key. There is the command: [importdescriptors][1] to use the master key in a wallet in Bitcoin Core. It's not strightforward, though. The master key must be transformed into so-called Output Script Descriptor in order to be accepted by the command.
There are other software packages that will make it easier to use a BIP-32 master private key, e.g. Electrum, Sparrow, https://iancoleman.io/bip39/.
- 305
- 1
- 8
