Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bech32 addresses for testnet and mainnet #61

Closed
mbnissen opened this issue Feb 18, 2019 · 4 comments
Closed

Bech32 addresses for testnet and mainnet #61

mbnissen opened this issue Feb 18, 2019 · 4 comments

Comments

@mbnissen
Copy link

https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki

As stated here bech32 address uses "bc" for mainnet and "tb" for testnet.

This library marks both to be valid in both testnet and mainnet

@valyakin
Copy link

Yes, I faced the same problem

@crabvk
Copy link

crabvk commented Oct 23, 2019

That's because of

function isValidAddress(address, hrp) {
var hrp = hrp || 'bc';
var ret = decode(hrp, address);
if (ret === null) {
hrp = 'tb';
ret = decode(hrp, address);
}
if (ret === null) {
return false;
}
var recreate = encode(hrp, ret.version, ret.program);
return recreate === address.toLowerCase();
}

which tries both prefixes, bc and tb.

@crabvk
Copy link

crabvk commented Oct 23, 2019

Also, I think we should check address prefix before making any further calculations.

@jonathascarrijo
Copy link

#70 seems to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants