ln-service 57.9.0 → 57.10.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,14 @@
1
1
  # Versions
2
2
 
3
+ ## 57.10.0
4
+
5
+ - `getPendingSweeps`: Add method to get the list of pending outpoints to sweep
6
+ - `requestBatchedFeeIncrease`: Add method to batch a CPFP sweep of an outpoint
7
+
8
+ ## 57.9.1
9
+
10
+ - Add support for LND 0.17.5
11
+
3
12
  ## 57.9.0
4
13
 
5
14
  - `fundPsbt`, `getChainFeeEstimate`, `sendToChainAddress`,
package/README.md CHANGED
@@ -9,7 +9,7 @@ through npm.
9
9
 
10
10
  Supported LND versions:
11
11
 
12
- - v0.17.0-beta to v0.17.4-beta
12
+ - v0.17.0-beta to v0.17.5-beta
13
13
  - v0.16.0-beta to v0.16.4-beta
14
14
  - v0.15.2-beta to v0.15.5-beta
15
15
  - v0.14.4-beta to v0.14.5-beta
@@ -215,6 +215,7 @@ for `unlocker` methods.
215
215
  - [getPendingChainBalance](#getpendingchainbalance) - Get pending chain balance
216
216
  - [getPendingChannels](#getpendingchannels) - Get channels in pending states
217
217
  - [getPendingPayments](#getpendingpayments) - Get in-flight outgoing payments
218
+ - [getPendingSweeps](#getpendingsweeps) - Get sweeps waiting for resolution
218
219
  - [getPublicKey](#getpublickey) - Get a public key out of the seed
219
220
  - [getRouteConfidence](#getrouteconfidence) - Get confidence in a route
220
221
  - [getRouteThroughHops](#getroutethroughhops) - Get a route through nodes
@@ -248,6 +249,8 @@ for `unlocker` methods.
248
249
  - [removeAdvertisedFeature](#removeadvertisedfeature) - Remove feature from ad
249
250
  - [removeExternalSocket](#removeexternalsocket) - Remove a p2p host:ip announce
250
251
  - [removePeer](#removepeer) - Disconnect from a connected peer
252
+ - [requestBatchedFeeIncrease](#requestbatchedfeeincrease) - Request a batched
253
+ CPFP spend on an unconfirmed outpoint
251
254
  - [requestChainFeeIncrease](#requestchainfeeincrease) - Request a CPFP spend on
252
255
  a UTXO
253
256
  - [restrictMacaroon](#restrictmacaroon) - Add limitations to a macaroon
@@ -1003,7 +1006,7 @@ Remove a chain transaction.
1003
1006
 
1004
1007
  Requires `onchain:write` permission
1005
1008
 
1006
- This method is not supported on LND 0.17.4 and below
1009
+ This method is not supported on LND 0.17.5 and below
1007
1010
 
1008
1011
  {
1009
1012
  id: <Transaction Id Hex String>
@@ -1351,7 +1354,7 @@ This method is not supported in LND 0.11.1 and below
1351
1354
 
1352
1355
  Specifying 0 for `min_confirmations` is not supported in LND 0.13.0 and below
1353
1356
 
1354
- `utxo_selection` is not supported in LND 0.17.4 and below
1357
+ `utxo_selection` is not supported in LND 0.17.5 and below
1355
1358
 
1356
1359
  {
1357
1360
  [fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
@@ -1648,7 +1651,7 @@ Requires `onchain:read` permission
1648
1651
 
1649
1652
  Specifying 0 for `utxo_confirmations` is not supported in LND 0.13.0 or below
1650
1653
 
1651
- `utxo_selection` is not supported in LND 0.17.4 and below
1654
+ `utxo_selection` is not supported in LND 0.17.5 and below
1652
1655
 
1653
1656
  {
1654
1657
  lnd: <Authenticated LND API Object>
@@ -1706,7 +1709,7 @@ Get a chain transaction.
1706
1709
 
1707
1710
  Requires `onchain:read` permission
1708
1711
 
1709
- This method is not supported on LND 0.17.4 and below
1712
+ This method is not supported on LND 0.17.5 and below
1710
1713
 
1711
1714
  {
1712
1715
  id: <Transaction Id Hex String>
@@ -2019,7 +2022,7 @@ Get the current configuration file settings and the output log
2019
2022
  Requires `info:read`, `offchain:read`, `onchain:read`, `peers:read`
2020
2023
  permissions
2021
2024
 
2022
- This method is not supported on LND 0.17.4 and below
2025
+ This method is not supported on LND 0.17.5 and below
2023
2026
 
2024
2027
  {
2025
2028
  lnd: <Authenticated LND API Object>
@@ -2054,7 +2057,7 @@ Includes previously connected watchtowers
2054
2057
 
2055
2058
  `is_anchor` flag is not supported on LND 0.11.1 and below
2056
2059
 
2057
- `is_taproot` flag is not supported on LND 0.17.4 and below
2060
+ `is_taproot` flag is not supported on LND 0.17.5 and below
2058
2061
 
2059
2062
  {
2060
2063
  [is_anchor]: <Get Anchor Type Tower Info Bool>
@@ -3113,7 +3116,7 @@ Requires `offchain:read` permission
3113
3116
 
3114
3117
  `blocks_until_expiry` is not supported in LND 0.16.4 or before
3115
3118
 
3116
- `close_transaction` is not supported in LND 0.17.4 or before
3119
+ `close_transaction` is not supported in LND 0.17.5 or before
3117
3120
 
3118
3121
  {
3119
3122
  lnd: <Authenticated LND API Object>
@@ -3256,7 +3259,7 @@ Requires `offchain:read` permission
3256
3259
  }
3257
3260
 
3258
3261
  ```node
3259
- const {getPendingPayments} = require('ln-service')
3262
+ const {getPendingPayments} = require('ln-service');
3260
3263
 
3261
3264
  const {next, payments} = await getPendingPayments({lnd});
3262
3265
 
@@ -3265,6 +3268,42 @@ if (!next) {
3265
3268
  }
3266
3269
  ```
3267
3270
 
3271
+ ### getPendingSweeps
3272
+
3273
+ Get pending self-transfer spends
3274
+
3275
+ Requires `onchain:read` permission
3276
+
3277
+ Requires LND built with `walletrpc` build tag
3278
+
3279
+ This method is not supported in LND 0.17.5 or below
3280
+
3281
+ {
3282
+ lnd: <Authenticated LND API Object>
3283
+ }
3284
+
3285
+ @returns via cbk or Promise
3286
+ {
3287
+ sweeps: [{
3288
+ broadcasts_count: <Total Sweep Broadcast Attempts Count Number>
3289
+ [current_fee_rate]: <Current Chain Fee Rate Tokens Per VByte Number>
3290
+ [initial_fee_rate]: <Requested Chain Fee Rate Tokens per VByte Number>
3291
+ is_batching: <Requested Waiting For Batching Bool>
3292
+ [max_fee]: <Maximum Total Fee Tokens Allowed Number>
3293
+ [max_height]: <Targeted Maximum Confirmation Height Number>
3294
+ tokens: <Sweep Outpoint Tokens Value Number>
3295
+ transaction_id: <Sweeping Outpoint Transaction Id Hex String>
3296
+ transaction_vout: <Sweeping Outpoint Transaction Output Index Number>
3297
+ type: <Outpoint Constraint Script Type String>
3298
+ }]
3299
+ }
3300
+
3301
+ ```node
3302
+ const {getPendingSweeps} = require('ln-service');
3303
+
3304
+ const pendingSweepsCount = (await getPendingSweeps({lnd})).sweeps.length;
3305
+ ```
3306
+
3268
3307
  ### getPublicKey
3269
3308
 
3270
3309
  Get a public key in the seed
@@ -4767,6 +4806,36 @@ const connectedPeerPublicKey = 'nodePublicKeyHexString';
4767
4806
  await removePeer({lnd, public_key: connectedPeerPublicKey});
4768
4807
  ```
4769
4808
 
4809
+ ### requestBatchedFeeIncrease
4810
+
4811
+ Request batched CPFP fee bumping of an unconfirmed outpoint on a deadline
4812
+
4813
+ Requires `onchain:write` permission
4814
+
4815
+ Requires LND built with `walletrpc` build tag
4816
+
4817
+ This method is unsupported on LND 0.17.5 and below
4818
+
4819
+ {
4820
+ lnd: <Authenticated LND API Object>
4821
+ [max_fee]: <Maximum Tokens to Pay Into Chain Fees Number>
4822
+ [max_height]: <Maximum Height To Reach a Confirmation Number>
4823
+ transaction_id: <Unconfirmed UTXO Transaction Id Hex String>
4824
+ transaction_vout: <Unconfirmed UTXO Transaction Index Number>
4825
+ }
4826
+
4827
+ @returns via cbk or Promise
4828
+
4829
+ ```node
4830
+ const {requestBatchedFeeIncrease} = require('ln-service');
4831
+
4832
+ await requestBatchedFeeIncrease({
4833
+ lnd,
4834
+ transaction_id: unconfirmedUtxoTxId,
4835
+ transaction_vout: unconfirmedUtxoTxOutputIndex,
4836
+ });
4837
+ ```
4838
+
4770
4839
  ### requestChainFeeIncrease
4771
4840
 
4772
4841
  Request a future on-chain CPFP fee increase for an unconfirmed UTXO
@@ -4972,7 +5041,7 @@ Requires `onchain:write` permission
4972
5041
 
4973
5042
  `utxo_confirmations` is not supported on LND 0.11.1 or below
4974
5043
 
4975
- `utxo_selection` is not supported in LND 0.17.4 and below
5044
+ `utxo_selection` is not supported in LND 0.17.5 and below
4976
5045
 
4977
5046
  {
4978
5047
  address: <Destination Chain Address String>
@@ -5016,7 +5085,7 @@ Requires `onchain:write` permission
5016
5085
 
5017
5086
  `utxo_confirmations` is not supported on LND 0.11.1 or below
5018
5087
 
5019
- `utxo_selection` is not supported in LND 0.17.4 and below
5088
+ `utxo_selection` is not supported in LND 0.17.5 and below
5020
5089
 
5021
5090
  {
5022
5091
  [description]: <Transaction Label String>
@@ -5060,7 +5129,7 @@ Requires `onchain:write` permission
5060
5129
 
5061
5130
  Requires LND compiled with `walletrpc` build tag
5062
5131
 
5063
- `utxo_selection` is not supported in LND 0.17.4 and below
5132
+ `utxo_selection` is not supported in LND 0.17.5 and below
5064
5133
 
5065
5134
  {
5066
5135
  [description]: <Transaction Label String>
package/index.js CHANGED
@@ -73,6 +73,7 @@ const {getPeers} = require('lightning');
73
73
  const {getPendingChainBalance} = require('lightning');
74
74
  const {getPendingChannels} = require('lightning');
75
75
  const {getPendingPayments} = require('lightning');
76
+ const {getPendingSweeps} = require('lightning');
76
77
  const {getPublicKey} = require('lightning');
77
78
  const {getRouteConfidence} = require('lightning');
78
79
  const {getRouteThroughHops} = require('lightning');
@@ -103,6 +104,7 @@ const {recoverFundsFromChannels} = require('lightning');
103
104
  const {removeAdvertisedFeature} = require('lightning');
104
105
  const {removeExternalSocket} = require('lightning');
105
106
  const {removePeer} = require('lightning');
107
+ const {requestBatchedFeeIncrease} = require('lightning');
106
108
  const {requestChainFeeIncrease} = require('lightning');
107
109
  const {restrictMacaroon} = require('./macaroons');
108
110
  const {revokeAccess} = require('lightning');
@@ -235,6 +237,7 @@ module.exports = {
235
237
  getPendingChainBalance,
236
238
  getPendingChannels,
237
239
  getPendingPayments,
240
+ getPendingSweeps,
238
241
  getPublicKey,
239
242
  getRouteConfidence,
240
243
  getRouteThroughHops,
@@ -265,6 +268,7 @@ module.exports = {
265
268
  removeAdvertisedFeature,
266
269
  removeExternalSocket,
267
270
  removePeer,
271
+ requestBatchedFeeIncrease,
268
272
  requestChainFeeIncrease,
269
273
  restrictMacaroon,
270
274
  revokeAccess,
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.9.0",
12
+ "lightning": "10.10.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.13",
27
+ "ln-docker-daemons": "6.0.15",
28
28
  "p2tr": "2.0.0",
29
29
  "portfinder": "1.0.32",
30
30
  "psbt": "3.0.0",
@@ -52,6 +52,8 @@
52
52
  "url": "https://github.com/alexbosworth/ln-service.git"
53
53
  },
54
54
  "scripts": {
55
+ "integration-test-0.17.5": "DOCKER_LND_VERSION=v0.17.5-beta npm run test",
56
+ "integration-test-0.17.4": "DOCKER_LND_VERSION=v0.17.4-beta npm run test",
55
57
  "integration-test-0.17.3": "DOCKER_LND_VERSION=v0.17.3-beta npm run test",
56
58
  "integration-test-0.17.2": "DOCKER_LND_VERSION=v0.17.2-beta npm run test",
57
59
  "integration-test-0.17.1": "DOCKER_LND_VERSION=v0.17.1-beta npm run test",
@@ -69,5 +71,5 @@
69
71
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
70
72
  "test": "echo $DOCKER_LND_VERSION && node test/runner"
71
73
  },
72
- "version": "57.9.0"
74
+ "version": "57.10.0"
73
75
  }
@@ -7,7 +7,6 @@ const asyncRetry = require('async/retry');
7
7
  const {spawnLightningCluster} = require('ln-docker-daemons');
8
8
 
9
9
  const {createChainAddress} = require('./../../');
10
- const {delay} = require('./../macros');
11
10
  const {generateBlocks} = require('./../macros');
12
11
  const {getHeight} = require('./../../');
13
12
  const {getChainBalance} = require('./../../');
@@ -6,7 +6,6 @@ const {spawnLightningCluster} = require('ln-docker-daemons');
6
6
 
7
7
  const {chainSendTransaction} = require('./../macros');
8
8
  const {createChainAddress} = require('./../../');
9
- const {delay} = require('./../macros');
10
9
  const {generateBlocks} = require('./../macros');
11
10
  const {getChainBalance} = require('./../../');
12
11
  const {getChainTransactions} = require('./../../');
@@ -0,0 +1,84 @@
1
+ const {equal} = require('node:assert').strict;
2
+ const {exit} = require('node:process');
3
+ const test = require('node:test');
4
+
5
+ const asyncAuto = require('async/auto');
6
+ const asyncRetry = require('async/retry');
7
+ const {setupChannel} = require('ln-docker-daemons');
8
+ const {spawnLightningCluster} = require('ln-docker-daemons');
9
+
10
+ const {closeChannel} = require('./../../');
11
+ const {createHodlInvoice} = require('./../../');
12
+ const {delay} = require('./../macros');
13
+ const {getChainTransactions} = require('./../../');
14
+ const {getClosedChannels} = require('./../../');
15
+ const {getInvoice} = require('./../../');
16
+ const {getPendingChannels} = require('./../../');
17
+ const {getPendingSweeps} = require('./../../');
18
+ const {getWalletInfo} = require('./../../');
19
+ const {openChannel} = require('./../../');
20
+ const {pay} = require('./../../');
21
+
22
+ const blockDelay = 50;
23
+ const channelCapacityTokens = 1e6;
24
+ const confirmationCount = 6;
25
+ const defaultFee = 1e3;
26
+ const give = 1e5;
27
+ const interval = 50;
28
+ const size = 2;
29
+ const times = 10000;
30
+ const tokens = 100;
31
+
32
+ // Force close a channel and get the resulting pending sweeps
33
+ test(`Get pending sweeps`, async t => {
34
+ const {kill, nodes} = await spawnLightningCluster({size});
35
+
36
+ t.after(() => exit());
37
+
38
+ const [{generate, lnd}, target] = nodes;
39
+
40
+ await asyncRetry({interval, times}, async () => {
41
+ const wallet = await getWalletInfo({lnd});
42
+
43
+ await generate({});
44
+
45
+ if (!wallet.is_synced_to_chain) {
46
+ throw new Error('NotSyncedToChain');
47
+ }
48
+ });
49
+
50
+ const channel = await setupChannel({
51
+ generate,
52
+ lnd,
53
+ give_tokens: give,
54
+ partner_csv_delay: blockDelay,
55
+ to: target,
56
+ });
57
+
58
+ const closing = await closeChannel({
59
+ lnd,
60
+ is_force_close: true,
61
+ transaction_id: channel.transaction_id,
62
+ transaction_vout: channel.transaction_vout,
63
+ });
64
+
65
+ await asyncRetry({interval, times}, async () => {
66
+ await generate({});
67
+
68
+ if (!!(await getClosedChannels({lnd})).channels.length) {
69
+ return;
70
+ }
71
+
72
+ throw new Error('ExpectedClosedChannel');
73
+ });
74
+
75
+ const {sweeps} = await getPendingSweeps({lnd});
76
+
77
+ const [sweep] = sweeps;
78
+
79
+ equal(sweep.transaction_id, closing.transaction_id, 'Got closing sweep');
80
+
81
+ await kill({});
82
+
83
+ return;
84
+ });
@@ -0,0 +1,61 @@
1
+ const {deepEqual} = require('node:assert').strict;
2
+ const {equal} = require('node:assert').strict;
3
+ const {fail} = require('node:assert').strict;
4
+ const test = require('node:test');
5
+
6
+ const {spawnLightningCluster} = require('ln-docker-daemons');
7
+
8
+ const {broadcastChainTransaction} = require('./../../');
9
+ const {createChainAddress} = require('./../../');
10
+ const {delay} = require('./../macros');
11
+ const {fundPsbt} = require('./../../');
12
+ const {getPendingSweeps} = require('./../../');
13
+ const {getUtxos} = require('./../../');
14
+ const {requestBatchedFeeIncrease} = require('./../../');
15
+ const {signPsbt} = require('./../../');
16
+
17
+ const count = 100;
18
+ const tokens = 1e8;
19
+
20
+ // Test requesting a batched chain fee increase
21
+ test(`Request batched chain fee increase`, async () => {
22
+ const [{generate, kill, lnd}] = (await spawnLightningCluster({})).nodes;
23
+
24
+ try {
25
+ await generate({count});
26
+
27
+ const {address} = await createChainAddress({lnd});
28
+
29
+ const {psbt} = await fundPsbt({lnd, outputs: [
30
+ {address, tokens},
31
+ {tokens, address: '2N8hwP1WmJrFF5QWABn38y63uYLhnJYJYTF'},
32
+ ]});
33
+
34
+ const {transaction} = await signPsbt({lnd, psbt});
35
+
36
+ await broadcastChainTransaction({lnd, transaction});
37
+
38
+ const bump = (await getUtxos({lnd})).utxos.find(n => n.tokens === tokens);
39
+
40
+ await requestBatchedFeeIncrease({
41
+ lnd,
42
+ transaction_id: bump.transaction_id,
43
+ transaction_vout: bump.transaction_vout,
44
+ });
45
+
46
+ const {sweeps} = await getPendingSweeps({lnd});
47
+
48
+ const [sweep] = sweeps;
49
+
50
+ equal(sweep.transaction_id, bump.transaction_id, 'Requested tx id bump');
51
+ equal(sweep.transaction_vout, bump.transaction_vout, 'Requested tx vout');
52
+
53
+ await kill({});
54
+ } catch (err) {
55
+ await kill({});
56
+
57
+ equal(err, null, 'Expected no error');
58
+ }
59
+
60
+ return;
61
+ });