ln-service 57.5.1 → 57.7.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,13 @@
1
1
  # Versions
2
2
 
3
+ ## 57.7.0
4
+
5
+ - `getPendingChannels`: Add support for `close_transaction` to return raw tx
6
+
7
+ ## 57.6.0
8
+
9
+ - `addAdvertisedFeature`: Add method to advertise a feature bit support
10
+
3
11
  ## 57.5.0
4
12
 
5
13
  - `getSweepTransactions`: Add `after` to scope sweep result set
package/README.md CHANGED
@@ -135,6 +135,7 @@ for `unlocker` methods.
135
135
 
136
136
  ## All Methods
137
137
 
138
+ - [addAdvertisedFeature](#addadvertisedfeature) - Advertise a supported feature
138
139
  - [addExternalSocket](#addexternalsocket) - Advertise a new p2p host:ip address
139
140
  - [addPeer](#addpeer) - Connect to a peer
140
141
  - [authenticatedLndGrpc](#authenticatedlndgrpc) - LND API Object
@@ -329,6 +330,32 @@ for `unlocker` methods.
329
330
  - [probing](https://npmjs.com/package/probing) - payment probing utilities
330
331
  - [psbt](https://www.npmjs.com/package/psbt) - BIP 174 PSBT utilities
331
332
 
333
+ ### addAdvertisedFeature
334
+
335
+ Add an advertised feature to the graph node announcement
336
+
337
+ Note: this method is not supported in LND versions 0.14.5 and below
338
+
339
+ Requires LND built with `peersrpc` build tag
340
+
341
+ Requires `peers:write` permissions
342
+
343
+ {
344
+ feature: <BOLT 09 Feature Bit Number>
345
+ lnd: <Authenticated LND API Object>
346
+ }
347
+
348
+ @returns via cbk or Promise
349
+
350
+ Example:
351
+
352
+ ```node
353
+ const {addAdvertisedFeature} = require('ln-service');
354
+
355
+ // Add a new supported feature to the graph node announcement
356
+ await addAdvertisedFeature({lnd, feature: 12345});
357
+ ```
358
+
332
359
  ### addExternalSocket
333
360
 
334
361
  Add a new advertised p2p socket address
@@ -3074,6 +3101,8 @@ Requires `offchain:read` permission
3074
3101
 
3075
3102
  `blocks_until_expiry` is not supported in LND 0.16.4 or before
3076
3103
 
3104
+ `close_transaction` is not supported in LND 0.17.4 or before
3105
+
3077
3106
  {
3078
3107
  lnd: <Authenticated LND API Object>
3079
3108
  }
@@ -3083,6 +3112,7 @@ Requires `offchain:read` permission
3083
3112
  pending_channels: [{
3084
3113
  [blocks_until_expiry]: <Blocks Until Open Channel Expires Number>
3085
3114
  capacity: <Channel Capacity Tokens Number>
3115
+ [close_transaction]: <Channel Closing Raw Transaction Hex String>
3086
3116
  [close_transaction_id]: <Channel Closing Transaction Id String>
3087
3117
  [description]: <Channel Description String>
3088
3118
  is_active: <Channel Is Active Bool>
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const {addAdvertisedFeature} = require('lightning');
1
2
  const {addExternalSocket} = require('lightning');
2
3
  const {addPeer} = require('lightning');
3
4
  const {authenticatedLndGrpc} = require('lightning');
@@ -158,6 +159,7 @@ const {verifyChainAddressMessage} = require('lightning');
158
159
  const {verifyMessage} = require('lightning');
159
160
 
160
161
  module.exports = {
162
+ addAdvertisedFeature,
161
163
  addExternalSocket,
162
164
  addPeer,
163
165
  authenticatedLndGrpc,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "bolt07": "1.8.4",
11
11
  "invoices": "3.0.0",
12
- "lightning": "10.5.1",
12
+ "lightning": "10.7.0",
13
13
  "macaroon": "3.0.4"
14
14
  },
15
15
  "description": "Interaction helper for your Lightning Network daemon",
@@ -24,7 +24,7 @@
24
24
  "bn.js": "5.2.1",
25
25
  "bs58check": "3.0.1",
26
26
  "ecpair": "2.1.0",
27
- "ln-docker-daemons": "6.0.10",
27
+ "ln-docker-daemons": "6.0.11",
28
28
  "p2tr": "2.0.0",
29
29
  "portfinder": "1.0.32",
30
30
  "psbt": "3.0.0",
@@ -69,5 +69,5 @@
69
69
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
70
70
  "test": "echo $DOCKER_LND_VERSION && node test/runner"
71
71
  },
72
- "version": "57.5.1"
72
+ "version": "57.7.0"
73
73
  }
@@ -1,7 +1,10 @@
1
+ const {equal} = require('node:assert').strict;
1
2
  const {strictEqual} = require('node:assert').strict;
2
3
  const test = require('node:test');
3
4
 
4
5
  const asyncRetry = require('async/retry');
6
+ const {componentsOfTransaction} = require('@alexbosworth/blockchain');
7
+ const {idForTransactionComponents} = require('@alexbosworth/blockchain');
5
8
  const {setupChannel} = require('ln-docker-daemons');
6
9
  const {spawnLightningCluster} = require('ln-docker-daemons');
7
10
 
@@ -11,6 +14,7 @@ const {getWalletInfo} = require('./../../');
11
14
 
12
15
  const defaultFee = 1e3;
13
16
  const give = 1e4;
17
+ const hexAsBuffer = hex => Buffer.from(hex, 'hex');
14
18
  const interval = 10;
15
19
  const size = 2;
16
20
  const times = 2000;
@@ -55,6 +59,30 @@ test(`Get pending channels`, async () => {
55
59
  return {channel};
56
60
  });
57
61
 
62
+ const transaction = channel.close_transaction;
63
+
64
+ // LND 0.17.4 and below do not support close_transaction
65
+ if (!!transaction) {
66
+ const components = componentsOfTransaction({transaction});
67
+
68
+ const closing = idForTransactionComponents({
69
+ inputs: components.inputs.map(input => ({
70
+ hash: hexAsBuffer(input.id).reverse(),
71
+ script: hexAsBuffer(input.script),
72
+ sequence: input.sequence,
73
+ vout: input.vout,
74
+ })),
75
+ locktime: components.locktime,
76
+ outputs: components.outputs.map(output => ({
77
+ script: hexAsBuffer(output.script),
78
+ tokens: output.tokens,
79
+ })),
80
+ version: components.version,
81
+ });
82
+
83
+ equal(closing.id, channel.close_transaction_id, 'Got closing tx');
84
+ }
85
+
58
86
  if (channel.is_partner_initiated !== undefined) {
59
87
  strictEqual(channel.is_partner_initiated, false, 'Channel initiated');
60
88
  }
@@ -82,11 +110,13 @@ test(`Get pending channels`, async () => {
82
110
  if (!!channel.remote_balance) {
83
111
  strictEqual(channel.remote_balance, give, 'Opposing channel balance');
84
112
  }
113
+
114
+ await kill({});
85
115
  } catch (err) {
116
+ await kill({});
117
+
86
118
  strictEqual(err, null, 'Expected no error');
87
119
  }
88
120
 
89
- await kill({});
90
-
91
121
  return;
92
122
  });
@@ -0,0 +1,43 @@
1
+ const {deepEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const {spawnLightningCluster} = require('ln-docker-daemons');
5
+
6
+ const {addAdvertisedFeature} = require('./../../');
7
+ const {getWalletInfo} = require('./../../');
8
+
9
+ const feature = 12345;
10
+
11
+ // Adding a feature should result in an updated advertised feature
12
+ test(`Add external socket`, async () => {
13
+ const {kill, nodes} = await spawnLightningCluster({});
14
+
15
+ const [{id, lnd}] = nodes;
16
+
17
+ try {
18
+ await addAdvertisedFeature({feature, lnd});
19
+
20
+ const {features} = await getWalletInfo({lnd});
21
+
22
+ const added = features.find(n => n.bit === feature);
23
+
24
+ deepEqual(
25
+ added,
26
+ {
27
+ bit: 12345,
28
+ is_known: false,
29
+ is_required: false,
30
+ type: undefined,
31
+ },
32
+ 'Feature bit is advertised'
33
+ );
34
+
35
+ await kill({});
36
+ } catch (err) {
37
+ await kill({});
38
+
39
+ deepEqual(err, [400, 'ExpectedPeersRpcLndBuildTagToAddFeature']);
40
+ }
41
+
42
+ return;
43
+ });