<blockquote>
  <p>I then set <code>keypool</code> to <code>false</code> and <code>internal</code> to <code>true</code>:</p>
</blockquote>

<p>This is what you are doing wrong.</p>

<p>Bitcoin Core has a separate change keypool. By not setting <code>keypool</code> to <code>true</code>, the imported pubkeys won't be added to the change keypool.</p>

CC BY-SA 4.0
2019-06-21T02:52:46.060Z
Thank you, for some reason I thought the two were mutually exclusive. Just found your gist on how to use bitcoin core with a hardware wallet, it is exactly what I have been looking for. For anyone else here is the link: https://gist.github.com/achow101/a9cf757d45df56753fae9d65db4d6e1d
Fontaine
CC BY-SA 4.0
2019-06-21T01:25:59.763Z
2019-06-21T01:25:59.763Z
Ava Chow
<p>First I call:</p>

<pre><code>curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "createwallet", "params":["ColdWallet", true] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:18332/
</code></pre>

<p>Which returns:</p>

<pre><code>result = {
    name = ColdWallet;
    warning = "";
}
</code></pre>

<p>I then import keys to the keypool:</p>

<pre><code>bitcoin-cli getdescriptorinfo "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)"

responseString = {

  "descriptor": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5",
  "isrange": true,
  "issolvable": true,
  "hasprivatekeys": false

}

bitcoin-cli -rpcwallet=ColdWallet importmulti '[{ "desc": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'

result = (
        {
        success = 1;
    }
)

</code></pre>

<p>I then set <code>keypool</code> to <code>false</code> and <code>internal</code> to <code>true</code>:</p>

<pre><code>bitcoin-cli -rpcwallet=ColdWallet importmulti '[{ "desc": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5", "timestamp": "now", "range": [100, 199], "watchonly": true, "keypool": false, "internal": true, "rescan": false }]'

result = (
        {
        success = 1;
    }
)
</code></pre>

<p>I can use <code>getnewaddress -rpcwallet=ColdWallet</code> without issue but if I try:</p>

<pre><code>curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "walletcreatefundedpsbt", "params":[[],[{"mxV3ojsAHKuYHoDVqYczs6iPAfCCYESEDc":0.0001}]] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:18332/wallet/ColdWallet

result = {

    error =     {
        code = "-4";
        message = "Can't generate a change-address key. No keys in the internal keypool and can't generate any keys.";
    };
    id = curltest;
    result = "&lt;null&gt;";

}
</code></pre>

<p>Furthermore calling <code>bitcoin-cli rpcwallet=ColdWallet getwalletinfo</code></p>

<p>returns:</p>

<pre><code>{
  "walletname": "ColdWallet",
  "walletversion": 169900,
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 1,
  "keypoololdest": 1561077339,
  "keypoolsize": 98,
  "keypoolsize_hd_internal": 0,
  "paytxfee": 0.00000000,
  "private_keys_enabled": false
}
</code></pre>

<p>Is this a bug? Or am I doing something wrong?</p>

<p>I am using Bitcoin Core as a back end for an app I am developing and want the user to easily be able to create cold transactions using the keys they import into the wallet without having to specify a change address every time.</p>

<bitcoin-core><json-rpc><bitcoin-cli>
Using importmulti with internal set to true does not add any change keys. What am I doing wrong?
Fontaine
# Using importmulti with internal set to true does not add any change keys. What am I doing wrong?

(Asked by: username_0 on 2019-06-21)

First I call:

```
curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "createwallet", "params":["ColdWallet", true] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:18332/

```

Which returns:

```
result = {
    name = ColdWallet;
    warning = "";
}

```

I then import keys to the keypool:

```
bitcoin-cli getdescriptorinfo "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)"

responseString = {

  "descriptor": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5",
  "isrange": true,
  "issolvable": true,
  "hasprivatekeys": false

}

bitcoin-cli -rpcwallet=ColdWallet importmulti '[{ "desc": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'

result = (
        {
        success = 1;
    }
)

```

I then set `keypool` to `false` and `internal` to `true`:

```
bitcoin-cli -rpcwallet=ColdWallet importmulti '[{ "desc": "wpkh(tpubDFLL8VNUhpLNVLw8179WCEuMZtKtTDd7EeYeFDtThzisj6wfJ4Zi43qUvCE7ciCFxVKZYssRr9P9PerLefkVEjKL6CphUvbGv1CrSCS2KUB/*)#udrnh6f5", "timestamp": "now", "range": [100, 199], "watchonly": true, "keypool": false, "internal": true, "rescan": false }]'

result = (
        {
        success = 1;
    }
)

```

I can use `getnewaddress -rpcwallet=ColdWallet` without issue but if I try:

```
curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "walletcreatefundedpsbt", "params":[[],[{"mxV3ojsAHKuYHoDVqYczs6iPAfCCYESEDc":0.0001}]] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:18332/wallet/ColdWallet

result = {

    error =     {
        code = "-4";
        message = "Can't generate a change-address key. No keys in the internal keypool and can't generate any keys.";
    };
    id = curltest;
    result = "<null>";

}

```

Furthermore calling `bitcoin-cli rpcwallet=ColdWallet getwalletinfo`

returns:

```
{
  "walletname": "ColdWallet",
  "walletversion": 169900,
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 1,
  "keypoololdest": 1561077339,
  "keypoolsize": 98,
  "keypoolsize_hd_internal": 0,
  "paytxfee": 0.00000000,
  "private_keys_enabled": false
}

```

Is this a bug? Or am I doing something wrong?

I am using Bitcoin Core as a back end for an app I am developing and want the user to easily be able to create cold transactions using the keys they import into the wallet without having to specify a change address every time.

**Tags:** bitcoin-core, json-rpc, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2019-06-21. Score: 1 | Accepted answer

> I then set `keypool` to `false` and `internal` to `true`:

This is what you are doing wrong.

Bitcoin Core has a separate change keypool. By not setting `keypool` to `true`, the imported pubkeys won't be added to the change keypool.

> **Comments:**
> **username_0**: Thank you, for some reason I thought the two were mutually exclusive. Just found your gist on how to use bitcoin core with a hardware wallet, it is exactly what I have been looking for. For anyone else here is the link: https://gist.github.com/achow101/a9cf757d45df56753fae9d65db4d6e1d  

---

