0

I have a problem with my bitcoin wallet recovery process. I have a wallet with thousand of address attached created with RPC method 'getnewaddress'.

I would like to have a recovery process for this wallet and address.

For that, I try to remove the wallet from the node, and import it again by RPC with 'importprivkey'.

The RPC call work, and if I check the main wallet address with 'getaddressinfo', I can see that the address is well realted to the imported wallet.

But, if I do the same with address previously created (before delete and reimported wallet), the 'getaddressinfo' does not link me these address to my wallet.

I think I miss a step on the process, someone of you already made this type of recovery ?

My current process is :

  1. Generating walelt with RPC "createwallet"

  2. Generating hundreds of address with RPC "getnewaddress"

  3. Backup private key of wallet with RPC "dumpprivkey"

  4. Remove wallet dat file from node

  5. Import the previously backuped key with RPC "importprivkey" :

  6. { "method": "importprivkey", "params": [ "cPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXM", "dev_wallet", true ] }

  7. It takes one hour to synchronize because of rescan param to true.

  8. After that, I check the first generated wallet address with RPC "getaddressinfo"

  9. He find the address and link it to my imported wallet.

  10. If I do the same "getaddressinfo" RPC call with another wallet address generated previously generated with RPC "getaddressinfo" (step 2), the node didn't find it.

Thank you in advance,

5
  • Does this answer your question? How to restore a wallet with only the master private key Nov 14, 2023 at 21:46
  • Two wallets really shouldn't affect each other depending on whether they're loaded or not. Can you give the exact sequence of commands you're issuing to reproduce the problem? Nov 14, 2023 at 22:28
  • @PieterWuille It is not exactly two wallets. There is only one wallet with multiple address. I create wallet with "getnewaddress" from RPC for one wallet. After that, I use RPC "dumpprivkey" and "importprivkey", the import works but it only import the main wallet address and not all address crearted with "getnewaddress". Is it more clear for you ?
    – albaokilml
    Nov 15, 2023 at 20:24
  • No, I'm more confused now. There is no such thing as "main wallet address". Please edit your post to include actual commands go reproduce the problem. Nov 15, 2023 at 20:30
  • I added my current testing process.
    – albaokilml
    Nov 15, 2023 at 22:42

2 Answers 2

2

Every address has its own private key; if you inport one key, you get access to that one address.

If your goal is backing up an entire wallet, you should instead be using the dumpwallet and associated importwallet RPC, which produce a human-readable file with all key material in. In theory, you could dump all keys with dumpprivkey, but unless you really know what you're doing, this will likely not give you what you'd think of as a wallet backup. Newly generated addresses won't be reflected in your backup, and any time you send out funds, the change outputs will be sent to internal change addresses which you won't have backups for (they're separate from addresses produced by getnewaddress).

Alternatively, you can use backupwallet which produces a copy of the wallet file itself, which in addition to the above also includes address label information and transaction history.

Lastly, all these individual key-based approaches are unique to the legacy wallet format. In the more modern descriptor based format, there is no way to export individual keys anymore. Instead, you'd use listdescriptors and importdescriptors there, which describe the entire set of addresses controlled by the wallet at once, probably much more in line of how you'd expect exports to work.

2

A hierarchical deterministic (HD) wallet like Bitcoin core generates many private keys from one master private key.

So far as I know dumpprivkey only dumps one of the generated child keys. The one for the specified address.

So if you only import one child key, you have not recovered control over other money received at all your other addresses.

The documentation says

dumpprivkey "address"

Reveals the private key corresponding to 'address'. Then the importprivkey can be used with this output

Arguments:

  1. "address" (string, required) The bitcoin address for the private key

The supported backup method is backupwallet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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