ln-service 54.2.5 → 54.3.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
+ ## 54.3.0
4
+
5
+ - `getSettlementStatus`: Add method to lookup received htlc settlement status
6
+
7
+ ## 54.2.6
8
+
9
+ - `getWalletInfo`: Add support for LND 0.14.5
10
+
3
11
  ## 54.2.5
4
12
 
5
13
  - `getWalletInfo`: Add support for LND 0.15.4
package/README.md CHANGED
@@ -10,7 +10,7 @@ through npm.
10
10
  Supported LND versions:
11
11
 
12
12
  - v0.15.2-beta to v0.15.4-beta
13
- - v0.14.4-beta
13
+ - v0.14.4-beta to v0.14.5-beta
14
14
 
15
15
  For typescript-ready methods, check out https://github.com/alexbosworth/lightning#readme
16
16
 
@@ -177,6 +177,7 @@ for `unlocker` methods.
177
177
  - [getRouteConfidence](#getrouteconfidence) - Get confidence in a route
178
178
  - [getRouteThroughHops](#getroutethroughhops) - Get a route through nodes
179
179
  - [getRouteToDestination](#getroutetodestination) - Get a route to a destination
180
+ - [getSettlementStatus](#getsettlementstatus) - Get status of a received HTLC
180
181
  - [getSweepTransactions](#getsweeptransactions) - Get transactions sweeping to
181
182
  self
182
183
  - [getTowerServerInfo](#gettowerserverinfo) - Get information about tower server
@@ -290,7 +291,7 @@ for `unlocker` methods.
290
291
 
291
292
  Add a new advertised p2p socket address
292
293
 
293
- Note: this method is not supported in LND versions 0.14.3 and below
294
+ Note: this method is not supported in LND versions 0.14.5 and below
294
295
 
295
296
  Requires LND built with `peersrpc` build tag
296
297
 
@@ -391,7 +392,7 @@ Requires LND built with `signrpc`, `walletrpc` build tags
391
392
 
392
393
  Requires `address:read`, `signer:generate` permissions
393
394
 
394
- This method is not supported in LND 0.14.3 and below
395
+ This method is not supported in LND 0.14.5 and below
395
396
 
396
397
  {
397
398
  lnd: <Authenticated LND API Object>
@@ -593,7 +594,7 @@ Create a new receive address.
593
594
 
594
595
  Requires `address:write` permission
595
596
 
596
- LND 0.14.3 and below do not support p2tr addresses
597
+ LND 0.14.5 and below do not support p2tr addresses
597
598
 
598
599
  {
599
600
  [format]: <Receive Address Type String> // "np2wpkh" || "p2tr" || "p2wpkh"
@@ -1175,7 +1176,7 @@ Requires LND built with `signrpc` build tag
1175
1176
 
1176
1177
  Requires `signer:generate` permission
1177
1178
 
1178
- This method is not supported in LND 0.14.3 and below
1179
+ This method is not supported in LND 0.14.5 and below
1179
1180
 
1180
1181
  {
1181
1182
  id: <Session Id Hex String>
@@ -3075,7 +3076,7 @@ Call this iteratively after failed route attempts to get new routes
3075
3076
 
3076
3077
  Requires `info:read` permission
3077
3078
 
3078
- Preferred `confidence` is not supported on LND 0.14.3 and below
3079
+ Preferred `confidence` is not supported on LND 0.14.5 and below
3079
3080
 
3080
3081
  {
3081
3082
  [cltv_delta]: <Final CLTV Delta Number>
@@ -3153,6 +3154,43 @@ const {route} = await getRouteToDestination({destination, lnd, tokens});
3153
3154
  await payViaRoutes({lnd, routes: [route]});
3154
3155
  ```
3155
3156
 
3157
+ ### getSettlementStatus
3158
+
3159
+ Get the settlement status of a received HTLC
3160
+
3161
+ Note: this method is not supported in LND versions 0.15.4 and below
3162
+
3163
+ Requires `offchain:read` permissions
3164
+
3165
+ {
3166
+ channel: <Standard Format Channel Id String>
3167
+ lnd: <Authenticated LND API Object>
3168
+ payment: <Payment Id Number>
3169
+ }
3170
+
3171
+ @returns via cbk or Promise
3172
+ {
3173
+ is_onchain: <Payment Went to Chain Bool>
3174
+ is_settled: <Payment Is Settled Into Non-HTLC Balance Bool>
3175
+ }
3176
+
3177
+ Example:
3178
+
3179
+ ```node
3180
+ const {getSettlementStatus} = require('ln-service');
3181
+ const {getChannels} = require('ln-service');
3182
+
3183
+ const [channel] = (await getChannels({lnd})).channels;
3184
+
3185
+ const settlement = await getSettlementStatus({
3186
+ lnd,
3187
+ channel: channel.id,
3188
+ payment: 0,
3189
+ });
3190
+
3191
+ const isSettledOffchain = settlement.is_settled && !settlement.is_onchain;
3192
+ ```
3193
+
3156
3194
  ### getSweepTransactions
3157
3195
 
3158
3196
  Get self-transfer spend transactions related to channel closes
@@ -3479,7 +3517,7 @@ Determine if a payment destination is actually payable by probing it
3479
3517
 
3480
3518
  Requires `offchain:write` permission
3481
3519
 
3482
- Preferred `confidence` is not supported on LND 0.14.3 and below
3520
+ Preferred `confidence` is not supported on LND 0.14.5 and below
3483
3521
 
3484
3522
  {
3485
3523
  [cltv_delta]: <Final CLTV Delta Number>
@@ -3569,8 +3607,8 @@ If give_tokens is set, it is a gift and it does not alter the capacity
3569
3607
 
3570
3608
  Requires `offchain:write`, `onchain:write`, `peers:write` permissions
3571
3609
 
3572
- `base_fee_mtokens` is not supported on LND 0.15.3 and below
3573
- `fee_rate` is not supported on LND 0.15.3 and below
3610
+ `base_fee_mtokens` is not supported on LND 0.15.4 and below
3611
+ `fee_rate` is not supported on LND 0.15.4 and below
3574
3612
 
3575
3613
  {
3576
3614
  [base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
@@ -3622,8 +3660,8 @@ after the funding step.
3622
3660
  `--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
3623
3661
  as well as a channel open request listener to accept the trusted funding.
3624
3662
 
3625
- `base_fee_mtokens` is not supported on LND 0.15.3 and below
3626
- `fee_rate` is not supported on LND 0.15.3 and below
3663
+ `base_fee_mtokens` is not supported on LND 0.15.4 and below
3664
+ `fee_rate` is not supported on LND 0.15.4 and below
3627
3665
 
3628
3666
  {
3629
3667
  channels: [{
@@ -3779,7 +3817,7 @@ Requires `offchain:write` permission
3779
3817
 
3780
3818
  `max_path_mtokens` is not supported in LND 0.12.0 or below
3781
3819
 
3782
- Preferred `confidence` is not supported on LND 0.14.3 and below
3820
+ Preferred `confidence` is not supported on LND 0.14.5 and below
3783
3821
 
3784
3822
  {
3785
3823
  [confidence]: <Preferred Route Confidence Number Out of One Million Number>
@@ -3869,7 +3907,7 @@ Requires `offchain:write` permission
3869
3907
 
3870
3908
  `max_path_mtokens` is not supported in LND 0.12.0 or below
3871
3909
 
3872
- Preferred `confidence` is not supported on LND 0.14.3 and below
3910
+ Preferred `confidence` is not supported on LND 0.14.5 and below
3873
3911
 
3874
3912
  {
3875
3913
  [cltv_delta]: <Final CLTV Delta Number>
@@ -3959,7 +3997,7 @@ Requires `offchain:write` permission
3959
3997
 
3960
3998
  `max_path_mtokens` is not supported in LND 0.12.0 or below
3961
3999
 
3962
- Preferred `confidence` is not supported on LND 0.14.3 and below
4000
+ Preferred `confidence` is not supported on LND 0.14.5 and below
3963
4001
 
3964
4002
  {
3965
4003
  [confidence]: <Preferred Route Confidence Number Out of One Million Number>
@@ -4164,7 +4202,7 @@ If `total_mtokens` are specified, a `payment` nonce is required.
4164
4202
 
4165
4203
  Requires `offchain:write` permission
4166
4204
 
4167
- Preferred `confidence` is not supported on LND 0.14.3 and below
4205
+ Preferred `confidence` is not supported on LND 0.14.5 and below
4168
4206
 
4169
4207
  {
4170
4208
  [cltv_delta]: <Final CLTV Delta Number>
@@ -4350,7 +4388,7 @@ await recoverFundsFromChannels({backup, lnd});
4350
4388
 
4351
4389
  Remove an existing advertised p2p socket address
4352
4390
 
4353
- Note: this method is not supported in LND versions 0.14.3 and below
4391
+ Note: this method is not supported in LND versions 0.14.5 and below
4354
4392
 
4355
4393
  Requires LND built with `peersrpc` build tag
4356
4394
 
@@ -4867,8 +4905,8 @@ Requires LND built with `signrpc` build tag
4867
4905
 
4868
4906
  Requires `signer:generate` permission
4869
4907
 
4870
- `root_hash` is not supported in LND 0.14.3 and below
4871
- `spending` is not supported in LND 0.14.3 and below
4908
+ `root_hash` is not supported in LND 0.14.5 and below
4909
+ `spending` is not supported in LND 0.14.5 and below
4872
4910
 
4873
4911
  {
4874
4912
  inputs: [{
@@ -5042,7 +5080,7 @@ Requires LND built with `chainrpc` build tag
5042
5080
 
5043
5081
  Requires `onchain:read` permission
5044
5082
 
5045
- Subscribing to P2TR outputs is not supported in LND 0.14.3 and below
5083
+ Subscribing to P2TR outputs is not supported in LND 0.14.5 and below
5046
5084
 
5047
5085
  {
5048
5086
  [bech32_address]: <Bech32 P2WPKH or P2WSH Address String>
@@ -5770,7 +5808,7 @@ Requires `offchain:write` permission
5770
5808
 
5771
5809
  `max_path_mtokens` is not supported in LND 0.12.0 or below
5772
5810
 
5773
- Preferred `confidence` is not supported on LND 0.14.3 and below
5811
+ Preferred `confidence` is not supported on LND 0.14.5 and below
5774
5812
 
5775
5813
  {
5776
5814
  [cltv_delta]: <Final CLTV Delta Number>
@@ -5936,7 +5974,7 @@ Requires `offchain:write` permission
5936
5974
 
5937
5975
  `max_path_mtokens` is not supported in LND 0.12.0 or below
5938
5976
 
5939
- Preferred `confidence` is not supported on LND 0.14.3 and below
5977
+ Preferred `confidence` is not supported on LND 0.14.5 and below
5940
5978
 
5941
5979
  {
5942
5980
  [confidence]: <Preferred Route Confidence Number Out of One Million Number>
@@ -6272,7 +6310,7 @@ Subscribe to outgoing payments
6272
6310
 
6273
6311
  Requires `offchain:read` permission
6274
6312
 
6275
- Note: Method not supported on LND 0.15.3 and below
6313
+ Note: Method not supported on LND 0.15.4 and below
6276
6314
 
6277
6315
  {
6278
6316
  lnd: <Authenticated LND API Object>
@@ -6452,7 +6490,7 @@ Subscribe to a probe attempt
6452
6490
 
6453
6491
  Requires `offchain:write` permission
6454
6492
 
6455
- Preferred `confidence` is not supported on LND 0.14.3 and below
6493
+ Preferred `confidence` is not supported on LND 0.14.5 and below
6456
6494
 
6457
6495
  {
6458
6496
  [cltv_delta]: <Final CLTV Delta Number>
@@ -6949,7 +6987,7 @@ await unlockWallet({lnd, password: 'walletSecretPassword'});
6949
6987
 
6950
6988
  Update the node alias as advertised in the graph
6951
6989
 
6952
- Note: this method is not supported in LND versions 0.14.3 and below
6990
+ Note: this method is not supported in LND versions 0.14.5 and below
6953
6991
 
6954
6992
  Requires LND built with `peersrpc` build tag
6955
6993
 
@@ -7003,7 +7041,7 @@ await updateChainTransaction({id, lnd, description: 'First transaction'});
7003
7041
 
7004
7042
  Update the node color as advertised in the graph
7005
7043
 
7006
- Note: this method is not supported in LND versions 0.14.3 and below
7044
+ Note: this method is not supported in LND versions 0.14.5 and below
7007
7045
 
7008
7046
  Requires LND built with `peersrpc` build tag
7009
7047
 
@@ -7062,7 +7100,7 @@ Requires LND built with `signrpc` build tag
7062
7100
 
7063
7101
  Requires `signer:generate` permission
7064
7102
 
7065
- This method is not supported in LND 0.14.3 and below
7103
+ This method is not supported in LND 0.14.5 and below
7066
7104
 
7067
7105
  {
7068
7106
  hash: <Hash to Sign Hex String>
package/index.js CHANGED
@@ -70,6 +70,7 @@ const {getPublicKey} = require('lightning');
70
70
  const {getRouteConfidence} = require('lightning');
71
71
  const {getRouteThroughHops} = require('lightning');
72
72
  const {getRouteToDestination} = require('lightning');
73
+ const {getSettlementStatus} = require('lightning');
73
74
  const {getSweepTransactions} = require('lightning');
74
75
  const {getTowerServerInfo} = require('lightning');
75
76
  const {getUtxos} = require('lightning');
@@ -221,6 +222,7 @@ module.exports = {
221
222
  getRouteConfidence,
222
223
  getRouteThroughHops,
223
224
  getRouteToDestination,
225
+ getSettlementStatus,
224
226
  getSweepTransactions,
225
227
  getTowerServerInfo,
226
228
  getUtxos,
package/package.json CHANGED
@@ -10,11 +10,11 @@
10
10
  "bolt07": "1.8.2",
11
11
  "cors": "2.8.5",
12
12
  "express": "4.18.2",
13
- "invoices": "2.2.0",
14
- "lightning": "6.2.6",
13
+ "invoices": "2.2.1",
14
+ "lightning": "6.3.0",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
- "ws": "8.10.0"
17
+ "ws": "8.11.0"
18
18
  },
19
19
  "description": "Interaction helper for your Lightning Network daemon",
20
20
  "devDependencies": {
@@ -28,7 +28,7 @@
28
28
  "bn.js": "5.2.1",
29
29
  "bs58check": "2.1.2",
30
30
  "ecpair": "2.1.0",
31
- "ln-docker-daemons": "3.1.4",
31
+ "ln-docker-daemons": "3.1.5",
32
32
  "p2tr": "1.3.2",
33
33
  "portfinder": "1.0.32",
34
34
  "psbt": "2.7.1",
@@ -59,8 +59,9 @@
59
59
  "integration-test-0.15.4": "DOCKER_LND_VERSION=v0.15.4-beta npm run test",
60
60
  "integration-test-0.15.3": "DOCKER_LND_VERSION=v0.15.3-beta npm run test",
61
61
  "integration-test-0.15.2": "DOCKER_LND_VERSION=v0.15.2-beta npm run test",
62
+ "integration-test-0.14.5": "DOCKER_LND_VERSION=v0.14.5-beta npm run test",
62
63
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
63
64
  "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"
64
65
  },
65
- "version": "54.2.5"
66
+ "version": "54.3.0"
66
67
  }
@@ -40,7 +40,7 @@ test(`Create address results in address creation`, async ({end, equal}) => {
40
40
 
41
41
  equal(address.startsWith(prefixForV1), true, 'A taproot address is made');
42
42
  } catch (err) {
43
- // LND 0.14.3 and below do not support TR addresses
43
+ // LND 0.14.5 and below do not support TR addresses
44
44
  const [code] = err;
45
45
 
46
46
  equal(code, 501, 'Taproot addresses are unsupported');
@@ -178,7 +178,7 @@ test(`Get pending channels`, async ({end, equal}) => {
178
178
  equal(forceClose.received, 0, 'No receive amount');
179
179
  equal(forceClose.recovered_tokens, undefined, 'No recovered amount');
180
180
 
181
- // LND 0.14.3 and below do not support remote balance info
181
+ // LND 0.14.5 and below do not support remote balance info
182
182
  if (!!forceClose.remote_balance) {
183
183
  equal(forceClose.remote_balance, giftTokens, 'Got gift remote balance');
184
184
  } else {
@@ -0,0 +1,65 @@
1
+ const asyncRetry = require('async/retry');
2
+ const {setupChannel} = require('ln-docker-daemons');
3
+ const {spawnLightningCluster} = require('ln-docker-daemons');
4
+ const {test} = require('@alexbosworth/tap');
5
+
6
+ const {createInvoice} = require('./../../');
7
+ const {getSettlementStatus} = require('./../../');
8
+ const {pay} = require('./../../');
9
+
10
+ const fakeChannelId = '1x1x1';
11
+ const interval = 100;
12
+ const size = 2;
13
+ const times = 1000;
14
+ const tokens = 100;
15
+
16
+ // Get the settlement status of an HTLC
17
+ test(`Get settlement status`, async ({end, equal, strictSame}) => {
18
+ const {kill, nodes} = await spawnLightningCluster({size});
19
+
20
+ const [{generate, lnd}, target] = nodes;
21
+
22
+ // LND 0.15.4 and below do not support settlement status lookups
23
+ try {
24
+ await getSettlementStatus({
25
+ lnd: target.lnd,
26
+ channel: fakeChannelId,
27
+ payment: Number(),
28
+ });
29
+ } catch (err) {
30
+ const [code, message] = err;
31
+
32
+ if (code !== 404) {
33
+ equal(code, 501, 'Method unsupported');
34
+ equal(message, 'LookupHtlcMethodUnsupported', 'Got unsupported message');
35
+
36
+ await kill({});
37
+
38
+ return end();
39
+ }
40
+ }
41
+
42
+ try {
43
+ const channel = await setupChannel({generate, lnd, to: target});
44
+
45
+ const {request} = await createInvoice({tokens, lnd: target.lnd});
46
+
47
+ const payment = await pay({lnd, request});
48
+
49
+ const settlement = await asyncRetry({interval, times}, async () => {
50
+ return await getSettlementStatus({
51
+ lnd: target.lnd,
52
+ channel: channel.id,
53
+ payment: Number(),
54
+ });
55
+ });
56
+
57
+ strictSame(settlement, {is_onchain: false, is_settled: true}, 'Status');
58
+ } catch (err) {
59
+ equal(err, null, 'Expected no error');
60
+ }
61
+
62
+ await kill({});
63
+
64
+ return end();
65
+ });
@@ -70,7 +70,7 @@ test(`Open channel`, async ({end, equal}) => {
70
70
  throw new Error('ExpectedKnownPolicyBaseFeeMtokens');
71
71
  }
72
72
 
73
- // LND 0.15.3 and below do not support setting fees on open
73
+ // LND 0.15.4 and below do not support setting fees on open
74
74
  if (policy.base_fee_mtokens === defaultBaseFee) {
75
75
  return;
76
76
  }
@@ -139,7 +139,7 @@ test(`Open channels`, async ({end, equal}) => {
139
139
 
140
140
  const policy = policies.find(n => !!n.cltv_delta);
141
141
 
142
- // LND 0.15.3 and below do not support setting fees on open
142
+ // LND 0.15.4 and below do not support setting fees on open
143
143
  if (policy.base_fee_mtokens === defaultBaseFee) {
144
144
  return;
145
145
  }
@@ -162,7 +162,9 @@ test(`Open unconfirmed channels`, async ({end, equal, match, strictSame}) => {
162
162
 
163
163
  match(otherId, /16000000x0/, 'Got ephemeral id');
164
164
 
165
- await closeChannel({lnd, id: confirmed.id});
165
+ await asyncRetry({interval, times}, async () => {
166
+ await closeChannel({lnd, id: confirmed.id});
167
+ });
166
168
 
167
169
  // Propose a private channel to the peer
168
170
  const openPrivate = await asyncRetry({interval, times}, async () => {
@@ -43,7 +43,7 @@ test(`Subscribe to payments`, async ({end, rejects, strictSame}) => {
43
43
  sub.on('error', error => {
44
44
  const [,, {err}] = error;
45
45
 
46
- // subscribeToPayments is not supported on LND 0.15.3 and below
46
+ // subscribeToPayments is not supported on LND 0.15.4 and below
47
47
  if (err.details === unsupported) {
48
48
  return isLegacy.push(error);
49
49
  }
@@ -49,7 +49,7 @@ test(`Begin group signing session`, async ({end, equal}) => {
49
49
  public_keys: [Buffer.alloc(33, 2).toString('hex')],
50
50
  });
51
51
  } catch (err) {
52
- // On LND 0.14.3 and below, group signing is not supported
52
+ // On LND 0.14.5 and below, group signing is not supported
53
53
  if (err.slice().shift() === 501) {
54
54
  await kill({});
55
55
 
@@ -48,7 +48,7 @@ test(`Sign a taproot transaction`, async ({end, equal}) => {
48
48
  public_keys: [Buffer.alloc(33, 2).toString('hex')],
49
49
  });
50
50
  } catch (err) {
51
- // On LND 0.14.3 and below, taproot signing is not supported
51
+ // On LND 0.14.5 and below, taproot signing is not supported
52
52
  if (err.slice().shift() === 501) {
53
53
  await kill({});
54
54
 
@@ -38,7 +38,7 @@ test(`Disconnect watchtower`, async ({end, equal, match}) => {
38
38
 
39
39
  const [disconnected] = (await getConnectedWatchtowers({lnd})).towers;
40
40
 
41
- // LND 0.15.3 and below retain the tower
41
+ // LND 0.15.4 and below retain the tower
42
42
  if (!!disconnected) {
43
43
  equal(disconnected.is_active, false, 'Tower is inactive');
44
44
  }