Unable to get balance with bitcore lib

Unable to get balance with bitcore lib

Using latest version of bitcore lib , want to check balance for making tx but once I include

var explorers =require('bitcore-explorers');

after

var bitcore =require('bitcore-lib');

Error: More than one instance of bitcore-lib found. Please make sure to require bitcore-lib and check that submodules do not also include their own bitcore-lib dependency.
at Object.bitcore.versionGuard (/home/ubuntu/node_modules/bitcore-lib/index.js:12:11)
at Object.<anonymous> (/home/ubuntu/node_modules/bitcore-lib/index.js:15:9)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ubuntu/controllers/bitcoinController.js:8:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at module.exports (/home/ubuntu/routes/apiRoutes.js:5:15)
at Object.<anonymous> (/home/ubuntu/api/server.js:13:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

I had a look at this thread

Bitcore = "Error: More than one instance of bitcore-lib found"

but it does not help . When I comment out this part

var bitcore =require('bitcore-lib');

explorer seem to be running but the problem is it always returns 0 for all the wallets . For instance this wallet has fonds wallet testnet fonds

here is the code

const insight = new explorers.Insight();
insight.getUnspentUtxos('mkFPBvd3jbPYn4223SNTneBWHodziU287G', function(err, utxos) {
    console.log(utxos);
    let balance = 0;
    for (var i = 0; i < utxos.length; i++) {
        balance +=utxos[i]['satoshis'];
    }
    console.log('balance:'+ balance);
});

and response is always [] , 0

1) How to check balance using bitcore without conflict with bitcore-lib ?

2) Which is the "web3" (most commonly used for ethereum) node js library for bitcoin ?

Thanks a lot !

https://ift.tt/2PJWJnr

Comments

Popular posts from this blog

bitcoin node: what is the difference between simnet and regtest?

How to check if Electrum is masking my IP with the Tor proxy?

Need help to recover blpckchain.info wallet, my wife forgot her password and the brute force with btcrecover is not catching the password