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

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

    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)”.

    I expected that I can create a new address.

    ‘Create a new receiving address’ is greyed out.

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

    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:

     0{
     1  "walletname": "new-wallet",
     2  "walletversion": 169900,
     3  "format": "bdb",
     4  "balance": 0.00000000,
     5  "unconfirmed_balance": 0.00000000,
     6  "immature_balance": 0.00000000,
     7  "txcount": 0,
     8  "keypoololdest": 1614066198,
     9  "keypoolsize": 0,
    10  "keypoolsize_hd_internal": 0,
    11  "paytxfee": 0.00000000,
    12  "private_keys_enabled": true,
    13  "avoid_reuse": false,
    14  "scanning": false,
    15  "descriptors": false
    16}
    

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

     0
     1{
     2  "walletname": "new-wallet",
     3  "walletversion": 169900,
     4  "format": "bdb",
     5  "balance": 0.00000000,
     6  "unconfirmed_balance": 0.00000000,
     7  "immature_balance": 0.00000000,
     8  "txcount": 0,
     9  "keypoololdest": 1614066274,
    10  "keypoolsize": 1000,
    11  "hdseedid": "114871bad9b02312f198bbd5ebd852ae0614b855",
    12  "keypoolsize_hd_internal": 1000,
    13  "paytxfee": 0.00000000,
    14  "private_keys_enabled": true,
    15  "avoid_reuse": false,
    16  "scanning": false,
    17  "descriptors": false
    18}
    
  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

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: 2024-12-22 02:20 UTC

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