• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

handshake-org / hsd / 7113784955

06 Dec 2023 11:15AM UTC coverage: 68.615% (+0.003%) from 68.612%
7113784955

push

github

nodech
Merge PR #879 from 'nodech/cache-test-dns'

7499 of 12765 branches covered (0.0%)

Branch coverage included in aggregate %.

23952 of 33072 relevant lines covered (72.42%)

34147.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.62
/lib/wallet/node.js
1
/*!
2
 * server.js - wallet server for hsd
3
 * Copyright (c) 2017-2018, Christopher Jeffrey (MIT License).
4
 * https://github.com/handshake-org/hsd
5
 */
6

7
'use strict';
8

9
const assert = require('bsert');
1✔
10
const Node = require('../node/node');
1✔
11
const WalletDB = require('./walletdb');
1✔
12
const HTTP = require('./http');
1✔
13
const Client = require('./client');
1✔
14
const RPC = require('./rpc');
1✔
15
const pkg = require('../pkg');
1✔
16

17
/**
18
 * Wallet Node
19
 * @extends Node
20
 */
21

22
class WalletNode extends Node {
23
  /**
24
   * Create a wallet node.
25
   * @constructor
26
   * @param {Object?} options
27
   */
28

29
  constructor(options) {
30
    super(pkg.name, 'hsw.conf', 'wallet.log', options);
×
31

32
    this.opened = false;
×
33

34
    this.client = new Client({
×
35
      network: this.network,
36
      url: this.config.str('node-url'),
37
      host: this.config.str('node-host'),
38
      port: this.config.uint('node-port', this.network.rpcPort),
39
      ssl: this.config.bool('node-ssl'),
40
      apiKey: this.config.str('node-api-key')
41
    });
42

43
    this.wdb = new WalletDB({
×
44
      network: this.network,
45
      logger: this.logger,
46
      workers: this.workers,
47
      client: this.client,
48
      prefix: this.config.prefix,
49
      memory: this.config.bool('memory'),
50
      maxFiles: this.config.uint('max-files'),
51
      cacheSize: this.config.mb('cache-size'),
52
      wipeNoReally: this.config.bool('wipe-no-really'),
53
      spv: this.config.bool('spv'),
54
      walletMigrate: this.config.uint('migrate'),
55
      icannlockup: this.config.bool('icannlockup', false),
56
      migrateNoRescan: this.config.bool('migrate-no-rescan', false),
57
      preloadAll: this.config.bool('preload-all', false)
58
    });
59

60
    this.rpc = new RPC(this);
×
61

62
    this.http = new HTTP({
×
63
      network: this.network,
64
      logger: this.logger,
65
      node: this,
66
      prefix: this.config.prefix,
67
      ssl: this.config.bool('ssl'),
68
      keyFile: this.config.path('ssl-key'),
69
      certFile: this.config.path('ssl-cert'),
70
      host: this.config.str('http-host'),
71
      port: this.config.uint('http-port'),
72
      apiKey: this.config.str('api-key'),
73
      walletAuth: this.config.bool('wallet-auth'),
74
      noAuth: this.config.bool('no-auth'),
75
      cors: this.config.bool('cors'),
76
      adminToken: this.config.str('admin-token')
77
    });
78

79
    this.init();
×
80
  }
81

82
  /**
83
   * Initialize the node.
84
   * @private
85
   */
86

87
  init() {
88
    this.wdb.on('error', err => this.error(err));
×
89
    this.http.on('error', err => this.error(err));
×
90

91
    this.loadPlugins();
×
92
  }
93

94
  /**
95
   * Open the node and all its child objects,
96
   * wait for the database to load.
97
   * @returns {Promise}
98
   */
99

100
  async open() {
101
    assert(!this.opened, 'WalletNode is already open.');
×
102
    this.opened = true;
×
103

104
    await this.handlePreopen();
×
105
    await this.wdb.open();
×
106

107
    this.rpc.wallet = this.wdb.primary;
×
108

109
    await this.openPlugins();
×
110

111
    await this.http.open();
×
112
    await this.wdb.connect();
×
113
    await this.handleOpen();
×
114

115
    this.logger.info('Wallet node is loaded.');
×
116
  }
117

118
  /**
119
   * Close the node, wait for the database to close.
120
   * @returns {Promise}
121
   */
122

123
  async close() {
124
    assert(this.opened, 'WalletNode is not open.');
×
125
    this.opened = false;
×
126

127
    await this.handlePreclose();
×
128
    await this.http.close();
×
129

130
    await this.closePlugins();
×
131

132
    this.rpc.wallet = null;
×
133

134
    await this.wdb.disconnect();
×
135
    await this.wdb.close();
×
136
    await this.handleClose();
×
137
  }
138
}
139

140
/*
141
 * Expose
142
 */
143

144
module.exports = WalletNode;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc