Segwit address creation

5

3

I'm unable to create a segwit address in Bitcoin Core 15.0.1 64-bit Windows I have tried multiple times but keep getting the same error. The following is the output from the console

$ getnewaddress
1KxN5zBSMqCiMfaXpbgpbDipo3fdrWmWnF
$ addwitnessaddress 1KxN5zBSMqCiMfaXpbgpbDipo3fdrWmWnF
Public key or redeemscript not known to wallet, or the key is uncompressed (code -4)

I have also tried changing my encryption password but it did not help. I do not want to create a whole new wallet. What else can I do? Thanks

Patrick Brusky

Posted 2017-10-20T23:01:43.260

Reputation: 51

Can you post the output of the getwalletinfo command? The address likely corresponds to an uncompressed public key so it cannot be witnessified.Andrew Chow 2017-10-21T00:19:10.590

Answers

5

Your wallet is probably old enough that uncompressed public keys are used instead of compressed public keys. Segwit only works with compressed public keys so you cannot currently use segwit with your addresses.

However you can upgrade your wallet to using compressed keys. To do so, first start Bitcoin Core with the -upgradewallet option. That will upgrade your wallet to use compressed keys by default. Then you will need to call getnewaddress ~1000 times in order to get to addresses using compressed public keys keys. I don't believe that there is a way to regenerate the keypool without emptying it by requesting all of the addresses from the keypool.

Andrew Chow

Posted 2017-10-20T23:01:43.260

Reputation: 40 910

Yes my wallet is from 2012. So the "getnewaddress" command will give me about 1000 receive address. Is there a way to delete some of my receive address? Thanks for you replayPatrick Brusky 2017-10-21T01:29:12.747

No, addresses cannot be deleted.Andrew Chow 2017-10-21T01:30:14.177

Seems like it would be best if I would backup my wallet.dat and delete form the from "C:\Users\user\AppData\Roaming\Bitcoin" folder and have it create a new one. The new then should be able to create segwit address.Patrick Brusky 2017-10-21T01:54:44.007

Yes. You can move all of your coins there by getting some addresses from the new wallet and sending your Bitcoin to those addresses from your old wallet. This also has the benefit of migrating your wallet to the HD wallet type where one backup can theoretically backup all of your private keys ever, although periodic backups are still recommended.Andrew Chow 2017-10-21T02:33:17.473