#!/usr/bin/env node

'use strict';

process.title = 'bcoin';

var bcoin = require('../');
var plugin = require('../lib/wallet/plugin');
var co = bcoin.co;
var node;

node = new bcoin.fullnode({
  config: true,
  argv: true,
  env: true,
  logFile: true,
  logConsole: true,
  logLevel: 'debug',
  db: 'leveldb',
  persistent: true,
  listen: true,
  loader: require
});

// Temporary hack
if (!node.has('walletdb'))
  node.use(plugin);

node.on('error', function(err) {
  ;
});

co.spawn(function *() {
  yield node.ensure();
  yield node.open();
  yield node.connect();
  node.startSync();
}).catch(function(err) {
  throw err;
});
