bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.6k stars 2.08k forks source link

Version code of address did not match acceptable versions for network #1196

Closed mmick66 closed 5 years ago

mmick66 commented 5 years ago

I am trying to generate an address as:

import bitcoin from 'bitcoinjs-lib';
import bip39 from 'bip39';

const mnemonic = bip39.generateMnemonic();
const seed = bip39.mnemonicToSeed(mnemonic);

const master = bitcoin.HDNode.fromSeedBuffer(seed, bitcoin.networks.testnet);
const derived = master.derivePath(Wallet.Defaults.Path);
const address = derived.getAddress();

but the resulting address is not validated by blockchain.info. When I try to query it I get

Version code of address did not match acceptable versions for network.

The address generated in your test cases gets the same error.

dabura667 commented 5 years ago

This site is for testnet. https://testnet.smartbit.com.au/address/mubSzQNtZfDj1YdNP6pNDuZy6zs6GDn61L

This site is for mainnet. https://www.blockchain.com/btc/address/1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64

Your code generates the testnet address because you passed bitcoin.networks.testnet

mmick66 commented 5 years ago

I know I am generating testnet, it was my intention. What happened with blockchain.info? It seems there is a versioning problem or something. When I enter a random address (invalid) I get a proper error message while when I use the library to generate a testnet address I get the error I pasted above. Seems they are operating under different assumptions.

dabura667 commented 5 years ago

so your issue is with blockchain dot com.

please contact their support.

dcousens commented 5 years ago

@dabura667 is right, this isn't our issue. But in the interest of making everyones life simpler.

You wanted https://testnet.blockchain.info/

Try https://testnet.blockchain.info/address/mubSzQNtZfDj1YdNP6pNDuZy6zs6GDn61L