ln-docker-daemons 2.0.0 → 2.2.1
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/CHANGELOG.md +9 -0
- package/README.md +14 -3
- package/cluster/spawn_lightning_cluster.js +4 -2
- package/docker/spawn_docker_image.js +2 -0
- package/lnd/constants.json +1 -1
- package/lnd/spawn_lightning_docker.js +2 -0
- package/lnd/spawn_lnd_docker.js +37 -45
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
- `spawnLightningCluster`, `spawnLightningDocker`: Add `lnd_configuration` to
|
|
6
|
+
allow specifying additional LND configuration parameters
|
|
7
|
+
|
|
8
|
+
## 2.1.1
|
|
9
|
+
|
|
10
|
+
- `DOCKER_LND_VERSION`: add environment variable to control docker lnd image
|
|
11
|
+
|
|
3
12
|
## 2.0.0
|
|
4
13
|
|
|
5
14
|
- `spawnLightningCluster`: add `socket` to reveal node LN p2p sockets
|
package/README.md
CHANGED
|
@@ -18,6 +18,16 @@ const publicKey = (await getIdentity({lnd})).public_key;
|
|
|
18
18
|
await kill({});
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Environment Variables
|
|
22
|
+
|
|
23
|
+
- `DOCKER_LND_VERSION`: set this to use a custom LND docker image
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
|
|
27
|
+
```shell
|
|
28
|
+
export DOCKER_LND_VERSION="v0.14.0-beta"
|
|
29
|
+
```
|
|
30
|
+
|
|
21
31
|
## spawnBitcoindDocker
|
|
22
32
|
|
|
23
33
|
Spawn a Bitcoin Core Docker image
|
|
@@ -59,6 +69,7 @@ await kill({});
|
|
|
59
69
|
Spawn a cluster of nodes
|
|
60
70
|
|
|
61
71
|
{
|
|
72
|
+
[lnd_configuration]: [<LND Configuration Argument String>]
|
|
62
73
|
[size]: <Total Lightning Nodes Number>
|
|
63
74
|
}
|
|
64
75
|
|
|
@@ -83,11 +94,10 @@ const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
|
83
94
|
const {nodes} = await spawnLightningCluster({});
|
|
84
95
|
const [{lnd, generate, kill}] = nodes;
|
|
85
96
|
|
|
86
|
-
const
|
|
97
|
+
const publicKey = (await getIdentity({lnd})).public_key;
|
|
87
98
|
|
|
88
99
|
// Generate some coins for the wallet
|
|
89
|
-
|
|
90
|
-
await generate({address, count: 500});
|
|
100
|
+
await generate({count: 500});
|
|
91
101
|
|
|
92
102
|
// Stop the image
|
|
93
103
|
await kill({});
|
|
@@ -105,6 +115,7 @@ Spawn an LND Docker
|
|
|
105
115
|
generate_address: <Generate Blocks to Address String>
|
|
106
116
|
lightning_p2p_port: <Lightning Network P2P Listen Port Number>
|
|
107
117
|
lightning_rpc_port: <Lightning Node RPC Port Number>
|
|
118
|
+
[lnd_configuration]: [<LND Configuration Argument String>]
|
|
108
119
|
}
|
|
109
120
|
|
|
110
121
|
@returns via cbk or Promise
|
|
@@ -17,7 +17,7 @@ const count = size => size || 1;
|
|
|
17
17
|
const endPort = 65000;
|
|
18
18
|
const generateAddress = '2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF';
|
|
19
19
|
const interval = 10;
|
|
20
|
-
const makeAddress = ({lnd}) => createChainAddress({lnd
|
|
20
|
+
const makeAddress = ({lnd}) => createChainAddress({lnd});
|
|
21
21
|
const maturity = 100;
|
|
22
22
|
const pairs = n => n.map((x, i) => n.slice(i + 1).map(y => [x, y])).flat();
|
|
23
23
|
const portsPerLnd = 6;
|
|
@@ -27,6 +27,7 @@ const times = 3000;
|
|
|
27
27
|
/** Spawn a cluster of nodes
|
|
28
28
|
|
|
29
29
|
{
|
|
30
|
+
[lnd_configuration]: [<LND Configuration Argument String>]
|
|
30
31
|
[size]: <Total Lightning Nodes Number>
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -46,7 +47,7 @@ module.exports = (args, cbk) => {
|
|
|
46
47
|
return asyncAuto({
|
|
47
48
|
// Spawn nodes
|
|
48
49
|
spawn: async () => {
|
|
49
|
-
return await asyncRetry({}, async () => {
|
|
50
|
+
return await asyncRetry({interval, times: 25}, async () => {
|
|
50
51
|
const options = {startPort: between(startPort, endPort)};
|
|
51
52
|
|
|
52
53
|
// Find ports for the requested daemons
|
|
@@ -75,6 +76,7 @@ module.exports = (args, cbk) => {
|
|
|
75
76
|
generate_address: generateAddress,
|
|
76
77
|
lightning_p2p_port: lightningP2pPort,
|
|
77
78
|
lightning_rpc_port: lightningRpcPort,
|
|
79
|
+
lnd_configuration: args.lnd_configuration,
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
const {lnd} = authenticatedLndGrpc({
|
package/lnd/constants.json
CHANGED
|
@@ -18,6 +18,7 @@ const spawnLndDocker = require('./spawn_lnd_docker');
|
|
|
18
18
|
generate_address: <Generate Blocks to Address String>
|
|
19
19
|
lightning_p2p_port: <Lightning Network P2P Listen Port Number>
|
|
20
20
|
lightning_rpc_port: <Lightning Node RPC Port Number>
|
|
21
|
+
[lnd_configuration]: [<LND Configuration Argument String>]
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
@returns via cbk or Promise
|
|
@@ -99,6 +100,7 @@ module.exports = (args, cbk) => {
|
|
|
99
100
|
({spawnChainDaemon}, cbk) =>
|
|
100
101
|
{
|
|
101
102
|
return spawnLndDocker({
|
|
103
|
+
configuration: args.lnd_configuration,
|
|
102
104
|
bitcoind_rpc_host: spawnChainDaemon.host,
|
|
103
105
|
bitcoind_rpc_pass: spawnChainDaemon.rpc_pass,
|
|
104
106
|
bitcoind_rpc_port: args.chain_rpc_port,
|
package/lnd/spawn_lnd_docker.js
CHANGED
|
@@ -8,7 +8,8 @@ const {unauthenticatedLndGrpc} = require('lightning');
|
|
|
8
8
|
const {dockerLndImage} = require('./constants');
|
|
9
9
|
const {spawnDockerImage} = require('./../docker');
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const imageName = ver => !!ver ? `lightninglabs/lnd:${ver}` : dockerLndImage;
|
|
12
|
+
const interval = 100;
|
|
12
13
|
const macaroonPath = '/root/.lnd/data/chain/bitcoin/regtest/admin.macaroon';
|
|
13
14
|
const times = 500;
|
|
14
15
|
const tlsCertPath = '/root/.lnd/tls.cert';
|
|
@@ -22,6 +23,7 @@ const tlsCertPath = '/root/.lnd/tls.cert';
|
|
|
22
23
|
bitcoind_rpc_user: <Bitcoin Core RPC Username String>
|
|
23
24
|
bitcoind_zmq_block_port: <Bitcoin Core ZMQ Block Port Number>
|
|
24
25
|
bitcoind_zmq_tx_port: <Bitcoin Core ZMQ Transaction Port Number>
|
|
26
|
+
[configuration]: [<LND Configuration Argument String>]
|
|
25
27
|
p2p_port: <LND Peer to Peer Listen Port Number>
|
|
26
28
|
rpc_port: <LND RPC Port Number>
|
|
27
29
|
}
|
|
@@ -77,31 +79,33 @@ module.exports = (args, cbk) => {
|
|
|
77
79
|
const zmqBlockPort = args.bitcoind_zmq_block_port;
|
|
78
80
|
const zmqTxPort = args.bitcoind_zmq_tx_port;
|
|
79
81
|
|
|
82
|
+
const arguments = [
|
|
83
|
+
'--accept-keysend',
|
|
84
|
+
'--allow-circular-route',
|
|
85
|
+
'--autopilot.heuristic=externalscore:0.5',
|
|
86
|
+
'--autopilot.heuristic=preferential:0.5',
|
|
87
|
+
'--bitcoin.active',
|
|
88
|
+
'--bitcoin.minhtlc=1000',
|
|
89
|
+
'--bitcoin.node=bitcoind',
|
|
90
|
+
'--bitcoin.regtest',
|
|
91
|
+
`--bitcoind.rpchost=${chainHost}:18443`,
|
|
92
|
+
`--bitcoind.rpcpass=${args.bitcoind_rpc_pass}`,
|
|
93
|
+
`--bitcoind.rpcuser=${args.bitcoind_rpc_user}`,
|
|
94
|
+
`--bitcoind.zmqpubrawblock=tcp://${chainHost}:${zmqBlockPort}`,
|
|
95
|
+
`--bitcoind.zmqpubrawtx=tcp://${chainHost}:${zmqTxPort}`,
|
|
96
|
+
'--debuglevel=trace',
|
|
97
|
+
`--externalip=127.0.0.1:9735`,
|
|
98
|
+
'--historicalsyncinterval=1s',
|
|
99
|
+
`--listen=0.0.0.0:9735`,
|
|
100
|
+
'--nobootstrap',
|
|
101
|
+
`--rpclisten=0.0.0.0:10009`,
|
|
102
|
+
'--trickledelay=1',
|
|
103
|
+
'--unsafe-disconnect',
|
|
104
|
+
];
|
|
105
|
+
|
|
80
106
|
return spawnDockerImage({
|
|
81
|
-
arguments: [
|
|
82
|
-
|
|
83
|
-
'--allow-circular-route',
|
|
84
|
-
'--autopilot.heuristic=externalscore:0.5',
|
|
85
|
-
'--autopilot.heuristic=preferential:0.5',
|
|
86
|
-
'--bitcoin.active',
|
|
87
|
-
'--bitcoin.minhtlc=1000',
|
|
88
|
-
'--bitcoin.node=bitcoind',
|
|
89
|
-
'--bitcoin.regtest',
|
|
90
|
-
`--bitcoind.rpchost=${chainHost}:18443`,
|
|
91
|
-
`--bitcoind.rpcpass=${args.bitcoind_rpc_pass}`,
|
|
92
|
-
`--bitcoind.rpcuser=${args.bitcoind_rpc_user}`,
|
|
93
|
-
`--bitcoind.zmqpubrawblock=tcp://${chainHost}:${zmqBlockPort}`,
|
|
94
|
-
`--bitcoind.zmqpubrawtx=tcp://${chainHost}:${zmqTxPort}`,
|
|
95
|
-
'--debuglevel=trace',
|
|
96
|
-
`--externalip=127.0.0.1:9735`,
|
|
97
|
-
'--historicalsyncinterval=1s',
|
|
98
|
-
`--listen=0.0.0.0:9735`,
|
|
99
|
-
'--nobootstrap',
|
|
100
|
-
`--rpclisten=0.0.0.0:10009`,
|
|
101
|
-
'--trickledelay=1',
|
|
102
|
-
'--unsafe-disconnect',
|
|
103
|
-
],
|
|
104
|
-
image: dockerLndImage,
|
|
107
|
+
arguments: arguments.concat(args.configuration || []),
|
|
108
|
+
image: imageName(process.env.DOCKER_LND_VERSION),
|
|
105
109
|
ports: {
|
|
106
110
|
'9735/tcp': args.p2p_port,
|
|
107
111
|
'10009/tcp': args.rpc_port,
|
|
@@ -135,40 +139,28 @@ module.exports = (args, cbk) => {
|
|
|
135
139
|
cipher_seed_mnemonic: res.cipher_seed_mnemonic,
|
|
136
140
|
wallet_password: Buffer.from('password', 'utf8'),
|
|
137
141
|
},
|
|
138
|
-
err => {
|
|
142
|
+
(err, res) => {
|
|
139
143
|
if (!!err) {
|
|
140
144
|
return cbk([503, 'UnexpectedErrorInitializingWallet', {err}]);
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
return cbk();
|
|
147
|
+
return cbk(null, res.admin_macaroon);
|
|
144
148
|
});
|
|
145
149
|
});
|
|
146
150
|
},
|
|
147
151
|
cbk);
|
|
148
152
|
}],
|
|
149
153
|
|
|
150
|
-
// Get the macaroon out of the docker image
|
|
151
|
-
getMacaroon: [
|
|
152
|
-
'createWallet',
|
|
153
|
-
'spawnDocker',
|
|
154
|
-
({createWallet, spawnDocker}, cbk) =>
|
|
155
|
-
{
|
|
156
|
-
return asyncRetry({interval, times}, cbk => {
|
|
157
|
-
return spawnDocker.getFile({path: macaroonPath}, cbk);
|
|
158
|
-
},
|
|
159
|
-
cbk);
|
|
160
|
-
}],
|
|
161
|
-
|
|
162
154
|
// Wait for gRPC to respond
|
|
163
155
|
waitForRpc: [
|
|
156
|
+
'createWallet',
|
|
164
157
|
'getCertificate',
|
|
165
|
-
'getMacaroon',
|
|
166
158
|
'spawnDocker',
|
|
167
|
-
({
|
|
159
|
+
({createWallet, getCertificate, spawnDocker}, cbk) =>
|
|
168
160
|
{
|
|
169
161
|
const {lnd} = authenticatedLndGrpc({
|
|
170
162
|
cert: getCertificate.file.toString('hex'),
|
|
171
|
-
macaroon:
|
|
163
|
+
macaroon: createWallet.toString('hex'),
|
|
172
164
|
socket: `localhost:${args.rpc_port}`,
|
|
173
165
|
});
|
|
174
166
|
|
|
@@ -180,17 +172,17 @@ module.exports = (args, cbk) => {
|
|
|
180
172
|
|
|
181
173
|
// LND fully spawned
|
|
182
174
|
spawned: [
|
|
175
|
+
'createWallet',
|
|
183
176
|
'getCertificate',
|
|
184
|
-
'getMacaroon',
|
|
185
177
|
'spawnDocker',
|
|
186
178
|
'waitForRpc',
|
|
187
|
-
({
|
|
179
|
+
({createWallet, getCertificate, spawnDocker, waitForRpc}, cbk) =>
|
|
188
180
|
{
|
|
189
181
|
return cbk(null, {
|
|
190
182
|
cert: getCertificate.file.toString('base64'),
|
|
191
183
|
host: spawnDocker.host,
|
|
192
184
|
kill: spawnDocker.kill,
|
|
193
|
-
macaroon:
|
|
185
|
+
macaroon: createWallet.toString('hex'),
|
|
194
186
|
public_key: waitForRpc.public_key,
|
|
195
187
|
socket: `localhost:${args.rpc_port}`,
|
|
196
188
|
});
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
11
|
-
"async": "3.2.
|
|
12
|
-
"asyncjs-util": "1.2.
|
|
11
|
+
"async": "3.2.3",
|
|
12
|
+
"asyncjs-util": "1.2.8",
|
|
13
13
|
"dockerode": "3.3.1",
|
|
14
14
|
"find-free-ports": "3.0.0",
|
|
15
|
-
"lightning": "4.
|
|
15
|
+
"lightning": "5.4.1",
|
|
16
16
|
"tar-stream": "2.2.0"
|
|
17
17
|
},
|
|
18
18
|
"description": "Spawn and control LN Docker daemons",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -j 1 test/bitcoind/*.js test/lnd/*.js"
|
|
37
37
|
},
|
|
38
|
-
"version": "2.
|
|
38
|
+
"version": "2.2.1"
|
|
39
39
|
}
|