itns-sidechain/bin/spvnode

54 lines
987 B
Text
Raw Normal View History

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-01-14 07:18:47 -08:00
var assert = require('assert');
2016-07-04 05:36:06 -07:00
var bcoin = require('../');
var plugin = require('../lib/wallet/plugin');
2016-11-19 14:33:18 -08:00
var util = bcoin.util;
2017-01-14 07:18:47 -08:00
var co = bcoin.co;
var node;
2016-04-03 01:21:38 -07:00
node = bcoin.spvnode({
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,
logLevel: 'debug',
db: 'leveldb',
persistent: true,
listen: true,
loader: require
2016-04-03 01:21:38 -07:00
});
// Temporary hack
if (!node.has('walletdb'))
node.use(plugin);
2016-04-03 01:21:38 -07:00
node.on('error', function(err) {
2016-07-04 05:36:06 -07:00
;
2016-04-03 01:21:38 -07:00
});
2017-01-14 07:18:47 -08:00
co.spawn(function *() {
yield node.ensure();
2017-01-14 07:18:47 -08:00
yield node.open();
yield node.connect();
if (node.config.bool('test')) {
2016-06-03 11:16:26 -07:00
node.pool.watchAddress('1VayNert3x1KzbpzMGt2qdqrAThiRovi8');
2017-01-14 07:18:47 -08:00
node.pool.watchOutpoint(new bcoin.outpoint());
node.on('block', function(block) {
assert(block.txs.length >= 1);
if (block.txs.length > 1)
2016-11-19 14:33:18 -08:00
util.log(block.txs[1]);
2016-06-03 11:16:26 -07:00
});
}
2016-04-03 01:21:38 -07:00
node.startSync();
2017-01-14 07:18:47 -08:00
}).catch(function(err) {
throw err;
2016-04-03 01:21:38 -07:00
});