<p>The problem is that your wallet version is extremely old - it predates support for compressed public keys (which was added in v0.6.0, released in March 2012). As segwit addresses require compressed public keys, Bitcoin Core is failing with the keys you have, and defaulting to legacy addresses instead.</p>

<p>The solution is restart with <code>-upgradewallet</code> (just once), which will update the wallet to the latest version but break compatibility with old Bitcoin Core versions. Note that you'll need a new backup after doing so.</p>

CC BY-SA 4.0
2020-03-19T18:05:57.893Z
Thank you, Pieter. We have restarted with '-upgradewallet' and now the 'getwalletinfo' command returns this: {
  "walletname": "",
  "walletversion": 169900,
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 2019,
  "keypoololdest": 1584640664,
  "keypoolsize": 195,
  "keypoolsize_hd_internal": 5,
  "paytxfee": 0.00005000,
  "hdseedid": "f68ec1b30d87a265effc2735fcc0bc4aabbbc5f8",
  "private_keys_enabled": true,
  "avoid_reuse": false,
  "scanning": false
}
pferg
CC BY-SA 4.0
2020-03-19T18:06:15.633Z
However, we are still only able to generate addresses that begin with a "1"
pferg
CC BY-SA 4.0
2020-03-19T18:06:23.537Z
And is the problem solved?
Pieter Wuille
CC BY-SA 4.0
2020-03-19T18:11:09.833Z
Ah, it may be the case that your keypool still has uncompressed public keys which you need to cycle through (running getnewaddress 100 times should do it). Make backups of wallet.dat frequently
Pieter Wuille
CC BY-SA 4.0
2020-03-19T18:20:03.833Z
Hello Pieter - you were right. We had to run 'getnewaddress' about 85 times and then the bech32 address just started to appear. Thank you you are a true hero of Bitcoin.
pferg
CC BY-SA 4.0
2020-03-19T17:52:01.103Z
2020-03-19T17:52:01.103Z
Pieter Wuille
<p>We are only able to generate "legacy" addresses that begin with a "1". This is a long standing problem generating new addresses using bitcoind and has persisted through a few recent versions of bitcoin core.</p>

<p>This might be a possible bug in bitcoind 64-bit linux.</p>

<p>We are currently running core 19.1 taken from here: <a href="https://bitcoincore.org/bin/bitcoin-core-0.19.1/" rel="nofollow noreferrer">https://bitcoincore.org/bin/bitcoin-core-0.19.1/</a></p>

<p>And our linux version is: Ubuntu 18.04.3 LTS x86_64</p>

<p>We have "addresstype=bech32" set in our bitcoin.conf.</p>

<p>Has anyone else seen this problem before?</p>

<p>Here is our bitcoin.conf:</p>

<pre><code>addnode=**.***.***.***

server=1

rpcport=****

walletnotify=/btc_notify.sh %s

# OpenSSL settings used when rpcssl=1
rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH
rpcsslcertificatechainfile=server.cert
rpcsslprivatekeyfile=server.pem

gen=0

keypool=100

paytxfee=0.00005000

addresstype=bech32
</code></pre>

<p>And here is an example of how the problem manifests itself:</p>

<p><a href="https://i.sstatic.net/Tb0Fi.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Tb0Fi.jpg" alt="enter image description here"></a></p>

CC BY-SA 4.0
2020-03-19T17:09:24.800Z
How old is the wallet file? As in, when was it first created?
Pieter Wuille
CC BY-SA 4.0
2020-03-19T17:27:53.310Z
Also, can you post the output of the `getwalletinfo` command (specifically, its walletversion field).
Pieter Wuille
CC BY-SA 4.0
2020-03-19T17:46:30.857Z
And as a side-note, the rpcssl settings have been removed years ago, you might be best off removing them from your config as well.
user2084795
CC BY-SA 4.0
2020-03-19T17:47:15.887Z
As for the age of the wallet file, we had to restart bitcoind today, and when we run "stat wallet.dat" we are getting access and modification dates for today. However, this full node has been running since at least 2013 and that's when it was likely originally created.
pferg
CC BY-SA 4.0
2020-03-19T17:48:20.867Z
{
  "walletname": "",
  "walletversion": 10500,
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 2019,
  "keypoololdest": 1583432175,
  "keypoolsize": 99,
  "paytxfee": 0.00005000,
  "private_keys_enabled": true,
  "avoid_reuse": false,
  "scanning": false
}
pferg
<bitcoind>
getnewaddress won't generate bech32 or p2sh-segwit addresses
pferg
# getnewaddress won't generate bech32 or p2sh-segwit addresses

(Asked by: username_0 on 2020-03-19)

We are only able to generate "legacy" addresses that begin with a "1". This is a long standing problem generating new addresses using bitcoind and has persisted through a few recent versions of bitcoin core.
This might be a possible bug in bitcoind 64-bit linux.
We are currently running core 19.1 taken from here: https://bitcoincore.org/bin/bitcoin-core-0.19.1/
And our linux version is: Ubuntu 18.04.3 LTS x86_64
We have "addresstype=bech32" set in our bitcoin.conf.
Has anyone else seen this problem before?
Here is our bitcoin.conf:
addnode=**.***.***.***

server=1

rpcport=****

walletnotify=/btc_notify.sh %s

# OpenSSL settings used when rpcssl=1
rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH
rpcsslcertificatechainfile=server.cert
rpcsslprivatekeyfile=server.pem

gen=0

keypool=100

paytxfee=0.00005000

addresstype=bech32

And here is an example of how the problem manifests itself:

**Tags:** bitcoind

> **Comments:**
> **username_1**: How old is the wallet file? As in, when was it first created?  
> **username_1**: Also, can you post the output of the `getwalletinfo` command (specifically, its walletversion field).  
> **username_2**: And as a side-note, the rpcssl settings have been removed years ago, you might be best off removing them from your config as well.  
> **username_0**: As for the age of the wallet file, we had to restart bitcoind today, and when we run "stat wallet.dat" we are getting access and modification dates for today. However, this full node has been running since at least 2013 and that's when it was likely originally created.  
> **username_0**: {   "walletname": "",   "walletversion": 10500,   "balance": 0.00000000,   "unconfirmed_balance": 0.00000000,   "immature_balance": 0.00000000,   "txcount": 2019,   "keypoololdest": 1583432175,   "keypoolsize": 99,   "paytxfee": 0.00005000,   "private_keys_enabled": true,   "avoid_reuse": false,   "scanning": false }  

---

## 1 answers

### Answer by username_1 on 2020-03-19. Score: 3 | Accepted answer

The problem is that your wallet version is extremely old - it predates support for compressed public keys (which was added in v0.6.0, released in March 2012). As segwit addresses require compressed public keys, Bitcoin Core is failing with the keys you have, and defaulting to legacy addresses instead.

The solution is restart with `-upgradewallet` (just once), which will update the wallet to the latest version but break compatibility with old Bitcoin Core versions. Note that you'll need a new backup after doing so.

> **Comments:**
> **username_0**: Thank you, Pieter. We have restarted with '-upgradewallet' and now the 'getwalletinfo' command returns this: {   "walletname": "",   "walletversion": 169900,   "balance": 0.00000000,   "unconfirmed_balance": 0.00000000,   "immature_balance": 0.00000000,   "txcount": 2019,   "keypoololdest": 1584640664,   "keypoolsize": 195,   "keypoolsize_hd_internal": 5,   "paytxfee": 0.00005000,   "hdseedid": "f68ec1b30d87a265effc2735fcc0bc4aabbbc5f8",   "private_keys_enabled": true,   "avoid_reuse": false,   "scanning": false }  
> **username_0**: However, we are still only able to generate addresses that begin with a "1"  
> **username_1**: And is the problem solved?  
> **username_1**: Ah, it may be the case that your keypool still has uncompressed public keys which you need to cycle through (running getnewaddress 100 times should do it). Make backups of wallet.dat frequently  
> **username_0**: Hello Pieter - you were right. We had to run 'getnewaddress' about 85 times and then the bech32 address just started to appear. Thank you you are a true hero of Bitcoin.  

---

