ln-service 57.9.1 → 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,10 @@
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
+
3
8
  ## 57.9.1
4
9
 
5
10
  - Add support for LND 0.17.5
package/README.md CHANGED
@@ -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
@@ -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
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.1",
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.14",
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",
@@ -71,5 +71,5 @@
71
71
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
72
72
  "test": "echo $DOCKER_LND_VERSION && node test/runner"
73
73
  },
74
- "version": "57.9.1"
74
+ "version": "57.10.0"
75
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
+ });