getnewaddress generates invalid bech32 addresses in regtest

Open
#1,092 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
blockchain

Research direction

Start a fresh node in regtest mode and run getnewaddress followed by getaddressinfo, comparing the generated bech32 address with legacy and p2sh-segwit results. Trace the address parsing and validation path for regtest and add coverage for this reproduction; done means getaddressinfo returns address information instead of Invalid address.

Written by the indexing model from the issue text.

Description

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
Dominant language
C++
Stars
1.2k
Forks
418
Avg merge
1d 12h
Merged PRs (30d)
13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ElementsProject/elements

All issues in ElementsProject/elements

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.