<p>Every address has its own private key; if you inport one key, you get access to that one address.</p>
<p>If your goal is backing up an entire wallet, you should instead be using the <code>dumpwallet</code> and associated <code>importwallet</code> RPC, which produce a human-readable file with all key material in. In theory, you could dump all keys with <code>dumpprivkey</code>, but unless you <strong>really</strong> 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 <code>getnewaddress</code>).</p>
<p>Alternatively, you can use <code>backupwallet</code> which produces a copy of the wallet file itself, which in addition to the above also includes address label information and transaction history.</p>
<p>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 <code>listdescriptors</code> and <code>importdescriptors</code> 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.</p>

CC BY-SA 4.0
2023-11-15T23:13:35.993Z
2023-11-15T23:29:07.497Z
2023-11-15T23:29:07.497Z
Pieter Wuille
<p>A hierarchical deterministic (HD) wallet like Bitcoin core generates many private keys from one master private key.</p>
<p>So far as I know <code>dumpprivkey</code> only dumps one of the generated child keys. The one for the specified address.</p>
<p>So if you only import one child key, you have not recovered control over other money received at all your other addresses.</p>
<p>The documentation says</p>
<blockquote>
<p><code>dumpprivkey &quot;address&quot;</code></p>
<p>Reveals the private key corresponding to 'address'. Then the
<code>importprivkey</code> can be used with this output</p>
<p>Arguments:</p>
<ol>
<li>&quot;address&quot;   (string, required) The bitcoin address for the private key</li>
</ol>
</blockquote>
<p>The supported backup method is <a href="https://developer.bitcoin.org/reference/rpc/backupwallet.html" rel="nofollow noreferrer"><code>backupwallet</code></a></p>

CC BY-SA 4.0
2023-11-15T22:48:32.613Z
2023-11-15T22:56:08.670Z
2023-11-15T22:56:08.670Z
RedGrittyBrick
<p>I have a problem with my bitcoin wallet recovery process.
I have a wallet with thousand of address attached created with RPC method 'getnewaddress'.</p>
<p>I would like to have a recovery process for this wallet and address.</p>
<p>For that, I try to remove the wallet from the node, and import it again by RPC with 'importprivkey'.</p>
<p>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.</p>
<p>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.</p>
<p>I think I miss a step on the process, someone of you already made this type of recovery ?</p>
<p>My current process is :</p>
<ol>
<li><p>Generating walelt with RPC &quot;<strong>createwallet</strong>&quot;</p>
</li>
<li><p>Generating hundreds of address with RPC &quot;<strong>getnewaddress</strong>&quot;</p>
</li>
<li><p>Backup private key of wallet with RPC &quot;<strong>dumpprivkey</strong>&quot;</p>
</li>
<li><p>Remove wallet dat file from node</p>
</li>
<li><p>Import the previously backuped key with RPC &quot;<strong>importprivkey</strong>&quot; :</p>
</li>
<li><p>{
&quot;method&quot;: &quot;importprivkey&quot;,
&quot;params&quot;: [
&quot;cPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXM&quot;,
&quot;dev_wallet&quot;,
true
]
}</p>
</li>
<li><p>It takes one hour to synchronize because of rescan param to true.</p>
</li>
<li><p>After that, I check the first generated wallet address with RPC &quot;<strong>getaddressinfo</strong>&quot;</p>
</li>
<li><p>He find the address and link it to my imported wallet.</p>
</li>
<li><p>If I do the same &quot;<strong>getaddressinfo</strong>&quot; RPC call with another wallet address generated previously generated with RPC &quot;<strong>getaddressinfo</strong>&quot; (step 2), the node didn't find it.</p>
</li>
</ol>
<p>Thank you in advance,</p>

CC BY-SA 4.0
2023-11-14T21:46:43.140Z
Does this answer your question? [How to restore a wallet with only the master private key](https://bitcoin.stackexchange.com/questions/116644/how-to-restore-a-wallet-with-only-the-master-private-key)
RedGrittyBrick
CC BY-SA 4.0
2023-11-14T22:28:03.467Z
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?
Pieter Wuille
CC BY-SA 4.0
2023-11-15T20:24:48.887Z
@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
CC BY-SA 4.0
2023-11-15T20:30:23.817Z
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.
Pieter Wuille
CC BY-SA 4.0
2023-11-15T22:42:01.480Z
I added my current testing process.
albaokilml
<bitcoin-core><bitcoind><bitcoin-cli><private-key-import><private-key-export>
Bitcoin node : importprivkey does not import all getnewaddress previously created
albaokilml
# Bitcoin node : importprivkey does not import all getnewaddress previously created

(Asked by: username_0 on 2023-11-14)

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,

**Tags:** bitcoin-core, bitcoind, bitcoin-cli, private-key-import, private-key-export

> **Comments:**
> **username_1**: Does this answer your question? [How to restore a wallet with only the master private key](https://bitcoin.stackexchange.com/questions/116644/how-to-restore-a-wallet-with-only-the-master-private-key)  
> **username_2**: 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?  
> **username_0**: @username_2 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 ?  
> **username_2**: 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.  
> **username_0**: I added my current testing process.  

---

## 2 answers

### Answer by username_2 on 2023-11-15. Score: 2 | Accepted answer

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.


---

### Answer by username_1 on 2023-11-15. Score: 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`](https://developer.bitcoin.org/reference/rpc/backupwallet.html)


---

