<p>You cannot import private keys to the keypool. This is currently not allowed because it is generally regarded as unsafe, at least with the way that the wallet works today. There is ongoing work to change this in the future.</p>

<p>You could do a split wallet setup where you have a watch only wallet with the pubkeys imported into the keypool and use that for address generation and transaction creation. Then you have a wallet with just the private keys imported and you use that for signing. But that's not what you want.</p>

<p>If you aren't tied to using a BIP 39 seed, you could generate a 256 bit seed and use <code>sethdseed</code> to set the HD seed of a wallet. That would do what you want, but BIP 39 uses 512 bit seeds and not 256, so it won't work there.</p>

<hr>

<p>Imported addresses are never automatically used when you do <code>getnewaddress</code>. When you import them, you need to set <code>keypool: "true"</code> for each imported object for that to work.</p>

CC BY-SA 4.0
2020-01-31T17:31:29.003Z
The problem is that `keypool: true` is `only allowed when wallet private keys are disabled`. but I want to use them, so I don't know how to do that.
eloyesp
CC BY-SA 4.0
2020-02-01T01:32:44.507Z
Oh right. You can't then. The reason that keypool is not allowed for wallets with private keys is that we don't want users to use keys that have been exposed. Imported private keys are considered to be exposed. Importing private keys to the keypool also means that you may be reusing addresses, and we want to avoid that as well.
Ava Chow
CC BY-SA 4.0
2020-02-03T14:40:49.420Z
Could I generate a mnemonic, use it to generate the 512 bit seed, split that seed in two and use the first one on bitcoin core? If I ever lost access to bitcoin core backups, I can use the same procedure to get the same seed, is that correct? does it makes sense?
eloyesp
CC BY-SA 4.0
2020-02-03T17:37:30.473Z
You could do that, but the seed would be useless in any other software.
Ava Chow
CC BY-SA 4.0
2020-01-31T17:05:14.970Z
2020-02-01T01:40:27.743Z
2020-02-01T01:40:27.743Z
Ava Chow
<p>I want to use a mnemonic phrase and BIP 39 to store the keys, and use bitcoin-core, I understand that <a href="https://bitcoin.stackexchange.com/questions/68039/importing-an-arbitrarily-created-master-private-key-to-bitcoin-core">master private keys cannot be imported</a> at least directly and that mnemonic phrase is not supported.</p>

<p>Also, I know that there is the idea of re-think the wallet format of bitcoin core to use <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md" rel="nofollow noreferrer">descriptors</a>, that support key derivation using BIP32.</p>

<p>My idea was to use importmulti to generate a basic usable wallet with some addresses generated from the master account key.</p>

<p>Using <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a> , I've generated a seed and mnemonic:</p>

<pre><code>rebel image use energy write boil throw okay claw
umbrella advice together clarify water actress
</code></pre>

<p>From there I can get the account extended private key (44'/1'/0'):</p>

<p>tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o</p>

<p>From there I can build some descriptors to build usable wallet:</p>

<h2>External</h2>

<pre><code>deriveaddresses "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad" 0
# =&gt; ["myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "tb1qcm233e9h79ntuv4c5mhsvmfhe2umvm0hsgafsf", "2N56BvNBqmkTh1Jic4GbpXSYpbtTNHUdQFw"]
</code></pre>

<h2>Internal</h2>

<pre><code>deriveaddresses "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv" 0
# =&gt; ["tb1q5vgxy6ntsugpdde9ryhst66cz8z4c8ztp4k7qv"]
</code></pre>

<p>To generate the wallet, I've created an empty wallet (as I don't want to depend on backups, just the mnemonic I generated earlier), and import some addresses with <code>importmulti</code>:</p>

<pre><code>createwallet "mnemonic-test" false true
importmulti '[{"desc": "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad", "range": 10, "timestamp": "now"}, {"desc": "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv", "range": 10, "internal": true, "timestamp": "now"}]' '{"rescan": false}'
</code></pre>

<p>It seems to work, all the generated addresses are generated, there is no HD seed enabled (so the addresses are always derived from the mnemonic seed).</p>

<p>The problems I found is that, those addresses, are never used by bitcoin-wallet, when trying to receive bitcoin it says it cannot generate an address (does not try to use one of the already generated addresses) and when spending it says it does not have any internal address available.</p>

<p>Do you know how to enable those coins?</p>

<bitcoin-core><bip32-hd-wallets><mnemonic-seed>
Importing master keys on bitcoin core
eloyesp
# Importing master keys on bitcoin core

(Asked by: username_0 on 2020-01-31)

I want to use a mnemonic phrase and BIP 39 to store the keys, and use bitcoin-core, I understand that [master private keys cannot be imported](https://bitcoin.stackexchange.com/questions/68039/importing-an-arbitrarily-created-master-private-key-to-bitcoin-core) at least directly and that mnemonic phrase is not supported.

Also, I know that there is the idea of re-think the wallet format of bitcoin core to use [descriptors](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md), that support key derivation using BIP32.

My idea was to use importmulti to generate a basic usable wallet with some addresses generated from the master account key.

Using <https://iancoleman.io/bip39/> , I've generated a seed and mnemonic:

```
rebel image use energy write boil throw okay claw
umbrella advice together clarify water actress

```

From there I can get the account extended private key (44'/1'/0'):

tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o

From there I can build some descriptors to build usable wallet:

## External

```
deriveaddresses "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad" 0
# => ["myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "myeHNHuNnbk1aG4WcJNkWw6foM2G64AXGF", "tb1qcm233e9h79ntuv4c5mhsvmfhe2umvm0hsgafsf", "2N56BvNBqmkTh1Jic4GbpXSYpbtTNHUdQFw"]

```

## Internal

```
deriveaddresses "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv" 0
# => ["tb1q5vgxy6ntsugpdde9ryhst66cz8z4c8ztp4k7qv"]

```

To generate the wallet, I've created an empty wallet (as I don't want to depend on backups, just the mnemonic I generated earlier), and import some addresses with `importmulti`:

```
createwallet "mnemonic-test" false true
importmulti '[{"desc": "combo(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/0h/*)#quvrmfad", "range": 10, "timestamp": "now"}, {"desc": "wpkh(tprv8fvSBE7NPnC8FJfBwcptSmmgxhQZhsAbbzRWaLo9d9ystozdV7BFUbRHqvYgL18fnV3WfM4GZb2cLKbLq5H8qZqC9XDnq8Mep3RWXfRsZ7o/1h/*)#6gdaynzv", "range": 10, "internal": true, "timestamp": "now"}]' '{"rescan": false}'

```

It seems to work, all the generated addresses are generated, there is no HD seed enabled (so the addresses are always derived from the mnemonic seed).

The problems I found is that, those addresses, are never used by bitcoin-wallet, when trying to receive bitcoin it says it cannot generate an address (does not try to use one of the already generated addresses) and when spending it says it does not have any internal address available.

Do you know how to enable those coins?

**Tags:** bitcoin-core, bip32-hd-wallets, mnemonic-seed


---

## 1 answers

### Answer by username_1 on 2020-01-31. Score: 1

You cannot import private keys to the keypool. This is currently not allowed because it is generally regarded as unsafe, at least with the way that the wallet works today. There is ongoing work to change this in the future.

You could do a split wallet setup where you have a watch only wallet with the pubkeys imported into the keypool and use that for address generation and transaction creation. Then you have a wallet with just the private keys imported and you use that for signing. But that's not what you want.

If you aren't tied to using a BIP 39 seed, you could generate a 256 bit seed and use `sethdseed` to set the HD seed of a wallet. That would do what you want, but BIP 39 uses 512 bit seeds and not 256, so it won't work there.

---

Imported addresses are never automatically used when you do `getnewaddress`. When you import them, you need to set `keypool: "true"` for each imported object for that to work.

> **Comments:**
> **username_0**: The problem is that `keypool: true` is `only allowed when wallet private keys are disabled`. but I want to use them, so I don't know how to do that.  
> **username_1**: Oh right. You can't then. The reason that keypool is not allowed for wallets with private keys is that we don't want users to use keys that have been exposed. Imported private keys are considered to be exposed. Importing private keys to the keypool also means that you may be reusing addresses, and we want to avoid that as well.  
> **username_0**: Could I generate a mnemonic, use it to generate the 512 bit seed, split that seed in two and use the first one on bitcoin core? If I ever lost access to bitcoin core backups, I can use the same procedure to get the same seed, is that correct? does it makes sense?  
> **username_1**: You could do that, but the seed would be useless in any other software.  

---

