itns-sidechain/bin/spvnode

44 lines
762 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';
2016-07-04 05:36:06 -07:00
var bcoin = require('../');
2016-04-03 01:21:38 -07:00
var utils = bcoin.utils;
var assert = utils.assert;
2016-07-29 15:40:39 -07:00
var options = bcoin.config({
config: true,
arg: true,
env: true,
2016-07-04 05:36:06 -07:00
logLevel: 'debug',
logFile: true,
2016-07-29 15:40:39 -07:00
db: 'leveldb'
2016-04-03 01:21:38 -07:00
});
2016-07-29 15:40:39 -07:00
bcoin.set(options);
var node = bcoin.spvnode(options);
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
});
node.open(function(err) {
if (err)
throw err;
2016-06-03 11:16:26 -07:00
if (process.argv.indexOf('--test') !== -1) {
node.pool.watchAddress('1VayNert3x1KzbpzMGt2qdqrAThiRovi8');
node.pool.watch(bcoin.outpoint().toRaw());
node.on('block', function(block) {
assert(block.txs.length >= 1);
if (block.txs.length > 1)
utils.log(block.txs[1]);
2016-06-03 11:16:26 -07:00
});
}
2016-04-03 01:21:38 -07:00
node.startSync();
});