ln-service 56.10.0 → 56.11.1
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 +4 -0
- package/README.md +6 -0
- package/package.json +4 -4
- package/test/integration/test_delete_pending_channel.js +115 -119
- package/test/integration/test_get_closed_channels.js +4 -1
- package/test/integration/test_open_channel_max.js +92 -0
- package/test/integration/test_stop_daemon.js +4 -1
- package/test/integration/test_subscribe_to_graph.js +4 -1
- package/test/integration/test_trusted_funding.js +4 -1
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +18 -28
- package/test/routerrpc-integration/test_pay_via_routes.js +8 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3729,6 +3729,8 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
|
|
|
3729
3729
|
|
|
3730
3730
|
`description` is not supported on LND 0.16.4 and below
|
|
3731
3731
|
|
|
3732
|
+
`inputs` is not supported on LND 0.16.4 and below
|
|
3733
|
+
|
|
3732
3734
|
{
|
|
3733
3735
|
[base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
|
|
3734
3736
|
[chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
|
|
@@ -3736,6 +3738,10 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
|
|
|
3736
3738
|
[description]: <Immutable Channel Description String>
|
|
3737
3739
|
[fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
|
|
3738
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
|
+
}]
|
|
3739
3745
|
[is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
|
|
3740
3746
|
[is_private]: <Channel is Private Bool> // Defaults to false
|
|
3741
3747
|
[is_trusted_funding]: <Accept Funding as Trusted Bool>
|
package/package.json
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.18.2",
|
|
13
13
|
"invoices": "3.0.0",
|
|
14
|
-
"lightning": "9.
|
|
14
|
+
"lightning": "9.11.2",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.13.0"
|
|
18
18
|
},
|
|
19
19
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@alexbosworth/blockchain": "1.
|
|
21
|
+
"@alexbosworth/blockchain": "1.7.0",
|
|
22
22
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
23
23
|
"async": "3.2.4",
|
|
24
24
|
"asyncjs-util": "1.2.12",
|
|
@@ -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.
|
|
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.
|
|
72
|
+
"version": "56.11.1"
|
|
73
73
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
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
|
-
|
|
45
|
-
await generate({count});
|
|
46
|
+
await generate({count});
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
69
|
-
|
|
52
|
+
const channels = [{
|
|
53
|
+
capacity,
|
|
54
|
+
description,
|
|
55
|
+
is_private: true,
|
|
56
|
+
partner_public_key: target.id,
|
|
57
|
+
}];
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
109
|
-
|
|
85
|
+
id: utxo.lock_id,
|
|
86
|
+
transaction_id: utxo.transaction_id,
|
|
87
|
+
transaction_vout: utxo.transaction_vout,
|
|
110
88
|
});
|
|
89
|
+
});
|
|
111
90
|
|
|
112
|
-
|
|
113
|
-
|
|
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:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
131
|
-
|
|
143
|
+
throw new Error('ExpectedNewChannelCreated');
|
|
144
|
+
});
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
if (!!channel) {
|
|
135
|
-
return channel;
|
|
136
|
-
}
|
|
146
|
+
const [pending] = (await getPendingChannels({lnd})).pending_channels;
|
|
137
147
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
154
|
+
const stuckTx = extractTransaction({ecp, psbt: signTarget.psbt});
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
const [stuckPending] = proposeToTarget.pending;
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
164
|
-
|
|
164
|
+
deepEqual(code, 503, 'Pending channel cannot be canceled');
|
|
165
|
+
}
|
|
165
166
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
175
|
+
const [notPending] = (await getPendingChannels({lnd})).pending_channels;
|
|
175
176
|
|
|
176
|
-
|
|
177
|
-
} catch (err) {
|
|
178
|
-
deepStrictEqual(err, [501, 'DeletePendingChannelMethodNotSupported']);
|
|
179
|
-
}
|
|
177
|
+
deepEqual(notPending, undefined, 'Conflicting pending deleted');
|
|
180
178
|
} catch (err) {
|
|
181
|
-
|
|
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
|
|
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({});
|
|
@@ -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
|
-
|
|
38
|
-
|
|
39
|
-
const {features} = await getWalletInfo({lnd});
|
|
36
|
+
t.after(() => exit());
|
|
40
37
|
|
|
41
|
-
const
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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(
|
|
102
|
-
equal(
|
|
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,
|