namecoin / electrum-nmc

Namecoin port of Electrum Bitcoin client.
https://www.namecoin.org/
MIT License
29 stars 24 forks source link

Add regression test for ambiguous P2PKH/Bech32 addresses #276

Open JeremyRand opened 3 years ago

JeremyRand commented 3 years ago

Is your feature request related to a problem? Please describe.

It is possible to construct valid P2PKH addresses that look like Bech32 addresses, e.g. NC138Dg9crt4QWaZTUYLtLdwCRGqxzKkmn. (This is an actual address from the Namecoin blockchain.) Trying to parse these addresses under the assumption that a case-insensitive NC1 prefix implies Bech32 will result in a Bech32 parsing failure. I don't think we have any regression tests to make sure that this is handled sanely. (Or maybe we do but I never saw them?)

Describe the solution you'd like

We should have a regression test that tries to parse the above address, and verifies that it is treated as P2PKH. (This may be slightly tricky, since the prefix only collides on mainnet.)

Describe alternatives you've considered

N/A.

Additional context

Also see the Namecoin Core bug, https://github.com/namecoin/namecoin-core/issues/410