ln-service 56.4.0 → 56.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 56.5.0
4
+
5
+ - `getWalletInfo`: Add support for LND 0.16.3
6
+
3
7
  ## 56.4.0
4
8
 
5
9
  - `getChannels`: Add `description` to show the channel description
package/README.md CHANGED
@@ -9,7 +9,7 @@ through npm.
9
9
 
10
10
  Supported LND versions:
11
11
 
12
- - v0.16.0-beta to v0.16.2-beta
12
+ - v0.16.0-beta to v0.16.3-beta
13
13
  - v0.15.2-beta to v0.15.5-beta
14
14
  - v0.14.4-beta to v0.14.5-beta
15
15
 
package/package.json CHANGED
@@ -11,31 +11,31 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.18.2",
13
13
  "invoices": "2.2.3",
14
- "lightning": "9.4.0",
14
+ "lightning": "9.5.0",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.13.0"
18
18
  },
19
19
  "description": "Interaction helper for your Lightning Network daemon",
20
20
  "devDependencies": {
21
- "@alexbosworth/blockchain": "1.3.0",
21
+ "@alexbosworth/blockchain": "1.4.0",
22
22
  "@alexbosworth/tap": "15.0.12",
23
23
  "@alexbosworth/node-fetch": "2.6.2",
24
24
  "async": "3.2.4",
25
25
  "asyncjs-util": "1.2.11",
26
26
  "bip32": "4.0.0",
27
27
  "bip66": "1.1.5",
28
- "bitcoinjs-lib": "6.1.0",
28
+ "bitcoinjs-lib": "6.1.2",
29
29
  "bn.js": "5.2.1",
30
30
  "bs58check": "3.0.1",
31
31
  "ecpair": "2.1.0",
32
- "ln-docker-daemons": "5.0.4",
32
+ "ln-docker-daemons": "5.0.5",
33
33
  "p2tr": "1.3.3",
34
34
  "portfinder": "1.0.32",
35
35
  "psbt": "2.7.2",
36
36
  "rimraf": "5.0.1",
37
37
  "secp256k1": "5.0.0",
38
- "tiny-secp256k1": "2.2.1",
38
+ "tiny-secp256k1": "2.2.2",
39
39
  "uuid": "9.0.0",
40
40
  "varuint-bitcoin": "1.1.2"
41
41
  },
@@ -57,6 +57,7 @@
57
57
  "url": "https://github.com/alexbosworth/ln-service.git"
58
58
  },
59
59
  "scripts": {
60
+ "integration-test-0.16.3": "DOCKER_LND_VERSION=v0.16.3-beta npm run test",
60
61
  "integration-test-0.16.2": "DOCKER_LND_VERSION=v0.16.2-beta npm run test",
61
62
  "integration-test-0.16.1": "DOCKER_LND_VERSION=v0.16.1-beta npm run test",
62
63
  "integration-test-0.16.0": "DOCKER_LND_VERSION=v0.16.0-beta npm run test",
@@ -68,5 +69,5 @@
68
69
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
69
70
  "test": "echo $DOCKER_LND_VERSION && tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 200 test/autopilotrpc-integration/*.js test/chainrpc-integration/*.js test/integration/*.js test/invoicesrpc-integration/*.js test/peersrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
70
71
  },
71
- "version": "56.4.0"
72
+ "version": "56.5.0"
72
73
  }
@@ -2,6 +2,7 @@ const {once} = require('events');
2
2
 
3
3
  const asyncEach = require('async/each');
4
4
  const asyncRetry = require('async/retry');
5
+ const asyncTimeout = require('async/timeout');
5
6
  const {extractTransaction} = require('psbt');
6
7
  const {spawnLightningCluster} = require('ln-docker-daemons');
7
8
  const {test} = require('@alexbosworth/tap');
@@ -63,11 +64,13 @@ test(`Forfeit pending channel`, async ({end, equal, strictSame}) => {
63
64
  const channels = [{capacity, partner_public_key: target.id}];
64
65
 
65
66
  // Propose a channel to target
66
- const proposeToTarget = await asyncRetry({interval, times}, async () => {
67
- return await race([
68
- delay(timeout),
69
- openChannels({channels, lnd, is_avoiding_broadcast: true}),
70
- ]);
67
+ const proposeToTarget = await asyncRetry({interval, times}, cbk => {
68
+ return asyncTimeout(openChannels, 1000 * 10)({
69
+ channels,
70
+ lnd,
71
+ is_avoiding_broadcast: true,
72
+ },
73
+ cbk);
71
74
  });
72
75
 
73
76
  // Setup funding for the target
@@ -93,14 +96,13 @@ test(`Forfeit pending channel`, async ({end, equal, strictSame}) => {
93
96
  });
94
97
 
95
98
  // Propose a channel to remote
96
- const proposeToRemote = await asyncRetry({interval, times}, async () => {
97
- return await race([
98
- delay(timeout),
99
- openChannels({lnd,
100
- channels: [{capacity, partner_public_key: remote.id}],
101
- is_avoiding_broadcast: true,
102
- }),
103
- ]);
99
+ const proposeToRemote = await asyncRetry({interval, times}, cbk => {
100
+ return asyncTimeout(openChannels, 1000 * 10)({
101
+ lnd,
102
+ channels: [{capacity, partner_public_key: remote.id}],
103
+ is_avoiding_broadcast: true,
104
+ },
105
+ cbk);
104
106
  });
105
107
 
106
108
  // Setup funding for the remote, using the same inputs
@@ -1,5 +1,4 @@
1
1
  const asyncRetry = require('async/retry');
2
- const {address} = require('bitcoinjs-lib');
3
2
  const {spawnLightningCluster} = require('ln-docker-daemons');
4
3
  const {test} = require('@alexbosworth/tap');
5
4
 
@@ -1,5 +1,4 @@
1
1
  const asyncRetry = require('async/retry');
2
- const {Transaction} = require('bitcoinjs-lib');
3
2
 
4
3
  const {getUtxos} = require('./../../');
5
4
 
@@ -10,9 +9,8 @@ const times = 10;
10
9
 
11
10
  {
12
11
  [confirmations]: <Confirmations Count Number>
13
- [id]: <Transaction Id Hex String>
12
+ id: <Transaction Id Hex String>
14
13
  lnd: <Authenticated LND gRPC API Object>
15
- [transaction]: <Raw Transaction Hex String>
16
14
  }
17
15
 
18
16
  @returns via cbk
@@ -26,24 +24,22 @@ const times = 10;
26
24
  transaction_vout: <Transaction Output Index Number>
27
25
  }
28
26
  */
29
- module.exports = ({confirmations, id, lnd, transaction}, cbk) => {
27
+ module.exports = ({confirmations, id, lnd}, cbk) => {
30
28
  if (!lnd || !lnd.default) {
31
29
  return cbk([400, 'ExpectedAuthenticatedLndToWaitForUtxo']);
32
30
  }
33
31
 
34
- if (!transaction && !id) {
32
+ if (!id) {
35
33
  return cbk([400, 'ExpectedTransactionOrIdToWaitForUtxo']);
36
34
  }
37
35
 
38
- const txId = id || Transaction.fromHex(transaction).getId();
39
-
40
36
  return asyncRetry({interval, times}, cbk => {
41
37
  return getUtxos({lnd}, (err, res) => {
42
38
  if (!!err) {
43
39
  return cbk(err);
44
40
  }
45
41
 
46
- const utxo = res.utxos.find(n => n.transaction_id === txId);
42
+ const utxo = res.utxos.find(n => n.transaction_id === id);
47
43
 
48
44
  if (!utxo) {
49
45
  return cbk([503, 'ExpectedToFindUtxoButUtxoNotFound']);
@@ -5,7 +5,7 @@ const {createPsbt} = require('psbt');
5
5
  const {hashForTree} = require('p2tr');
6
6
  const {leafHash} = require('p2tr');
7
7
  const {networks} = require('bitcoinjs-lib');
8
- const {script} = require('bitcoinjs-lib');
8
+ const {scriptElementsAsScript} = require('@alexbosworth/blockchain');
9
9
  const {spawnLightningCluster} = require('ln-docker-daemons');
10
10
  const {test} = require('@alexbosworth/tap');
11
11
  const {Transaction} = require('bitcoinjs-lib');
@@ -21,7 +21,7 @@ const {getUtxos} = require('./../../');
21
21
  const {signPsbt} = require('./../../');
22
22
  const {updateGroupSigningSession} = require('./../../');
23
23
 
24
- const {compile} = script;
24
+ const compile = elements => scriptElementsAsScript({elements}).script;
25
25
  const count = 100;
26
26
  const defaultInternalKey = '0350929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0';
27
27
  const {from} = Buffer;
@@ -189,7 +189,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
189
189
 
190
190
  const witnessScript = compile([xOnlyUnused, OP_CHECKSIG]);
191
191
 
192
- const branches = [{script: witnessScript.toString('hex')}];
192
+ const branches = [{script: witnessScript}];
193
193
 
194
194
  const {hash} = hashForTree({branches});
195
195
 
@@ -329,7 +329,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
329
329
 
330
330
  const witnessScript = compile([scriptKey, OP_CHECKSIG]);
331
331
 
332
- const branches = [{script: witnessScript.toString('hex')}];
332
+ const branches = [{script: witnessScript}];
333
333
 
334
334
  const {hash} = hashForTree({branches});
335
335
 
@@ -376,7 +376,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
376
376
  [hexAsBuffer(output.script)],
377
377
  [tokens],
378
378
  Transaction.SIGHASH_DEFAULT,
379
- hexAsBuffer(leafHash({script: witnessScript.toString('hex')}).hash),
379
+ hexAsBuffer(leafHash({script: witnessScript}).hash),
380
380
  );
381
381
  });
382
382
 
@@ -404,7 +404,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
404
404
 
405
405
  const {block} = controlBlock({
406
406
  external_key: output.external_key,
407
- leaf_script: witnessScript.toString('hex'),
407
+ leaf_script: witnessScript,
408
408
  script_branches: branches,
409
409
  });
410
410
 
@@ -412,7 +412,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
412
412
  tx.ins.forEach((input, i) => {
413
413
  return tx.setWitness(i, [
414
414
  hexAsBuffer(signature),
415
- witnessScript,
415
+ hexAsBuffer(witnessScript),
416
416
  hexAsBuffer(block),
417
417
  ]);
418
418
  });
@@ -5,6 +5,7 @@ const {createPsbt} = require('psbt');
5
5
  const {hashForTree} = require('p2tr');
6
6
  const {networks} = require('bitcoinjs-lib');
7
7
  const {script} = require('bitcoinjs-lib');
8
+ const {scriptElementsAsScript} = require('@alexbosworth/blockchain');
8
9
  const {spawnLightningCluster} = require('ln-docker-daemons');
9
10
  const {test} = require('@alexbosworth/tap');
10
11
  const tinysecp = require('tiny-secp256k1');
@@ -20,7 +21,7 @@ const {getUtxos} = require('./../../');
20
21
  const {signPsbt} = require('./../../');
21
22
  const {signTransaction} = require('./../../');
22
23
 
23
- const {compile} = script;
24
+ const compile = elements => scriptElementsAsScript({elements}).script;
24
25
  const count = 100;
25
26
  const defaultInternalKey = '0350929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0';
26
27
  const {fromHex} = Transaction;
@@ -93,7 +94,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
93
94
 
94
95
  const witnessScript = compile([publicKey.slice(1), OP_CHECKSIG]);
95
96
 
96
- const branches = [{script: witnessScript.toString('hex')}];
97
+ const branches = [{script: witnessScript}];
97
98
 
98
99
  const {hash} = hashForTree({branches});
99
100
 
@@ -144,7 +145,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
144
145
  root_hash: hash,
145
146
  sighash: Transaction.SIGHASH_DEFAULT,
146
147
  vin: 0,
147
- witness_script: witnessScript.toString('hex'),
148
+ witness_script: witnessScript,
148
149
  }],
149
150
  transaction: tx.toHex(),
150
151
  });
@@ -153,7 +154,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
153
154
 
154
155
  const {block} = controlBlock({
155
156
  external_key: output.external_key,
156
- leaf_script: witnessScript.toString('hex'),
157
+ leaf_script: witnessScript,
157
158
  script_branches: branches,
158
159
  });
159
160
 
@@ -161,7 +162,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
161
162
  tx.ins.forEach((input, i) => {
162
163
  return tx.setWitness(i, [
163
164
  signature,
164
- witnessScript,
165
+ hexAsBuffer(witnessScript),
165
166
  hexAsBuffer(block),
166
167
  ]);
167
168
  });
@@ -193,7 +194,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
193
194
 
194
195
  const witnessScript = compile([unusedKey.publicKey.slice(1), OP_CHECKSIG]);
195
196
 
196
- const branches = [{script: witnessScript.toString('hex')}];
197
+ const branches = [{script: witnessScript}];
197
198
 
198
199
  const {hash} = hashForTree({branches});
199
200
 
@@ -8,7 +8,7 @@ const {leafHash} = require('p2tr');
8
8
  const {networks} = require('bitcoinjs-lib');
9
9
  const {pointAdd} = require('tiny-secp256k1');
10
10
  const {privateAdd} = require('tiny-secp256k1');
11
- const {script} = require('bitcoinjs-lib');
11
+ const {scriptElementsAsScript} = require('@alexbosworth/blockchain');
12
12
  const {signHash} = require('p2tr');
13
13
  const {signSchnorr} = require('tiny-secp256k1');
14
14
  const {spawnLightningCluster} = require('ln-docker-daemons');
@@ -27,7 +27,7 @@ const {sendToChainAddress} = require('./../../');
27
27
  const {signPsbt} = require('./../../');
28
28
 
29
29
  const chainAddressRowType = 'chain_address';
30
- const {compile} = script;
30
+ const compile = elements => scriptElementsAsScript({elements}).script;
31
31
  const confirmationCount = 6;
32
32
  const count = 100;
33
33
  const defaultInternalKey = '0350929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0';
@@ -135,7 +135,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
135
135
 
136
136
  const witnessScript = compile([unusedKey.publicKey.slice(1), OP_CHECKSIG]);
137
137
 
138
- const branches = [{script: witnessScript.toString('hex')}];
138
+ const branches = [{script: witnessScript}];
139
139
 
140
140
  const {hash} = hashForTree({branches});
141
141
 
@@ -231,7 +231,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
231
231
 
232
232
  const witnessScript = compile([keyPair.publicKey.slice(1), OP_CHECKSIG]);
233
233
 
234
- const branches = [{script: witnessScript.toString('hex')}];
234
+ const branches = [{script: witnessScript}];
235
235
 
236
236
  const {hash} = hashForTree({branches});
237
237
 
@@ -278,7 +278,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
278
278
  [hexAsBuffer(output.script)],
279
279
  [tokens],
280
280
  Transaction.SIGHASH_DEFAULT,
281
- hexAsBuffer(leafHash({script: witnessScript.toString('hex')}).hash),
281
+ hexAsBuffer(leafHash({script: witnessScript}).hash),
282
282
  );
283
283
  });
284
284
 
@@ -286,7 +286,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
286
286
 
287
287
  const {block} = controlBlock({
288
288
  external_key: output.external_key,
289
- leaf_script: witnessScript.toString('hex'),
289
+ leaf_script: witnessScript,
290
290
  script_branches: branches,
291
291
  });
292
292
 
@@ -294,7 +294,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
294
294
  tx.ins.forEach((input, i) => {
295
295
  return tx.setWitness(i, [
296
296
  signature,
297
- witnessScript,
297
+ hexAsBuffer(witnessScript),
298
298
  hexAsBuffer(block),
299
299
  ]);
300
300
  });
@@ -1,6 +1,6 @@
1
1
  const asyncRetry = require('async/retry');
2
2
  const {componentsOfTransaction} = require('@alexbosworth/blockchain');
3
- const {script} = require('bitcoinjs-lib');
3
+ const {scriptElementsAsScript} = require('@alexbosworth/blockchain');
4
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
5
5
  const {test} = require('@alexbosworth/tap');
6
6
 
@@ -9,7 +9,6 @@ const {sendToChainOutputScripts} = require('./../../');
9
9
 
10
10
  const asBuf = hex => Buffer.from(hex, 'hex');
11
11
  const asHex = buffer => buffer.toString('hex');
12
- const {compile} = script;
13
12
  const confirmationCount = 6;
14
13
  const count = 100;
15
14
  const interval = 10;
@@ -26,9 +25,11 @@ test(`Send to chain output scripts`, async ({end, equal, strictSame}) => {
26
25
 
27
26
  await generate({count});
28
27
 
29
- const script = [].concat(OP_RETURN).concat(asBuf(target.id));
28
+ const elements = [].concat(OP_RETURN).concat(asBuf(target.id));
30
29
 
31
- const sendTo = [{tokens, script: asHex(compile(script))}];
30
+ const {script} = scriptElementsAsScript({elements});
31
+
32
+ const sendTo = [{script, tokens}];
32
33
 
33
34
  const sent = await sendToChainOutputScripts({lnd, send_to: sendTo});
34
35
 
@@ -1,9 +1,9 @@
1
1
  const asyncRetry = require('async/retry');
2
+ const {componentsOfTransaction} = require('@alexbosworth/blockchain');
2
3
  const {decodePsbt} = require('psbt');
3
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
4
5
  const {test} = require('@alexbosworth/tap');
5
6
  const tinysecp = require('tiny-secp256k1');
6
- const {Transaction} = require('bitcoinjs-lib');
7
7
 
8
8
  const {broadcastChainTransaction} = require('./../../');
9
9
  const {createChainAddress} = require('./../../');
@@ -70,7 +70,7 @@ test(`Sign PSBT`, async ({end, equal}) => {
70
70
 
71
71
  const finalized = await signPsbt({lnd: control.lnd, psbt: funded.psbt});
72
72
 
73
- const tx = Transaction.fromHex(finalized.transaction);
73
+ const tx = componentsOfTransaction({transaction: finalized.transaction});
74
74
 
75
75
  const decoded = decodePsbt({ecp, psbt: finalized.psbt});
76
76