ln-service 56.9.0 → 56.11.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
+ ## 56.11.0
4
+
5
+ - `openChannel`: Add `inputs` to select inputs for channel open funding
6
+
7
+ ## 56.10.0
8
+
9
+ - `createInvoice`, `createHodlInvoice`: Add `routes` to customize the hop hints
10
+
3
11
  ## 56.9.0
4
12
 
5
13
  - `openChannel`: Add `is_trusted_funding` to support skipping confirmation wait
package/README.md CHANGED
@@ -641,6 +641,13 @@ Requires `address:write`, `invoices:write` permission
641
641
  [is_including_private_channels]: <Invoice Includes Private Channels Bool>
642
642
  lnd: <Authenticated LND API Object>
643
643
  [mtokens]: <Millitokens String>
644
+ [routes]: [[{
645
+ [base_fee_mtokens]: <Base Routing Fee In Millitokens String>
646
+ [channel]: <Standard Format Channel Id String>
647
+ [cltv_delta]: <CLTV Blocks Delta Number>
648
+ [fee_rate]: <Fee Rate In Millitokens Per Million Number>
649
+ public_key: <Forward Edge Public Key Hex String>
650
+ }]]
644
651
  [tokens]: <Tokens Number>
645
652
  }
646
653
 
@@ -707,6 +714,13 @@ Requires `address:write`, `invoices:write` permission
707
714
  lnd: <Authenticated LND API Object>
708
715
  [secret]: <Payment Preimage Hex String>
709
716
  [mtokens]: <Millitokens String>
717
+ [routes]: [[{
718
+ [base_fee_mtokens]: <Base Routing Fee In Millitokens String>
719
+ [channel]: <Standard Format Channel Id String>
720
+ [cltv_delta]: <CLTV Blocks Delta Number>
721
+ [fee_rate]: <Fee Rate In Millitokens Per Million Number>
722
+ public_key: <Forward Edge Public Key Hex String>
723
+ }]]
710
724
  [tokens]: <Tokens Number>
711
725
  }
712
726
 
@@ -3715,6 +3729,8 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
3715
3729
 
3716
3730
  `description` is not supported on LND 0.16.4 and below
3717
3731
 
3732
+ `inputs` is not supported on LND 0.16.4 and below
3733
+
3718
3734
  {
3719
3735
  [base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
3720
3736
  [chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
@@ -3722,6 +3738,10 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
3722
3738
  [description]: <Immutable Channel Description String>
3723
3739
  [fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
3724
3740
  [give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
3741
+ [inputs]: [{
3742
+ transaction_id: <Fund With Unspent Transaction Id Hex String>
3743
+ transaction_vout: <Fund With Unspent Transaction Output Index Number>
3744
+ }]
3725
3745
  [is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
3726
3746
  [is_private]: <Channel is Private Bool> // Defaults to false
3727
3747
  [is_trusted_funding]: <Accept Funding as Trusted Bool>
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.18.2",
13
13
  "invoices": "3.0.0",
14
- "lightning": "9.9.0",
14
+ "lightning": "9.11.1",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.13.0"
@@ -28,7 +28,7 @@
28
28
  "bn.js": "5.2.1",
29
29
  "bs58check": "3.0.1",
30
30
  "ecpair": "2.1.0",
31
- "ln-docker-daemons": "5.1.1",
31
+ "ln-docker-daemons": "5.1.2",
32
32
  "p2tr": "2.0.0",
33
33
  "portfinder": "1.0.32",
34
34
  "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": "56.9.0"
72
+ "version": "56.11.0"
73
73
  }
@@ -1,4 +1,4 @@
1
- const {deepStrictEqual} = require('node:assert').strict;
1
+ const {deepEqual} = require('node:assert').strict;
2
2
  const test = require('node:test');
3
3
 
4
4
  const asyncEach = require('async/each');
@@ -34,154 +34,150 @@ const timeout = 1000 * 20;
34
34
  const times = 2000;
35
35
 
36
36
  // Forfeiting a pending channel should remove the pending channel
37
- test(`Forfeit pending channel`, async () => {
37
+ test(`Forfeit pending channel`, async t => {
38
38
  const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
39
39
 
40
40
  const {kill, nodes} = await spawnLightningCluster({size});
41
41
 
42
+ t.after(async () => await kill({}));
43
+
42
44
  const [{generate, lnd}, target, remote] = nodes;
43
45
 
44
- try {
45
- await generate({count});
46
+ await generate({count});
46
47
 
47
- await asyncEach([target, remote], async node => {
48
- return await addPeer({lnd, public_key: node.id, socket: node.socket});
49
- });
50
-
51
- const channels = [{
52
- capacity,
53
- description,
54
- is_private: true,
55
- partner_public_key: target.id,
56
- }];
57
-
58
- // Propose a channel to target
59
- const proposeToTarget = await asyncRetry({interval: 1000, times}, cbk => {
60
- return asyncTimeout(openChannels, 1000 * 3)({
61
- channels,
62
- lnd,
63
- is_avoiding_broadcast: true,
64
- },
65
- cbk);
66
- });
48
+ await asyncEach([target, remote], async node => {
49
+ return await addPeer({lnd, public_key: node.id, socket: node.socket});
50
+ });
67
51
 
68
- // Setup funding for the target
69
- const fundTarget = await fundPsbt({lnd, outputs: proposeToTarget.pending});
52
+ const channels = [{
53
+ capacity,
54
+ description,
55
+ is_private: true,
56
+ partner_public_key: target.id,
57
+ }];
70
58
 
71
- // Sign the funding to the target
72
- const signTarget = await signPsbt({lnd, psbt: fundTarget.psbt});
73
-
74
- // Fund the target channel that will get stuck
75
- await fundPendingChannels({
59
+ // Propose a channel to target
60
+ const proposeToTarget = await asyncRetry({interval: 1000, times}, cbk => {
61
+ return asyncTimeout(openChannels, 1000 * 3)({
62
+ channels,
76
63
  lnd,
77
- channels: proposeToTarget.pending.map(n => n.id),
78
- funding: signTarget.psbt,
79
- });
80
-
81
- await asyncEach((await getLockedUtxos({lnd})).utxos, async utxo => {
82
- return await unlockUtxo({
83
- lnd,
84
- id: utxo.lock_id,
85
- transaction_id: utxo.transaction_id,
86
- transaction_vout: utxo.transaction_vout,
87
- });
88
- });
89
-
90
- // Propose a channel to remote
91
- const proposeToRemote = await asyncRetry({interval: 1000, times}, cbk => {
92
- return asyncTimeout(openChannels, 1000 * 3)({
93
- lnd,
94
- channels: [{
95
- capacity,
96
- description,
97
- is_private: true,
98
- partner_public_key: remote.id,
99
- }],
100
- is_avoiding_broadcast: true,
101
- },
102
- cbk);
103
- });
104
-
105
- // Setup funding for the remote, using the same inputs
106
- const fundRemote = await fundPsbt({
64
+ is_avoiding_broadcast: true,
65
+ },
66
+ cbk);
67
+ });
68
+
69
+ // Setup funding for the target
70
+ const fundTarget = await fundPsbt({lnd, outputs: proposeToTarget.pending});
71
+
72
+ // Sign the funding to the target
73
+ const signTarget = await signPsbt({lnd, psbt: fundTarget.psbt});
74
+
75
+ // Fund the target channel that will get stuck
76
+ await fundPendingChannels({
77
+ lnd,
78
+ channels: proposeToTarget.pending.map(n => n.id),
79
+ funding: signTarget.psbt,
80
+ });
81
+
82
+ await asyncEach((await getLockedUtxos({lnd})).utxos, async utxo => {
83
+ return await unlockUtxo({
107
84
  lnd,
108
- inputs: fundTarget.inputs,
109
- outputs: proposeToRemote.pending
85
+ id: utxo.lock_id,
86
+ transaction_id: utxo.transaction_id,
87
+ transaction_vout: utxo.transaction_vout,
110
88
  });
89
+ });
111
90
 
112
- // Sign the funding to the target
113
- const signRemote = await signPsbt({lnd, psbt: fundRemote.psbt});
114
-
115
- // Fund the remote channel
116
- await fundPendingChannels({
91
+ // Propose a channel to remote
92
+ const proposeToRemote = await asyncRetry({interval: 1000, times}, cbk => {
93
+ return asyncTimeout(openChannels, 1000 * 3)({
117
94
  lnd,
118
- channels: proposeToRemote.pending.map(n => n.id),
119
- funding: signRemote.psbt,
120
- });
121
-
122
- await delay(1000);
123
-
124
- const {transaction} = extractTransaction({ecp, psbt: signRemote.psbt});
95
+ channels: [{
96
+ capacity,
97
+ description,
98
+ is_private: true,
99
+ partner_public_key: remote.id,
100
+ }],
101
+ is_avoiding_broadcast: true,
102
+ },
103
+ cbk);
104
+ });
105
+
106
+ // Setup funding for the remote, using the same inputs
107
+ const fundRemote = await fundPsbt({
108
+ lnd,
109
+ inputs: fundTarget.inputs,
110
+ outputs: proposeToRemote.pending
111
+ });
112
+
113
+ // Sign the funding to the target
114
+ const signRemote = await signPsbt({lnd, psbt: fundRemote.psbt});
115
+
116
+ // Fund the remote channel
117
+ await fundPendingChannels({
118
+ lnd,
119
+ channels: proposeToRemote.pending.map(n => n.id),
120
+ funding: signRemote.psbt,
121
+ });
122
+
123
+ await delay(1000);
124
+
125
+ const {transaction} = extractTransaction({ecp, psbt: signRemote.psbt});
126
+
127
+ await broadcastChainTransaction({lnd, transaction});
128
+
129
+ await generate({});
130
+
131
+ const channel = await asyncRetry({interval: 1000, times}, async () => {
132
+ const [channel] = (await getChannels({lnd})).channels;
133
+
134
+ // Exit early when the channel is created
135
+ if (!!channel) {
136
+ return channel;
137
+ }
125
138
 
126
139
  await broadcastChainTransaction({lnd, transaction});
127
140
 
128
141
  await generate({});
129
142
 
130
- const channel = await asyncRetry({interval: 1000, times}, async () => {
131
- const [channel] = (await getChannels({lnd})).channels;
143
+ throw new Error('ExpectedNewChannelCreated');
144
+ });
132
145
 
133
- // Exit early when the channel is created
134
- if (!!channel) {
135
- return channel;
136
- }
146
+ const [pending] = (await getPendingChannels({lnd})).pending_channels;
137
147
 
138
- await broadcastChainTransaction({lnd, transaction});
139
-
140
- await generate({});
141
-
142
- throw new Error('ExpectedNewChannelCreated');
143
- });
144
-
145
- const [pending] = (await getPendingChannels({lnd})).pending_channels;
146
-
147
- // Description is not supported in LND 0.16.4 or before
148
- if (!!pending.description) {
149
- strictSame(pending.description, description, 'Got expected description');
150
- strictSame(pending.is_private, true, 'Got pending private status');
151
- }
148
+ // Description is not supported in LND 0.16.4 or before
149
+ if (!!pending.description) {
150
+ deepEqual(pending.description, description, 'Got expected description');
151
+ deepEqual(pending.is_private, true, 'Got pending private status');
152
+ }
152
153
 
153
- const stuckTx = extractTransaction({ecp, psbt: signTarget.psbt});
154
+ const stuckTx = extractTransaction({ecp, psbt: signTarget.psbt});
154
155
 
155
- const [stuckPending] = proposeToTarget.pending;
156
+ const [stuckPending] = proposeToTarget.pending;
156
157
 
157
- // Try to cancel the pending channel, it will fail
158
- try {
159
- await cancelPendingChannel({lnd, id: stuckPending.id});
160
- } catch (err) {
161
- const [code] = err;
158
+ // Try to cancel the pending channel, it will fail
159
+ try {
160
+ await cancelPendingChannel({lnd, id: stuckPending.id});
161
+ } catch (err) {
162
+ const [code] = err;
162
163
 
163
- deepStrictEqual(code, 503, 'Pending channel cannot be canceled');
164
- }
164
+ deepEqual(code, 503, 'Pending channel cannot be canceled');
165
+ }
165
166
 
166
- try {
167
- await deletePendingChannel({
168
- lnd,
169
- confirmed_transaction: transaction,
170
- pending_transaction: stuckTx.transaction,
171
- pending_transaction_vout: pending.transaction_vout,
172
- });
167
+ try {
168
+ await deletePendingChannel({
169
+ lnd,
170
+ confirmed_transaction: transaction,
171
+ pending_transaction: stuckTx.transaction,
172
+ pending_transaction_vout: pending.transaction_vout,
173
+ });
173
174
 
174
- const [notPending] = (await getPendingChannels({lnd})).pending_channels;
175
+ const [notPending] = (await getPendingChannels({lnd})).pending_channels;
175
176
 
176
- deepStrictEqual(notPending, undefined, 'Conflicting pending deleted');
177
- } catch (err) {
178
- deepStrictEqual(err, [501, 'DeletePendingChannelMethodNotSupported']);
179
- }
177
+ deepEqual(notPending, undefined, 'Conflicting pending deleted');
180
178
  } catch (err) {
181
- deepStrictEqual(err, null, 'No error is expected');
179
+ deepEqual(err, [501, 'DeletePendingChannelMethodNotSupported']);
182
180
  }
183
181
 
184
- await kill({});
185
-
186
182
  return;
187
183
  });
@@ -1,3 +1,4 @@
1
+ const {exit} = require('node:process');
1
2
  const {strictEqual} = require('node:assert').strict;
2
3
  const test = require('node:test');
3
4
 
@@ -20,9 +21,11 @@ const size = 2;
20
21
  const times = 1000;
21
22
 
22
23
  // Getting closed channels should return closed channels
23
- test(`Get closed channels`, async () => {
24
+ test(`Get closed channels`, async t => {
24
25
  const {kill, nodes} = await spawnLightningCluster({size});
25
26
 
27
+ t.after(() => exit());
28
+
26
29
  const [control, target] = nodes;
27
30
 
28
31
  const {generate, lnd} = control;
@@ -0,0 +1,92 @@
1
+ const {equal} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const asyncRetry = require('async/retry');
5
+ const {componentsOfTransaction} = require('@alexbosworth/blockchain');
6
+ const {spawnLightningCluster} = require('ln-docker-daemons');
7
+
8
+ const {addPeer} = require('./../../');
9
+ const {getChainTransactions} = require('./../../');
10
+ const {getChannels} = require('./../../');
11
+ const {getUtxos} = require('./../../');
12
+ const {openChannel} = require('./../../');
13
+
14
+ const count = 101;
15
+ const description = 'description';
16
+ const interval = 250;
17
+ const size = 2;
18
+ const times = 1000;
19
+
20
+ // Opening a channel with max funds should open a channel using all funds
21
+ test(`Open channel max`, async () => {
22
+ const {kill, nodes} = await spawnLightningCluster({size});
23
+
24
+ const [{generate, id, lnd}, target] = nodes;
25
+
26
+ await generate({count});
27
+
28
+ // Find the second UTXO, it would not normally be chosen by coin selection
29
+ const utxo = await asyncRetry({interval, times}, async () => {
30
+ const {utxos} = await getUtxos({lnd});
31
+
32
+ const [, outpoint] = utxos;
33
+
34
+ if (!outpoint) {
35
+ throw new Error('ExpectedMultipleUtxos');
36
+ }
37
+
38
+ return {
39
+ transaction_id: outpoint.transaction_id,
40
+ transaction_vout: outpoint.transaction_vout,
41
+ };
42
+ });
43
+
44
+ // Open the channel using coin selection
45
+ const channelOpen = await asyncRetry({interval, times}, async () => {
46
+ await addPeer({lnd, public_key: target.id, socket: target.socket});
47
+
48
+ return await openChannel({
49
+ description,
50
+ lnd,
51
+ inputs: [utxo],
52
+ is_max_funding: true,
53
+ partner_public_key: target.id,
54
+ socket: target.socket,
55
+ });
56
+ });
57
+
58
+ const {transactions} = await getChainTransactions({lnd});
59
+
60
+ const tx = transactions.find(n => n.id === channelOpen.transaction_id);
61
+
62
+ const components = componentsOfTransaction({transaction: tx.transaction});
63
+
64
+ const [input] = components.inputs;
65
+
66
+ // Wait for the channel to activate
67
+ await asyncRetry({interval, times}, async () => {
68
+ await generate({});
69
+
70
+ const {channels} = await getChannels({lnd});
71
+
72
+ const [channel] = channels;
73
+
74
+ if (!channel) {
75
+ throw new Error('ExpectedMaxChannelOpened');
76
+ }
77
+
78
+ // LND 0.16.4 and below do not support max funding for channel opens
79
+ if (channel.description !== description) {
80
+ return;
81
+ }
82
+
83
+ // Make sure the channel spent the correct transaction output
84
+ equal(input.id, utxo.transaction_id, 'Channel open spent down right UTXO');
85
+
86
+ return;
87
+ });
88
+
89
+ await kill({});
90
+
91
+ return;
92
+ });
@@ -1,3 +1,4 @@
1
+ const {exit} = require('node:process');
1
2
  const {fail} = require('node:assert').strict;
2
3
  const {strictEqual} = require('node:assert').strict;
3
4
  const test = require('node:test');
@@ -8,9 +9,11 @@ const {getWalletInfo} = require('./../../');
8
9
  const {stopDaemon} = require('./../../');
9
10
 
10
11
  // Stopping the daemon should gracefully shut down the daemon
11
- test(`Stop daemon`, async ({end, equal, fail}) => {
12
+ test(`Stop daemon`, async t => {
12
13
  const [{kill, lnd}] = (await spawnLightningCluster({})).nodes;
13
14
 
15
+ t.after(() => exit());
16
+
14
17
  await stopDaemon({lnd});
15
18
 
16
19
  try {
@@ -1,5 +1,6 @@
1
1
  const {deepEqual} = require('node:assert').strict;
2
2
  const {equal} = require('node:assert').strict;
3
+ const {exit} = require('node:process');
3
4
  const test = require('node:test');
4
5
 
5
6
  const asyncRetry = require('async/retry');
@@ -19,9 +20,11 @@ const size = 2;
19
20
  const times = 1000;
20
21
 
21
22
  // Subscribing to graph should trigger graph events
22
- test('Subscribe to channels', async () => {
23
+ test('Subscribe to channels', async t => {
23
24
  const attempts = [];
24
25
 
26
+ t.after(() => exit());
27
+
25
28
  await asyncRetry({interval, times}, async () => {
26
29
  const {kill, nodes} = await spawnLightningCluster({size});
27
30
 
@@ -1,5 +1,6 @@
1
1
  const {deepEqual} = require('node:assert').strict;
2
2
  const {equal} = require('node:assert').strict;
3
+ const {exit} = require('node:process');
3
4
  const {match} = require('node:assert').strict;
4
5
  const test = require('node:test');
5
6
 
@@ -29,7 +30,9 @@ const size = 2;
29
30
  const times = 4000;
30
31
 
31
32
  // Opening unconfirmed channels should in immediate channel opening
32
- test(`Open unconfirmed channels`, async () => {
33
+ test(`Open unconfirmed channels`, async t => {
34
+ t.after(() => exit());
35
+
33
36
  // Unconfirmed channels are not supported on LND 0.15.0 and below
34
37
  {
35
38
  const {kill, nodes} = await spawnLightningCluster({});
@@ -0,0 +1,91 @@
1
+ const {deepEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const asyncRetry = require('async/retry');
5
+ const {setupChannel} = require('ln-docker-daemons');
6
+ const {spawnLightningCluster} = require('ln-docker-daemons');
7
+
8
+ const {cancelHodlInvoice} = require('./../../');
9
+ const {createHodlInvoice} = require('./../../');
10
+ const {createInvoice} = require('./../../');
11
+ const {parsePaymentRequest} = require('./../../');
12
+
13
+ const interval = 10;
14
+ const size = 3;
15
+ const times = 1000;
16
+ const tokens = 100;
17
+
18
+ // createInvoice should result in a created invoice with hop hints
19
+ test(`Create an invoice with hop hints`, async t => {
20
+ const {kill, nodes} = await spawnLightningCluster({size});
21
+
22
+ t.after(async () => await kill({}));
23
+
24
+ const [{generate, lnd}, target, remote] = nodes;
25
+
26
+ const channel = await setupChannel({generate, lnd, to: target});
27
+
28
+ const remoteChannel = await setupChannel({
29
+ generate: target.generate,
30
+ is_private: true,
31
+ lnd: target.lnd,
32
+ to: remote,
33
+ });
34
+
35
+ const specialRoutes = [[
36
+ {
37
+ public_key: target.id,
38
+ },
39
+ {
40
+ base_fee_mtokens: '123456',
41
+ channel: remoteChannel.id,
42
+ cltv_delta: 200,
43
+ fee_rate: 123456,
44
+ public_key: remote.id,
45
+ },
46
+ ]];
47
+
48
+ const invoice = await asyncRetry({interval, times}, async () => {
49
+ const invoice = await createInvoice({
50
+ tokens,
51
+ is_including_private_channels: true,
52
+ lnd: remote.lnd,
53
+ routes: specialRoutes,
54
+ });
55
+
56
+ const hodlInvoice = await createHodlInvoice({
57
+ tokens,
58
+ is_including_private_channels: true,
59
+ lnd: remote.lnd,
60
+ routes: specialRoutes,
61
+ });
62
+
63
+ const {routes} = parsePaymentRequest({request: invoice.request});
64
+
65
+ // Wait for private routes to get picked up
66
+ if (!routes) {
67
+ await cancelHodlInvoice({id: invoice.id, lnd: remote.lnd});
68
+
69
+ throw new Error('ExpectedRouteForInvoice');
70
+ }
71
+
72
+ const hodl = parsePaymentRequest({request: hodlInvoice.request});
73
+
74
+ // Wait for private routes to get picked up
75
+ if (!hodl.routes) {
76
+ await cancelHodlInvoice({id: hodl.id, lnd: remote.lnd});
77
+
78
+ throw new Error('ExpectedRouteForHodlInvoice');
79
+ }
80
+
81
+ return {
82
+ normal_routes: routes,
83
+ hodl_routes: hodl.routes,
84
+ };
85
+ });
86
+
87
+ deepEqual(invoice.normal_routes, specialRoutes, 'Got expected routes');
88
+ deepEqual(invoice.hodl_routes, specialRoutes, 'Got expected hodl routes');
89
+
90
+ return;
91
+ });
@@ -1,4 +1,5 @@
1
1
  const {equal} = require('node:assert').strict;
2
+ const {exit} = require('node:process');
2
3
  const test = require('node:test');
3
4
 
4
5
  const asyncAuto = require('async/auto');
@@ -17,9 +18,7 @@ const {getSweepTransactions} = require('./../../');
17
18
  const {getWalletInfo} = require('./../../');
18
19
  const {openChannel} = require('./../../');
19
20
  const {pay} = require('./../../');
20
- const {subscribeToInvoice} = require('./../../');
21
21
 
22
- const anchorsFeatureBit = 23;
23
22
  const blockDelay = 50;
24
23
  const channelCapacityTokens = 1e6;
25
24
  const confirmationCount = 6;
@@ -31,14 +30,12 @@ const times = 10000;
31
30
  const tokens = 100;
32
31
 
33
32
  // Force close a channel and get the resulting sweep transaction
34
- test(`Get sweep transactions`, async () => {
33
+ test(`Get sweep transactions`, async t => {
35
34
  const {kill, nodes} = await spawnLightningCluster({size});
36
35
 
37
- const [{generate, lnd}, target] = nodes;
38
-
39
- const {features} = await getWalletInfo({lnd});
36
+ t.after(() => exit());
40
37
 
41
- const isAnchors = !!features.find(n => n.bit === anchorsFeatureBit);
38
+ const [{generate, lnd}, target] = nodes;
42
39
 
43
40
  const channel = await setupChannel({
44
41
  generate,
@@ -79,28 +76,21 @@ test(`Get sweep transactions`, async () => {
79
76
 
80
77
  const [transaction] = transactions;
81
78
 
82
- // LND 0.12.0 uses anchor channels
83
- if (isAnchors) {
84
- const [anchorTokens, sweepTokens] = transactions
85
- .map(n => n.tokens).sort();
86
-
87
- equal(transactions.length, 2, 'Got closed channel sweep');
88
-
89
- // LND 0.15.0 and before have different sweep tokens
90
- if (sweepTokens === 890455) {
91
- equal(anchorTokens, 149, 'Sweep has tokens amount');
92
- equal(sweepTokens, 890455, 'Sweep has tokens amount');
93
- } else if (anchorTokens === 147) {
94
- equal(anchorTokens, 147, 'Sweep has tokens amount');
95
- equal(sweepTokens, 889855, 'Sweep has tokens amount');
96
- } else {
97
- equal(anchorTokens, 136, 'Sweep has tokens amount');
98
- equal(sweepTokens, 889855, 'Sweep has tokens amount');
99
- }
79
+ const [anchorTokens, sweepTokens] = transactions
80
+ .map(n => n.tokens).sort();
81
+
82
+ equal(transactions.length, 2, 'Got closed channel sweep');
83
+
84
+ // LND 0.15.0 and before have different sweep tokens
85
+ if (sweepTokens === 890455) {
86
+ equal(anchorTokens, 149, 'Sweep has tokens amount');
87
+ equal(sweepTokens, 890455, 'Sweep has tokens amount');
88
+ } else if (anchorTokens === 147) {
89
+ equal(anchorTokens, 147, 'Sweep has tokens amount');
90
+ equal(sweepTokens, 889855, 'Sweep has tokens amount');
100
91
  } else {
101
- equal(transactions.length, [channel].length, 'Got closed channel sweep');
102
- equal(transaction.spends.length, 1, 'Sweep has spends');
103
- equal(transaction.tokens, 884875, 'Sweep has tokens amount');
92
+ equal(anchorTokens, 136, 'Sweep has tokens amount');
93
+ equal(sweepTokens, 889855, 'Sweep has tokens amount');
104
94
  }
105
95
 
106
96
  equal(transaction.block_id.length, 64, 'Sweep confirmed');
@@ -48,8 +48,16 @@ test(`Pay via routes`, async () => {
48
48
  const remoteLnd = remote.lnd;
49
49
  const targetPubKey = target.id;
50
50
 
51
+ await addPeer({lnd, public_key: target.id, socket: target.socket});
52
+
51
53
  const channel = await setupChannel({generate, lnd, to: target});
52
54
 
55
+ await addPeer({
56
+ lnd: target.lnd,
57
+ public_key: remote.id,
58
+ socket: remote.socket,
59
+ });
60
+
53
61
  const targetToRemoteChan = await setupChannel({
54
62
  generate: target.generate,
55
63
  is_private: true,