forked from bcoin-org/bcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspvnode
executable file
·59 lines (49 loc) · 1.17 KB
/
spvnode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env node
'use strict';
process.title = 'bcoin';
const assert = require('assert');
const SPVNode = require('../lib/node/spvnode');
const Outpoint = require('../lib/primitives/outpoint');
const node = new SPVNode({
file: true,
argv: true,
env: true,
logFile: true,
logConsole: true,
logLevel: 'debug',
db: 'leveldb',
memory: false,
persistent: true,
workers: true,
listen: true,
loader: require
});
// Temporary hack
if (!node.config.bool('no-wallet') && !node.has('walletdb')) {
const plugin = require('../lib/wallet/plugin');
node.use(plugin);
}
process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();
await node.connect();
if (node.config.bool('test')) {
node.pool.watchAddress('1VayNert3x1KzbpzMGt2qdqrAThiRovi8');
node.pool.watchOutpoint(new Outpoint());
node.on('block', (block) => {
assert(block.txs.length >= 1);
if (block.txs.length > 1)
console.log(block.txs[1]);
});
}
node.startSync();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});