Author

Topic: Bitcoin Core 0.16 and bech32 (Read 345 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
March 16, 2018, 01:41:29 PM
#11
I think you're right but I the getaddressinfo command does not exist and I can't find a similar command in the list of commands you get by typing help. Do you know what you meant instead?
Right, getaddressinfo was merged for 0.17, not 0.16. It's validateaddress for 0.16.
legendary
Activity: 2324
Merit: 1125
March 16, 2018, 12:12:07 PM
#10
Thank you. Indeed the call is returning iscompresses false.
full member
Activity: 198
Merit: 130
Some random software engineer
March 16, 2018, 10:31:06 AM
#9
I think you're right but I the getaddressinfo command does not exist and I can't find a similar command in the list of commands you get by typing help. Do you know what you meant instead?

I also made a new wallet and can generate bech32 so that also seems to point in the direction of your conclusion. Seems like I'm best off retiring this wallet cause it is encrypted (and generating 100s of addresses doesn't sound like a fun endeavour or a good way to keep an overview of used addresses).

I guess you can try the validateaddress api call:

Code:
$ bitcoin-cli validateaddress 1NNFJhT8mGyQAFF6Sr3sXQmGpmXzhdjrGx
{
  "isvalid": true,
  "address": "1NNFJhT8mGyQAFF6Sr3sXQmGpmXzhdjrGx",
[...]
  "pubkey": "02e1e96545df48f58852e537ec7820b940fea5b4834ed18062456ae126eb1e9d55",
  "iscompressed": true,
  "account": "",
[...}
}

It will only work if you're the owner of the address (ie: have private key), because it is impossible from a single address to know if its public key was compressed or not before hashing it.
legendary
Activity: 2324
Merit: 1125
March 16, 2018, 07:59:41 AM
#8
I think you're right but I the getaddressinfo command does not exist and I can't find a similar command in the list of commands you get by typing help. Do you know what you meant instead?

I also made a new wallet and can generate bech32 so that also seems to point in the direction of your conclusion. Seems like I'm best off retiring this wallet cause it is encrypted (and generating 100s of addresses doesn't sound like a fun endeavour or a good way to keep an overview of used addresses).
staff
Activity: 3374
Merit: 6530
Just writing some code
March 16, 2018, 12:34:26 AM
#7
Get an address from your wallet and go to the debug window. Then type
Code:
validateaddress 

Find the field for
Code:
iscompressed
and tell us what it says. I suspect it will say false.

Since you say that your wallet is old, there's a good chance that you still are using uncompressed public keys which are not allowed by segwit. This has nothing to do with a wallet being non-HD; it just means that you are using a wallet that does not support compressed public keys.

To use compressed public keys (so that you can use segwit), you can upgrade your wallet to use compressed public keys by starting Bitcoin Core with -upgradewallet. Note that this will not make your wallet HD, it will only upgrade it to support compressed public keys. Then you will need to flush and regenerate the keypool. Unfortunately I don't think there's a way to do that right now besides just generating a few hundred addresses. At some point it will start giving you p2sh wrapped addresses instead of legacy addresses as the keypool runs out of the old uncompressed public keys.

If your wallet is not encrypted, you can encrypt it and that will automatically flush and regenerate the keypool for you.

edit: validateaddress, not getaddressinfo
HCP
legendary
Activity: 2086
Merit: 4314
March 15, 2018, 11:55:52 PM
#6
Try shutting down Bitcoin Core, then make a backup of your wallet.dat and rename it to "ORIGINALwallet.dat" or something similar... then start Bitcoin Core so that it creates a new (empty) wallet.dat and see if it creates "bc1" addresses.

It is quite possible that if your wallet is VERY old it is causing the issue... I don't have a wallet that old, so I can't try and replicate it.
legendary
Activity: 2324
Merit: 1125
March 15, 2018, 02:16:03 PM
#5
Just out of curiousity... what version did you upgrade from? and is your wallet an HD wallet? (does the HD icon in the bottom right corner have a X through it or does it say "HD Key generation is enabled" if you hover the mouse over it?)

I ask because if you have an old legacy wallet that isn't HD, it's possible it won't generate the SegWit addresses... It isn't mentioned explicitly in the release notes or anything, I'm just thinking out loud.

I've tried this with my old vintage 2013 non-HD wallet.dat and it produces bech32 addresses without any issues. To answer the OP it should work and I can't reproduce the problem.

Edit:
You can also try from the dubug console:

getnewaddress "" bech32


I keep getting an address with 1... both when I start the client with -addresstype=bech32 and with the command on the debug console.

I do really have a very old wallet.dat (non-HD) so maybe it is not available? (Although that seems to be contradicted above)
hero member
Activity: 2576
Merit: 882
Freebitco.in Support https://bit.ly/2I9BVS2
March 15, 2018, 04:31:50 AM
#4
Just out of curiousity... what version did you upgrade from? and is your wallet an HD wallet? (does the HD icon in the bottom right corner have a X through it or does it say "HD Key generation is enabled" if you hover the mouse over it?)

I ask because if you have an old legacy wallet that isn't HD, it's possible it won't generate the SegWit addresses... It isn't mentioned explicitly in the release notes or anything, I'm just thinking out loud.

I've tried this with my old vintage 2013 non-HD wallet.dat and it produces bech32 addresses without any issues. To answer the OP it should work and I can't reproduce the problem.

Edit:
You can also try from the dubug console:

getnewaddress "" bech32

HCP
legendary
Activity: 2086
Merit: 4314
March 14, 2018, 11:53:51 PM
#3
I upgraded to 0.16 and tried to generate a bech32 address by clicking the request payment button with the "Generate bech32 address" checkbox checked however it simply generates an address starting with 1 and bnot with bc.
Just out of curiousity... what version did you upgrade from? and is your wallet an HD wallet? (does the HD icon in the bottom right corner have a X through it or does it say "HD Key generation is enabled" if you hover the mouse over it?)

I ask because if you have an old legacy wallet that isn't HD, it's possible it won't generate the SegWit addresses... It isn't mentioned explicitly in the release notes or anything, I'm just thinking out loud.
sr. member
Activity: 322
Merit: 363
39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD
March 14, 2018, 03:46:40 PM
#2
it simply generates an address starting with 1 and bnot with bc.
The prefix is actually bc1, not bc.
Post the address generated.
Does it have capital and small letters?
What's the length?
For most Bitcoin addresses their difference is cosmetic: P2PKH (addresses that start with 1) are definitely not Segwit addresses; P2PWPKH addresses (Bech 32 addresses, that start with bc1) are obviously segwit addresses.
The only confusion is in P2SH addresses (those that start with 3), they could be normal P2SH addresses (multisig, usually), or P2WPKH wrapped in P2SH (Segwit addresses).
However the only way to distinguish between them is only when the UTXO is spent, and the redeem script exposed.
Until then it is impossible to distinguish between them.
TL;DR: Segwit addresses start with either '3' or 'bc1'
Quote
  • How is segwit visualized (if at all)? In the transaction screen I see nothing of the sort.
How exactly do you mean?
Segwit works under the hood by reducing transaction size thereby reducing transaction fees.
legendary
Activity: 2324
Merit: 1125
March 14, 2018, 12:27:05 PM
#1
I upgraded to 0.16 and tried to generate a bech32 address by clicking the request payment button with the "Generate bech32 address" checkbox checked however it simply generates an address starting with 1 and bnot with bc.

  • Is this a P2SH wrapped address?
  • If not, how do I generate a bech32 address?
  • If yes, how can I tell the addresses apart in my address book?
  • How is segwit visualized (if at all)? In the transaction screen I see nothing of the sort.

Thanks!
Jump to: