Error: This wallet has no available keys (code -4) #218

issue chaihahaha opened this issue on February 23, 2021
  1. chaihahaha commented at 4:45 AM on February 23, 2021: none

    <!-- Describe the issue -->

    I created a new empty encrypted wallet and used walletpassphrase to unlock it and used importprivkey to import my private key. Then I found that I still cannot create a new address. After entering getnewaddress, I get the error message "Error: This wallet has no available keys (code -4)".

    <!--- What behavior did you expect? -->

    I expected that I can create a new address.

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    'Create a new receiving address' is greyed out.

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    I used Bitcoin Core v0.21.0 downloaded from bitcoin.org, I got the error message in the console of Bitcoin Core GUI.

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    Windows 10.0.19042, Intel i7-4720HQ, HDD

  2. chaihahaha added the label Bug on Feb 23, 2021
  3. jarolrod commented at 6:33 AM on February 23, 2021: member

    Confirming that I can replicate this issue on master. System: macOS 11.1

    Steps I took to Replicate:

    • Create a new Encrypted wallet with Make Blank Wallet option selected. This option means that the wallet starts out with no private keys and you can add them in later with importprivkey or sethdseed
    • Go over to console and unlock wallet with walletpassphrase "123" 60
    • In console, run: importprivkey <priv_key> "label"
    • Run getnewaddress -> get error: Error: This wallet has no available keys (code -4)

    While importprivkey leads to this error, I can still populate the wallet with a key using sethdseed then subsequently create a new address.

  4. jarolrod commented at 7:17 AM on February 23, 2021: member

    I can also replicate using bitcoind and bitcoin-cli on master, the debug log says I already have this key in pubkey and already have the script. This is the same issue as outlined in https://github.com/bitcoin/bitcoin/issues/16711. Still cannot create a new address with getnewaddress after importing the private key

  5. hebasto commented at 7:39 AM on February 23, 2021: member

    @chaihahaha @jarolrod

    What is the result of the getwalletinfo command?

  6. jarolrod commented at 7:47 AM on February 23, 2021: member

    @hebasto After importing a valid private key with importprivkey the keypoolsize is 0:

    {
      "walletname": "new-wallet",
      "walletversion": 169900,
      "format": "bdb",
      "balance": 0.00000000,
      "unconfirmed_balance": 0.00000000,
      "immature_balance": 0.00000000,
      "txcount": 0,
      "keypoololdest": 1614066198,
      "keypoolsize": 0,
      "keypoolsize_hd_internal": 0,
      "paytxfee": 0.00000000,
      "private_keys_enabled": true,
      "avoid_reuse": false,
      "scanning": false,
      "descriptors": false
    }
    

    after running sethdseed, it successfully populates with a private key:

    
    {
      "walletname": "new-wallet",
      "walletversion": 169900,
      "format": "bdb",
      "balance": 0.00000000,
      "unconfirmed_balance": 0.00000000,
      "immature_balance": 0.00000000,
      "txcount": 0,
      "keypoololdest": 1614066274,
      "keypoolsize": 1000,
      "hdseedid": "114871bad9b02312f198bbd5ebd852ae0614b855",
      "keypoolsize_hd_internal": 1000,
      "paytxfee": 0.00000000,
      "private_keys_enabled": true,
      "avoid_reuse": false,
      "scanning": false,
      "descriptors": false
    }
    
    
  7. hebasto commented at 7:51 AM on February 23, 2021: member

    I can also replicate using bitcoind and bitcoin-cli on master...

    This issue should be posted in the main repo, I think.

  8. jarolrod commented at 8:10 AM on February 23, 2021: member

    This can be closed in favor of https://github.com/bitcoin/bitcoin/issues/21275

  9. MarcoFalke closed this on Feb 23, 2021

  10. bitcoin-core locked this on Aug 16, 2022
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-29 09:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me