Error: Unknown network starting a bcoin node

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();

})();

arshbot

Posted 2017-11-28T23:12:02.763

Reputation: 753

Answers

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
))();

arshbot

Posted 2017-11-28T23:12:02.763

Reputation: 753

1

bcoin.network.get().toString()

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

tuxcanfly

Posted 2017-11-28T23:12:02.763

Reputation: 365

Even changing the network to testnet didn't workarshbot 2017-12-03T03:11:03.890