Using importmulti with internal set to true does not add any change keys. What am I doing wrong?

0

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.

Fontaine

Posted 2019-06-21T00:59:49.383

Reputation: 158

Answers

1

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.

Andrew Chow

Posted 2019-06-21T00:59:49.383

Reputation: 40 910

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 2019-06-21T02:52:46.060