2016-04-03 01:21:38 -07:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
2016-06-13 01:06:01 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-07-30 13:53:43 -07:00
|
|
|
process.title = 'bcoin';
|
|
|
|
|
|
2017-06-29 20:54:07 -07:00
|
|
|
const assert = require('assert');
|
2017-07-30 10:41:58 -07:00
|
|
|
const SPVNode = require('../lib/node/spvnode');
|
|
|
|
|
const Outpoint = require('../lib/primitives/outpoint');
|
2016-04-03 01:21:38 -07:00
|
|
|
|
2017-07-30 10:41:58 -07:00
|
|
|
const node = SPVNode({
|
2017-03-10 20:25:00 -08:00
|
|
|
config: true,
|
|
|
|
|
argv: true,
|
|
|
|
|
env: true,
|
2016-07-04 05:36:06 -07:00
|
|
|
logFile: true,
|
2017-03-14 05:16:52 -07:00
|
|
|
logConsole: true,
|
2017-03-08 07:18:53 -08:00
|
|
|
logLevel: 'debug',
|
|
|
|
|
db: 'leveldb',
|
2017-03-14 05:47:12 -07:00
|
|
|
persistent: true,
|
2017-07-07 08:15:10 -07:00
|
|
|
workers: true,
|
2017-03-08 07:18:53 -08:00
|
|
|
listen: true,
|
|
|
|
|
loader: require
|
2016-04-03 01:21:38 -07:00
|
|
|
});
|
|
|
|
|
|
2017-03-14 06:22:43 -07:00
|
|
|
// Temporary hack
|
2017-07-30 10:41:58 -07:00
|
|
|
if (!node.has('walletdb')) {
|
|
|
|
|
const plugin = require('../lib/wallet/plugin');
|
2017-03-14 06:22:43 -07:00
|
|
|
node.use(plugin);
|
2017-07-30 10:41:58 -07:00
|
|
|
}
|
2017-03-14 06:22:43 -07:00
|
|
|
|
2017-06-29 20:54:07 -07:00
|
|
|
process.on('unhandledRejection', (err, promise) => {
|
|
|
|
|
throw err;
|
2016-04-03 01:21:38 -07:00
|
|
|
});
|
|
|
|
|
|
2017-06-29 20:54:07 -07:00
|
|
|
(async () => {
|
2017-06-24 02:37:55 -07:00
|
|
|
await node.ensure();
|
|
|
|
|
await node.open();
|
|
|
|
|
await node.connect();
|
2017-01-14 07:18:47 -08:00
|
|
|
|
2017-03-08 07:18:53 -08:00
|
|
|
if (node.config.bool('test')) {
|
2016-06-03 11:16:26 -07:00
|
|
|
node.pool.watchAddress('1VayNert3x1KzbpzMGt2qdqrAThiRovi8');
|
2017-07-30 10:41:58 -07:00
|
|
|
node.pool.watchOutpoint(new Outpoint());
|
2017-06-29 20:54:07 -07:00
|
|
|
node.on('block', (block) => {
|
2016-07-27 06:28:28 -07:00
|
|
|
assert(block.txs.length >= 1);
|
|
|
|
|
if (block.txs.length > 1)
|
2017-10-26 04:07:36 -07:00
|
|
|
console.log(block.txs[1]);
|
2016-06-03 11:16:26 -07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-03 01:21:38 -07:00
|
|
|
node.startSync();
|
2017-06-29 20:54:07 -07:00
|
|
|
})().catch((err) => {
|
2017-07-17 16:40:16 -07:00
|
|
|
console.error(err.stack);
|
|
|
|
|
process.exit(1);
|
2016-04-03 01:21:38 -07:00
|
|
|
});
|