Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

TypeError: Address has mismatched network type. #247

Open
saritvakrat opened this issue Jul 16, 2018 · 1 comment
Open

TypeError: Address has mismatched network type. #247

saritvakrat opened this issue Jul 16, 2018 · 1 comment

Comments

@saritvakrat
Copy link

Running insight to getUnspentUtxos for a testnet address shows the following error:
throw new TypeError('Address has mismatched network type.'); ^TypeError: Address has mismatched network type.

Code:
var Insight = require('bitcore-explorers').Insight; var insight = new Insight('testnet'); return insight.getUnspentUtxos(address, function (err, utxos) { if (err) { console.err(err) } console.log(utxos); });
Calling it with a testnet address

Code for testnet address:
let privateKey = new bitcore.PrivateKey(), hexa = privateKey.toString(), publicKey = new bitcore.PublicKey(privateKey); address = new bitcore.Address(publicKey, Networks.testnet);

@Divyesh-mi
Copy link

Divyesh-mi commented Jul 16, 2018

Hello @ActoMatics, Please try below code for generate address

const bitcore = require('bitcore-lib');
let value = new Buffer('*Unique string.....');
                    let hash = bitcore.crypto.Hash.sha256(value);
                    let bn = bitcore.crypto.BN.fromBuffer(hash);
                    let privateKey = new bitcore.PrivateKey(bn,'testnet');
                    let address = privateKey.toAddress();                   
                    addressArr.address = address.toString();
                    resolve(addressArr);

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

No branches or pull requests

2 participants