1

Getting an error Unknown Network running a bcoin node, but I'm not sure what's causing it since I'm defining the network very quickly.

Error Message:

(node:10579) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unknown network.
(node:10579) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here is the bcoin script

var bcoin = require('bcoin').set('testnet');

(async () => {
  var full = new bcoin.node.FullNode({
    network: bcoin.network.get().toString(),
    httpPort: 18332,
    httpHost: '127.0.0.1',
    bip37: true,
    listen: true,
    passphrase: "secret",
    logLevel: "info",
    loader: require
  });

  if (!full.config.bool('no-wallet') && !full.has('walletdb')) {
    const plugin = require('/Users/<user>/Projects/bcoin/lib/wallet/plugin');
    full.use(plugin);
  }
  await full.open();


  setUpWalletWatcher(full.pool, full.walletdb);
  await full.connect();
  await full.http.open();

  full.startSync();

})();

2 Answers 2

1
bcoin.network.get().toString()

returns main which is not a valid network string, it should be one of mainnet testnet simnet or regtest.

1
  • Even changing the network to testnet didn't work
    – arshbot
    Dec 3, 2017 at 3:11
0

I fixed it by simply instantiating the fullnode object outside of the async block

var full = new bcoin.node.FullNode({
   network: "testnet",
   httpPort: 18332,
   prefix: '~/.bcoin/testnet',
   httpHost: '127.0.0.1',
   bip37: true,
   listen: true,
   workers: true,
   passphrase: "secret",
   logLevel: "info",
   loader: require
});

(async () => {
   //do stuff
))();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.