ln-docker-daemons 8.1.3 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,14 +8,19 @@ Example:
8
8
  const {authenticatedLndGrpc, getIdentity} = require('ln-service');
9
9
  const {spawnLightningDocker} = require('ln-docker-daemons');
10
10
 
11
- const {cert, kill, macaroon, socket} = spawnLightningDocker({});
11
+ (async () => {
12
+ // Blocks are mined to a regtest address
13
+ const {cert, kill, macaroon, socket} = await spawnLightningDocker({
14
+ generate_address: '2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF',
15
+ });
12
16
 
13
- const {lnd} = authenticatedLndGrpc({cert, macaroon, socket});
17
+ const {lnd} = authenticatedLndGrpc({cert, macaroon, socket});
14
18
 
15
- // Fetch the identity public key of the LND node
16
- const publicKey = (await getIdentity({lnd})).public_key;
19
+ // Fetch the identity public key of the LND node
20
+ const publicKey = (await getIdentity({lnd})).public_key;
17
21
 
18
- await kill({});
22
+ await kill({});
23
+ })();
19
24
  ```
20
25
 
21
26
  Supported methods:
@@ -24,6 +29,11 @@ Supported methods:
24
29
  - spawnBitcoindDocker: Run a Bitcoin Core container
25
30
  - spawnLightningCluster: Spin up a group of nodes
26
31
  - spawnLightningDocker: Run lnd + bitcoind
32
+ - spawnLoopServerDocker: Run a regtest Loop server backed by an lnd
33
+
34
+ Container ports are published on `127.0.0.1` only. LND sockets use the
35
+ `localhost` host name, so clients that resolve `localhost` to `::1` need to
36
+ fall back to `127.0.0.1`, as gRPC clients and Node.js 22 connections do.
27
37
 
28
38
  One liner for killing all running Docker containers:
29
39
 
@@ -34,6 +44,7 @@ docker container kill $(docker ps -q)
34
44
  ## Environment Variables
35
45
 
36
46
  - `DOCKER_LND_VERSION`: set this to use a custom LND docker image
47
+ - `DOCKER_LOOP_SERVER_VERSION`: set this to use a custom Loop server image
37
48
 
38
49
  Example:
39
50
 
@@ -43,6 +54,7 @@ export DOCKER_LND_VERSION="v0.14.0-beta"
43
54
 
44
55
  A list of available tags can be found here:
45
56
  https://hub.docker.com/r/lightninglabs/lnd/tags
57
+ https://hub.docker.com/r/lightninglabs/loopserver/tags
46
58
 
47
59
  ## `setupChannel`
48
60
 
@@ -72,18 +84,21 @@ Example:
72
84
 
73
85
  ```node
74
86
  const {getNetworkInfo} = require('ln-service');
87
+ const {setupChannel} = require('ln-docker-daemons');
75
88
  const {spawnLightningCluster} = require('ln-docker-daemons');
76
89
 
77
- const {kill, nodes} = await spawnLightningCluster({size: 2});
90
+ (async () => {
91
+ const {kill, nodes} = await spawnLightningCluster({size: 2});
78
92
 
79
- const [alice, bob] = nodes;
93
+ const [alice, bob] = nodes;
80
94
 
81
- await setupChannel({generate: alice.generate, lnd: alice.lnd, to: bob});
95
+ await setupChannel({generate: alice.generate, lnd: alice.lnd, to: bob});
82
96
 
83
- const networkInfo = await getNetworkInfo({lnd: alice.lnd});
84
- // networkInfo.channel_count now equals 1
97
+ const networkInfo = await getNetworkInfo({lnd: alice.lnd});
98
+ // networkInfo.channel_count now equals 1
85
99
 
86
- await kill({});
100
+ await kill({});
101
+ })();
87
102
  ```
88
103
 
89
104
  ## `spawnBitcoindDocker`
@@ -117,11 +132,13 @@ Example:
117
132
  ```node
118
133
  const {spawnBitcoindDocker} = require('ln-docker-daemons');
119
134
 
120
- // Launch a Bitcoind Docker image, Docker picks a free port for RPC
121
- const {kill, rpc_port} = await spawnBitcoindDocker({});
135
+ (async () => {
136
+ // Launch a Bitcoind Docker image, Docker picks a free port for RPC
137
+ const {kill, rpc_port} = await spawnBitcoindDocker({});
122
138
 
123
- // Stop the image
124
- await kill({});
139
+ // Stop the image
140
+ await kill({});
141
+ })();
125
142
  ```
126
143
 
127
144
  ## `spawnLightningCluster`
@@ -164,17 +181,19 @@ Example:
164
181
  const {createChainAddress, getIdentity} = require('lightning');
165
182
  const {spawnLightningCluster} = require('ln-docker-daemons');
166
183
 
167
- // Launch a lightning node
168
- const {nodes} = await spawnLightningCluster({});
169
- const [{lnd, generate, kill}] = nodes;
184
+ (async () => {
185
+ // Launch a lightning node
186
+ const {nodes} = await spawnLightningCluster({});
187
+ const [{lnd, generate, kill}] = nodes;
170
188
 
171
- const publicKey = (await getIdentity({lnd})).public_key;
189
+ const publicKey = (await getIdentity({lnd})).public_key;
172
190
 
173
- // Generate some coins for the wallet
174
- await generate({count: 500});
191
+ // Generate some coins for the wallet
192
+ await generate({count: 500});
175
193
 
176
- // Stop the image
177
- await kill({});
194
+ // Stop the image
195
+ await kill({});
196
+ })();
178
197
  ```
179
198
 
180
199
  Example with channels:
@@ -182,16 +201,18 @@ Example with channels:
182
201
  ```node
183
202
  const {spawnLightningCluster} = require('ln-docker-daemons');
184
203
 
185
- // Launch three nodes with channels Alice -> Bob -> Carol
186
- const {channels, kill, nodes} = await spawnLightningCluster({
187
- capacity: 1e6,
188
- size: 3,
189
- });
204
+ (async () => {
205
+ // Launch three nodes with channels Alice -> Bob -> Carol
206
+ const {channels, kill, nodes} = await spawnLightningCluster({
207
+ capacity: 1e6,
208
+ size: 3,
209
+ });
190
210
 
191
- const [alice, bob, carol] = nodes;
211
+ const [alice, bob, carol] = nodes;
192
212
 
193
- // Stop all the nodes
194
- await kill({});
213
+ // Stop all the nodes
214
+ await kill({});
215
+ })();
195
216
  ```
196
217
 
197
218
  ## `spawnLightningDocker`
@@ -220,9 +241,10 @@ reachable over the Docker network.
220
241
  add_chain_peer: <Add Peer Function> ({socket}) => {}
221
242
  cert: <LND Base64 Serialized TLS Cert>
222
243
  chain_socket: <Chain P2P Socket String>
244
+ docker_host: <LND Docker Network Host String>
223
245
  kill: ({}, [cbk]) => <Kill LND Daemon Promise>
224
246
  ln_socket: <LN P2P Socket String>
225
- macaroon: <LND Base64 Serialized Macaroon String>
247
+ macaroon: <LND Hex Serialized Macaroon String>
226
248
  public_key: <Identity Public Key Hex String>
227
249
  socket: <LND RPC Host:Port Network Address String>
228
250
  tower_socket: <LND Tower Socket Host:Port Network Address String>
@@ -253,8 +275,72 @@ them. A p2p port that is not specified is not published to the host.
253
275
  {
254
276
  cert: <LND Base64 Serialized TLS Cert Base64 String>
255
277
  kill: ({}, [cbk]) => <Kill LND Docker Promise>
256
- macaroon: <LND Base64 Serialized Macaroon String>
278
+ macaroon: <LND Hex Serialized Macaroon String>
257
279
  public_key: <LND Public Key Hex String>
258
280
  socket: <LND RPC Host:Port Network Address String>
259
281
  tower_socket: <LND Tower Socket Host:Port Network Address String>
260
282
  }
283
+
284
+ ## `spawnLoopServerDocker`
285
+
286
+ Spawn a Lightning Labs regtest Loop server Docker image, backed by an LND
287
+
288
+ The Loop server has its own Bitcoin Core, which follows the LND chain by
289
+ connecting to `chain_socket`.
290
+
291
+ The image is `lightninglabs/loopserver:v0.1.1`. Set
292
+ `DOCKER_LOOP_SERVER_VERSION` to use a different version.
293
+
294
+ The Loop server takes gRPC without TLS on `socket`, at `127.0.0.1`. TLS-only
295
+ clients can use `tls_socket`, which passes connections on to the server. It
296
+ uses the `localhost` host name, and listens on both `127.0.0.1` and `::1`.
297
+
298
+ When an RPC port is not specified, Docker picks a free host port for it.
299
+
300
+ {
301
+ chain_socket: <LND Chain P2P Socket String>
302
+ lnd_cert: <LND Base64 Serialized TLS Cert String>
303
+ lnd_docker_host: <LND Docker Network Host String>
304
+ lnd_macaroon: <LND Admin Macaroon Hex String>
305
+ [rpc_port]: <Loop Server RPC Port Number>
306
+ }
307
+
308
+ @returns via cbk or Promise
309
+ {
310
+ cert: <TLS Socket Base64 Serialized TLS Cert String>
311
+ kill: ({}, [cbk]) => <Kill Loop Server Promise>
312
+ socket: <Loop Server RPC Host:Port Network Address String>
313
+ tls_socket: <Loop Server TLS RPC Host:Port Network Address String>
314
+ }
315
+
316
+ Example:
317
+
318
+ ```node
319
+ const {spawnLightningDocker} = require('ln-docker-daemons');
320
+ const {spawnLoopServerDocker} = require('ln-docker-daemons');
321
+
322
+ (async () => {
323
+ // Blocks are mined to a regtest address
324
+ const lnd = await spawnLightningDocker({
325
+ generate_address: '2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF',
326
+ });
327
+
328
+ // Stop LND even when the Loop server fails to start
329
+ try {
330
+ const loopServer = await spawnLoopServerDocker({
331
+ chain_socket: lnd.chain_socket,
332
+ lnd_cert: lnd.cert,
333
+ lnd_docker_host: lnd.docker_host,
334
+ lnd_macaroon: lnd.macaroon,
335
+ });
336
+
337
+ try {
338
+ // Point a Loop client at loopServer.socket, without TLS
339
+ } finally {
340
+ await loopServer.kill({});
341
+ }
342
+ } finally {
343
+ await lnd.kill({});
344
+ }
345
+ })();
346
+ ```
@@ -6,7 +6,7 @@ const rpc = require('./rpc');
6
6
  const action = 'add';
7
7
  const alreadyAdded = -23;
8
8
  const cmd = 'addnode';
9
- const host = 'localhost';
9
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
10
10
  const isAlreadyAdded = err => isRpcError(err) && err[2].code === alreadyAdded;
11
11
  const isRpcError = err => err[1] === 'UnexpectedErrorFromRpcCommand';
12
12
 
@@ -23,24 +23,24 @@ const isRpcError = err => err[1] === 'UnexpectedErrorFromRpcCommand';
23
23
 
24
24
  @returns via cbk or Promise
25
25
  */
26
- module.exports = ({pass, port, socket, user}, cbk) => {
26
+ module.exports = (args, cbk) => {
27
27
  return new Promise((resolve, reject) => {
28
28
  return asyncAuto({
29
29
  // Check arguments
30
30
  validate: cbk => {
31
- if (!pass) {
31
+ if (!args.pass) {
32
32
  return cbk([400, 'ExpectedRpcPasswordToAddChainPeer']);
33
33
  }
34
34
 
35
- if (!port) {
35
+ if (!args.port) {
36
36
  return cbk([400, 'ExpectedRpcPortNumberToAddChainPeer']);
37
37
  }
38
38
 
39
- if (!socket) {
39
+ if (!args.socket) {
40
40
  return cbk([400, 'ExpectedSocketToAddChainPeer']);
41
41
  }
42
42
 
43
- if (!user) {
43
+ if (!args.user) {
44
44
  return cbk([400, 'ExpectedRpcUsernameToAddChainPeer']);
45
45
  }
46
46
 
@@ -49,9 +49,17 @@ module.exports = ({pass, port, socket, user}, cbk) => {
49
49
 
50
50
  // Execute request
51
51
  request: ['validate', ({}, cbk) => {
52
- const params = [socket, action];
52
+ const params = [args.socket, action];
53
53
 
54
- return rpc({cmd, host, pass, params, port, user}, err => {
54
+ return rpc({
55
+ cmd,
56
+ host,
57
+ params,
58
+ pass: args.pass,
59
+ port: args.port,
60
+ user: args.user,
61
+ },
62
+ err => {
55
63
  // Exit early when the node was already added
56
64
  if (!!err && isAlreadyAdded(err)) {
57
65
  return cbk();
@@ -8,18 +8,11 @@ const getBlockchainInfo = require('./get_blockchain_info');
8
8
  const rpc = require('./rpc');
9
9
  const unknownGeneratedError = require('./unknown_generated_error');
10
10
 
11
- const host = 'localhost';
11
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
12
12
  const txVerbosityFlag = 2;
13
13
 
14
14
  /** Check what blocks a failed generate request made
15
15
 
16
- Generate requests run one at a time, so blocks on top of the start height
17
- can only be from this request, unless they were mined outside this process.
18
- They must all pay to the address, and there can't be more than requested.
19
-
20
- A request that may still be running is given time to finish mining. When a
21
- request finished without mining anything, its original error is returned.
22
-
23
16
  {
24
17
  address: <Coinbase Output Address String>
25
18
  count: <Requested Blocks Count Number>
@@ -8,12 +8,10 @@ const queue = asyncQueue(mineBlocks, 1);
8
8
 
9
9
  /** Generate blocks and mine coinbase outputs to an address
10
10
 
11
- Requests run one at a time. When the outcome of a request is unclear, blocks
12
- on top of where it started can then only be from that request, unless they
13
- were mined outside of this process.
14
-
15
11
  {
16
12
  address: <Address to Mine Outputs Towards String>
13
+ [check_interval]: <Unclear Outcome Poll Interval Milliseconds Number>
14
+ [check_times]: <Unclear Outcome Poll Times Number>
17
15
  [count]: <Generate Count Number>
18
16
  pass: <RPC Password String>
19
17
  port: <RPC Port Number>
@@ -23,38 +21,40 @@ const queue = asyncQueue(mineBlocks, 1);
23
21
  @returns via cbk or Promise
24
22
  [<Generated Block Hash Hex String>]
25
23
  */
26
- module.exports = ({address, count, pass, port, user}, cbk) => {
24
+ module.exports = (args, cbk) => {
27
25
  return new Promise((resolve, reject) => {
28
26
  return asyncAuto({
29
27
  // Check arguments
30
28
  validate: cbk => {
31
- if (!address) {
29
+ if (!args.address) {
32
30
  return cbk([400, 'ExpectedAddressToGenerateToAddress']);
33
31
  }
34
32
 
35
- if (!pass) {
33
+ if (!args.pass) {
36
34
  return cbk([400, 'ExpectedRpcPasswordToGenerateToAddress']);
37
35
  }
38
36
 
39
- if (!port) {
37
+ if (!args.port) {
40
38
  return cbk([400, 'ExpectedRpcPortNumberToGenerateToAddress']);
41
39
  }
42
40
 
43
- if (!user) {
41
+ if (!args.user) {
44
42
  return cbk([400, 'ExpectedRpcUsernameToGenerateToAddresss']);
45
43
  }
46
44
 
47
45
  return cbk();
48
46
  },
49
47
 
50
- // Mine the blocks once earlier generate requests are done
48
+ // Mine after earlier requests so that new blocks are from this request
51
49
  generate: ['validate', ({}, cbk) => {
52
50
  return queue.push({
53
- address,
54
- pass,
55
- port,
56
- user,
57
- count: count || [address].length,
51
+ address: args.address,
52
+ check_interval: args.check_interval,
53
+ check_times: args.check_times,
54
+ count: args.count || [args.address].length,
55
+ pass: args.pass,
56
+ port: args.port,
57
+ user: args.user,
58
58
  },
59
59
  cbk);
60
60
  }],
@@ -0,0 +1,79 @@
1
+ const asyncAuto = require('async/auto');
2
+ const {returnResult} = require('asyncjs-util');
3
+
4
+ const rpc = require('./rpc');
5
+
6
+ const cmd = 'getaddednodeinfo';
7
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
8
+
9
+ /** Get the connected addresses of a manually added Bitcoin Core peer
10
+
11
+ {
12
+ pass: <RPC Password String>
13
+ port: <RPC Port Number>
14
+ socket: <Peer Socket Passed to Addnode String>
15
+ [timeout]: <Request Timeout Milliseconds Number>
16
+ user: <RPC Username String>
17
+ }
18
+
19
+ @returns via cbk or Promise
20
+ {
21
+ addresses: [<Connected Peer Address String>]
22
+ }
23
+ */
24
+ module.exports = (args, cbk) => {
25
+ return new Promise((resolve, reject) => {
26
+ return asyncAuto({
27
+ // Check arguments
28
+ validate: cbk => {
29
+ if (!args.pass) {
30
+ return cbk([400, 'ExpectedRpcPasswordToGetAddedNodeInfo']);
31
+ }
32
+
33
+ if (!args.port) {
34
+ return cbk([400, 'ExpectedRpcPortToGetAddedNodeInfo']);
35
+ }
36
+
37
+ if (!args.socket) {
38
+ return cbk([400, 'ExpectedSocketToGetAddedNodeInfo']);
39
+ }
40
+
41
+ if (!args.user) {
42
+ return cbk([400, 'ExpectedRpcUserToGetAddedNodeInfo']);
43
+ }
44
+
45
+ return cbk();
46
+ },
47
+
48
+ // Look up the node using the same socket that was passed to addnode
49
+ request: ['validate', ({}, cbk) => {
50
+ const params = [args.socket];
51
+
52
+ return rpc({
53
+ cmd,
54
+ host,
55
+ params,
56
+ pass: args.pass,
57
+ port: args.port,
58
+ timeout: args.timeout,
59
+ user: args.user,
60
+ },
61
+ cbk);
62
+ }],
63
+
64
+ // Disconnected nodes have no connected addresses
65
+ connected: ['request', ({request}, cbk) => {
66
+ const [node] = request || [];
67
+
68
+ if (!node || !node.connected) {
69
+ return cbk(null, {addresses: []});
70
+ }
71
+
72
+ const addresses = (node.addresses || []).map(n => n.address);
73
+
74
+ return cbk(null, {addresses: addresses.filter(n => !!n)});
75
+ }],
76
+ },
77
+ returnResult({reject, resolve, of: 'connected'}, cbk));
78
+ });
79
+ };
@@ -4,7 +4,7 @@ const {returnResult} = require('asyncjs-util');
4
4
  const rpc = require('./rpc');
5
5
 
6
6
  const cmd = 'getblock';
7
- const host = 'localhost';
7
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
8
8
  const infoVerbosityFlag = 1;
9
9
 
10
10
  /** Get block info from Bitcoin Core daemon
@@ -21,24 +21,24 @@ const infoVerbosityFlag = 1;
21
21
  tx: [<Transaction Id Hex String>]
22
22
  }
23
23
  */
24
- module.exports = ({id, pass, port, user}, cbk) => {
24
+ module.exports = (args, cbk) => {
25
25
  return new Promise((resolve, reject) => {
26
26
  return asyncAuto({
27
27
  // Check arguments
28
28
  validate: cbk => {
29
- if (!id) {
29
+ if (!args.id) {
30
30
  return cbk([400, 'ExpectedBlockIdToGetBlockInfo']);
31
31
  }
32
32
 
33
- if (!pass) {
33
+ if (!args.pass) {
34
34
  return cbk([400, 'ExpectedRpcPasswordToGetBlockInfo']);
35
35
  }
36
36
 
37
- if (!port) {
37
+ if (!args.port) {
38
38
  return cbk([400, 'ExpectedRpcPortNumberToGetBlockInfo']);
39
39
  }
40
40
 
41
- if (!user) {
41
+ if (!args.user) {
42
42
  return cbk([400, 'ExpectedRpcUsernameToGetBlockInfo']);
43
43
  }
44
44
 
@@ -47,9 +47,17 @@ module.exports = ({id, pass, port, user}, cbk) => {
47
47
 
48
48
  // Execute request
49
49
  request: ['validate', ({}, cbk) => {
50
- const params = [id, infoVerbosityFlag];
50
+ const params = [args.id, infoVerbosityFlag];
51
51
 
52
- return rpc({cmd, host, pass, params, port, user}, cbk);
52
+ return rpc({
53
+ cmd,
54
+ host,
55
+ params,
56
+ pass: args.pass,
57
+ port: args.port,
58
+ user: args.user,
59
+ },
60
+ cbk);
53
61
  }],
54
62
  },
55
63
  returnResult({reject, resolve, of: 'request'}, cbk));
@@ -4,7 +4,7 @@ const {returnResult} = require('asyncjs-util');
4
4
  const rpc = require('./rpc');
5
5
 
6
6
  const cmd = 'getblockchaininfo';
7
- const host = 'localhost';
7
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
8
8
  const params = [];
9
9
 
10
10
  /** Get blockchain info from Bitcoin Core daemon
@@ -21,20 +21,20 @@ const params = [];
21
21
  blocks: <Best Chain Block Height Number>
22
22
  }
23
23
  */
24
- module.exports = ({pass, port, timeout, user}, cbk) => {
24
+ module.exports = (args, cbk) => {
25
25
  return new Promise((resolve, reject) => {
26
26
  return asyncAuto({
27
27
  // Check arguments
28
28
  validate: cbk => {
29
- if (!pass) {
29
+ if (!args.pass) {
30
30
  return cbk([400, 'ExpectedRpcPasswordToGetBlockchainInfo']);
31
31
  }
32
32
 
33
- if (!port) {
33
+ if (!args.port) {
34
34
  return cbk([400, 'ExpectedRpcPortNumberToGetBlockchainInfo']);
35
35
  }
36
36
 
37
- if (!user) {
37
+ if (!args.user) {
38
38
  return cbk([400, 'ExpectedRpcUsernameToGetBlockchainInfo']);
39
39
  }
40
40
 
@@ -43,7 +43,16 @@ module.exports = ({pass, port, timeout, user}, cbk) => {
43
43
 
44
44
  // Execute request
45
45
  request: ['validate', ({}, cbk) => {
46
- return rpc({cmd, host, pass, params, port, timeout, user}, cbk);
46
+ return rpc({
47
+ cmd,
48
+ host,
49
+ params,
50
+ pass: args.pass,
51
+ port: args.port,
52
+ timeout: args.timeout,
53
+ user: args.user,
54
+ },
55
+ cbk);
47
56
  }],
48
57
  },
49
58
  returnResult({reject, resolve, of: 'request'}, cbk));
@@ -0,0 +1,73 @@
1
+ const asyncAuto = require('async/auto');
2
+ const {returnResult} = require('asyncjs-util');
3
+
4
+ const rpc = require('./rpc');
5
+
6
+ const cmd = 'getpeerinfo';
7
+ const host = '127.0.0.1'; // Published ports bind IPv4 loopback only
8
+ const params = [];
9
+
10
+ /** Get the peers of a Bitcoin Core daemon
11
+
12
+ {
13
+ pass: <RPC Password String>
14
+ port: <RPC Port Number>
15
+ [timeout]: <Request Timeout Milliseconds Number>
16
+ user: <RPC Username String>
17
+ }
18
+
19
+ @returns via cbk or Promise
20
+ {
21
+ peers: [{
22
+ socket: <Peer Address String>
23
+ starting_height: <Peer Best Chain Height When It Connected Number>
24
+ }]
25
+ }
26
+ */
27
+ module.exports = (args, cbk) => {
28
+ return new Promise((resolve, reject) => {
29
+ return asyncAuto({
30
+ // Check arguments
31
+ validate: cbk => {
32
+ if (!args.pass) {
33
+ return cbk([400, 'ExpectedRpcPasswordToGetPeerInfo']);
34
+ }
35
+
36
+ if (!args.port) {
37
+ return cbk([400, 'ExpectedRpcPortNumberToGetPeerInfo']);
38
+ }
39
+
40
+ if (!args.user) {
41
+ return cbk([400, 'ExpectedRpcUsernameToGetPeerInfo']);
42
+ }
43
+
44
+ return cbk();
45
+ },
46
+
47
+ // Execute request
48
+ request: ['validate', ({}, cbk) => {
49
+ return rpc({
50
+ cmd,
51
+ host,
52
+ params,
53
+ pass: args.pass,
54
+ port: args.port,
55
+ timeout: args.timeout,
56
+ user: args.user,
57
+ },
58
+ cbk);
59
+ }],
60
+
61
+ // Final peers
62
+ peers: ['request', ({request}, cbk) => {
63
+ const peers = (request || []).map(peer => ({
64
+ socket: peer.addr,
65
+ starting_height: peer.startingheight,
66
+ }));
67
+
68
+ return cbk(null, {peers});
69
+ }],
70
+ },
71
+ returnResult({reject, resolve, of: 'peers'}, cbk));
72
+ });
73
+ };
@@ -1,11 +1,15 @@
1
1
  const addPeer = require('./add_peer');
2
2
  const generateToAddress = require('./generate_to_address');
3
+ const getAddedNodeInfo = require('./get_added_node_info');
3
4
  const getBlockInfo = require('./get_block_info');
4
5
  const getBlockchainInfo = require('./get_blockchain_info');
6
+ const getPeerInfo = require('./get_peer_info');
5
7
 
6
8
  module.exports = {
7
9
  addPeer,
8
10
  generateToAddress,
11
+ getAddedNodeInfo,
9
12
  getBlockInfo,
10
13
  getBlockchainInfo,
14
+ getPeerInfo,
11
15
  };