elements icon indicating copy to clipboard operation
elements copied to clipboard

getnewaddress generates invalid bech32 addresses in regtest

Open Sosthene00 opened this issue 3 years ago • 5 comments

Expected behavior

When calling getnewaddress and then getaddressinfo on the newly generated address, it should work and return the address info, not an error.

Actual behavior

getaddressinfo returns:

error code: -5
error message:
Invalid address

but only for bech32 addresses and apparently only in regtest chain. Legacy and p2sh-segwit seems to work fine.

To reproduce

Just starts a fresh node in regtest mode, and type the 2 commands.

System information

Tried on 2 different machines with elements 0.18.1.7 and 0.18.1.12:

  1. Linux sosthene01 5.13.0-28-generic # 31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  2. Linux sosthene02 5.13.0-27-generic # 29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Sosthene00 avatar Feb 15 '22 23:02 Sosthene00

are you using either liquidregtest or elementsregtest? regtest is reserved for bitcoin

tiero avatar Feb 16 '22 10:02 tiero

Hi, thanks for the tip ! But I'm a bit confused by a few points nonetheless:

  • According to elementsd help, reserved values for chain are: main, test, regtest, liquidv1, liquidv1test. I tried liquidregtest, elementsregtest and liquidv1test, and they seem to be pretty much the same at first glance, what are the uses for those different test chains?
  • since regtest is a reserved value for chain, and that iiuc main and test are simply using elements as a bitcoin node, shouldn't regtest be a bitcoin regtest? I think there's something wrong, I can start a chain regtest, it works, it simply doesn't produce valid bech32 addresses

Sosthene00 avatar Feb 16 '22 12:02 Sosthene00

Did you tried using liquidregtest or elementsregtest? those should produce right address

tiero avatar Feb 16 '22 12:02 tiero

Yes I did, it solved the problem for me, sorry it wasn't very explicit in my previous answer.

I just wanted to understand more about the different chains that elements is using.

Beside I suspect that's not the expected behaviour when starting elements with chain=regtest and that maybe it should be corrected, even if obviously it would be a low priority bug.

Sosthene00 avatar Feb 16 '22 12:02 Sosthene00

Not an Elements maintainer so not that fond on the reason here (if there is any, or just a bug)

Glad it solved

tiero avatar Feb 16 '22 14:02 tiero