ln-service 53.5.2 → 53.7.2
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 +8 -0
- package/README.md +51 -2
- package/index.js +4 -2
- package/package.json +16 -5
- package/test/integration/test_add_peer.js +25 -19
- package/test/integration/test_delete_pending_channel.js +18 -11
- package/test/integration/test_get_failed_payments.js +123 -119
- package/test/integration/test_get_node.js +48 -44
- package/test/integration/test_get_pending_force.js +8 -1
- package/test/integration/test_get_wallet_info.js +30 -15
- package/test/integration/test_open_channels.js +21 -14
- package/test/integration/test_propose_channel.js +438 -421
- package/test/integration/test_subscribe_to_channels.js +1 -1
- package/test/integration/test_subscribe_to_peer_messages.js +77 -71
- package/test/integration/test_subscribe_to_peers.js +23 -19
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +64 -60
- package/test/routerrpc-integration/test_get_route_confidence.js +38 -34
- package/test/routerrpc-integration/test_get_route_through_hops.js +33 -14
- package/test/routerrpc-integration/test_pay_via_payment_details.js +118 -110
- package/test/routerrpc-integration/test_pay_via_routes.js +19 -1
- package/test/routerrpc-integration/test_probe_for_route.js +75 -71
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +2 -2
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +508 -504
- package/test/walletrpc-integration/test_fund_psbt.js +4 -1
- package/test/walletrpc-integration/test_partially_sign_psbt.js +216 -0
- package/test/walletrpc-integration/test_sign_psbt.js +4 -1
|
@@ -24,62 +24,66 @@ test(`Get node`, async ({end, equal, strictSame}) => {
|
|
|
24
24
|
|
|
25
25
|
const [{generate, id, lnd}, target, remote] = nodes;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
try {
|
|
28
|
+
const controlToTarget = await setupChannel({generate, lnd, to: target});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const targetToRemote = await setupChannel({
|
|
31
|
+
generate: target.generate,
|
|
32
|
+
lnd: target.lnd,
|
|
33
|
+
to: remote,
|
|
34
|
+
});
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
await updateRoutingFees({
|
|
37
|
+
lnd,
|
|
38
|
+
base_fee_tokens: baseFee,
|
|
39
|
+
cltv_delta: cltvDelta,
|
|
40
|
+
fee_rate: feeRate,
|
|
41
|
+
transaction_id: controlToTarget.transaction_id,
|
|
42
|
+
transaction_vout: controlToTarget.transaction_vout,
|
|
43
|
+
});
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
await delay(3000);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
const node = await getNode({lnd, public_key: id});
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
{
|
|
52
|
+
const {channels} = await getNode({
|
|
53
|
+
lnd,
|
|
54
|
+
is_omitting_channels: true,
|
|
55
|
+
public_key: id,
|
|
56
|
+
});
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!!node.channels.length) {
|
|
61
|
-
const [{policies}] = node.channels;
|
|
58
|
+
equal(channels.length, [].length, 'Channels are omitted')
|
|
59
|
+
}
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
if (!!node.channels.length) {
|
|
62
|
+
const [{policies}] = node.channels;
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
equal(policy.cltv_delta, cltvDelta, 'Got expected cltv delta');
|
|
67
|
-
equal(policy.fee_rate, feeRate, 'Got expected fee rate');
|
|
68
|
-
equal(policy.is_disabled, false, 'Channel is not disabled');
|
|
69
|
-
equal(policy.max_htlc_mtokens, '990000000', 'Max HTLC mtokens returned');
|
|
70
|
-
equal(policy.min_htlc_mtokens, '1000', 'Min HTLC mtokens returned');
|
|
71
|
-
}
|
|
64
|
+
const policy = policies.find(n => n.public_key === id);
|
|
72
65
|
|
|
73
|
-
|
|
66
|
+
equal(BigInt(policy.base_fee_mtokens), BigInt(baseFee)*mtokPerTok, 'bf');
|
|
67
|
+
equal(policy.cltv_delta, cltvDelta, 'Got expected cltv delta');
|
|
68
|
+
equal(policy.fee_rate, feeRate, 'Got expected fee rate');
|
|
69
|
+
equal(policy.is_disabled, false, 'Channel is not disabled');
|
|
70
|
+
equal(policy.max_htlc_mtokens, '990000000', 'Max HTLC mtokens returned');
|
|
71
|
+
equal(policy.min_htlc_mtokens, '1000', 'Min HTLC mtokens returned');
|
|
72
|
+
}
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
equal(node.color, '#3399ff', 'Color');
|
|
77
|
-
equal(node.sockets.length, 1, 'Socket');
|
|
78
|
-
equal(!!socket.socket, true, 'Ip, port');
|
|
79
|
-
equal(socket.type, 'tcp', 'Socket type');
|
|
80
|
-
equal(node.updated_at.length, 24, 'Update date');
|
|
74
|
+
const [socket] = node.sockets;
|
|
81
75
|
|
|
82
|
-
|
|
76
|
+
equal(node.alias, id.slice(0, defaultAliasLength), 'Alias');
|
|
77
|
+
equal(node.color, '#3399ff', 'Color');
|
|
78
|
+
equal(node.sockets.length, 1, 'Socket');
|
|
79
|
+
equal(!!socket.socket, true, 'Ip, port');
|
|
80
|
+
equal(socket.type, 'tcp', 'Socket type');
|
|
81
|
+
equal(node.updated_at.length, 24, 'Update date');
|
|
82
|
+
} catch (err) {
|
|
83
|
+
strictSame(err, null, 'Expected no error');
|
|
84
|
+
} finally {
|
|
85
|
+
await kill({});
|
|
86
|
+
}
|
|
83
87
|
|
|
84
88
|
return end();
|
|
85
89
|
});
|
|
@@ -177,7 +177,14 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
177
177
|
equal(forceClose.partner_public_key, target.id, 'pk');
|
|
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.2 and below do not support remote balance info
|
|
182
|
+
if (!!forceClose.remote_balance) {
|
|
183
|
+
equal(forceClose.remote_balance, giftTokens, 'Got gift remote balance');
|
|
184
|
+
} else {
|
|
185
|
+
equal(forceClose.remote_balance, 0, 'No remote balance');
|
|
186
|
+
}
|
|
187
|
+
|
|
181
188
|
equal(forceClose.sent, 0, 'No sent amount');
|
|
182
189
|
equal(!!forceClose.timelock_blocks, true, 'Timelock blocks set');
|
|
183
190
|
equal(forceClose.timelock_expiration, startHeight + 265, 'Funds timelock');
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
const asyncRetry = require('async/retry');
|
|
1
2
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
5
|
const {getWalletInfo} = require('./../../');
|
|
5
6
|
|
|
6
7
|
const initHeight = 1;
|
|
8
|
+
const interval = 10;
|
|
7
9
|
const pubKeyHexLength = Buffer.alloc(33).toString('hex').length;
|
|
8
10
|
const regtestChainId = '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f';
|
|
11
|
+
const times = 1000;
|
|
9
12
|
const walletInfoType = 'wallet';
|
|
10
13
|
|
|
11
14
|
// Getting the wallet info should return info about the wallet
|
|
@@ -14,21 +17,33 @@ test(`Get wallet info`, async ({end, equal, strictSame}) => {
|
|
|
14
17
|
|
|
15
18
|
const [{lnd}] = nodes;
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
try {
|
|
21
|
+
const result = await asyncRetry({interval, times}, async () => {
|
|
22
|
+
const result = await getWalletInfo({lnd});
|
|
23
|
+
|
|
24
|
+
if (result.current_block_height === initHeight) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
throw new Error('ExpectedBlockHeightAtInitHeight');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
equal(result.active_channels_count, 0, 'Expected channels count');
|
|
32
|
+
equal(!!result.alias, true, 'Expected alias');
|
|
33
|
+
strictSame(result.chains, [regtestChainId], 'Got chains');
|
|
34
|
+
equal(!!result.current_block_hash, true, 'Expected best block hash');
|
|
35
|
+
equal(result.current_block_height, initHeight, 'Expected best block height');
|
|
36
|
+
equal(!!result.latest_block_at, true, 'Last block time');
|
|
37
|
+
equal(result.peers_count, 0, 'Expected wallet peers count');
|
|
38
|
+
equal(result.pending_channels_count, 0, 'Expected pending channels count');
|
|
39
|
+
equal(result.public_key.length, pubKeyHexLength, 'Expected public key');
|
|
40
|
+
strictSame(result.uris.length, 1, 'Expected node URI');
|
|
41
|
+
equal(!!result.version, true, 'Expected version');
|
|
42
|
+
} catch (err) {
|
|
43
|
+
equal(err, null, 'Expected no error');
|
|
44
|
+
} finally {
|
|
45
|
+
await kill({});
|
|
46
|
+
}
|
|
32
47
|
|
|
33
48
|
return end();
|
|
34
49
|
});
|
|
@@ -4,6 +4,7 @@ const {extractTransaction} = require('psbt');
|
|
|
4
4
|
const {finalizePsbt} = require('psbt');
|
|
5
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
6
6
|
const {test} = require('@alexbosworth/tap');
|
|
7
|
+
const tinysecp = require('tiny-secp256k1');
|
|
7
8
|
const {transactionAsPsbt} = require('psbt');
|
|
8
9
|
|
|
9
10
|
const {addPeer} = require('./../../');
|
|
@@ -29,27 +30,29 @@ const times = 2000;
|
|
|
29
30
|
|
|
30
31
|
// Opening channels should open up channels
|
|
31
32
|
test(`Open channels`, async ({end, equal}) => {
|
|
33
|
+
const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
|
|
34
|
+
|
|
32
35
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
33
36
|
|
|
34
37
|
const [{generate, lnd}, target, remote] = nodes;
|
|
35
38
|
|
|
36
39
|
await generate({count: maturity});
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
try {
|
|
42
|
+
await asyncRetry({interval, times}, async () => {
|
|
43
|
+
const lnds = [lnd, target.lnd, remote.lnd];
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
const heights = await asyncMap(lnds, async lnd => {
|
|
46
|
+
return (await getHeight({lnd})).current_block_height;
|
|
47
|
+
});
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
const [controlHeight, targetHeight, remoteHeight] = heights;
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
if (controlHeight !== targetHeight || controlHeight !== remoteHeight) {
|
|
52
|
+
throw new Error('ExpectedSyncHeights');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
51
55
|
|
|
52
|
-
try {
|
|
53
56
|
const chainTx = (await getChainTransactions({lnd})).transactions;
|
|
54
57
|
|
|
55
58
|
const spending = chainTx.map(({transaction}) => transaction);
|
|
@@ -97,11 +100,15 @@ test(`Open channels`, async ({end, equal}) => {
|
|
|
97
100
|
.map(({transaction}) => transaction)
|
|
98
101
|
.find(transaction => spending.find(spend => transaction !== spend));
|
|
99
102
|
|
|
100
|
-
const fundingPsbt = transactionAsPsbt({
|
|
103
|
+
const fundingPsbt = transactionAsPsbt({
|
|
104
|
+
ecp,
|
|
105
|
+
spending,
|
|
106
|
+
transaction: fundTx,
|
|
107
|
+
});
|
|
101
108
|
|
|
102
|
-
const {psbt} = finalizePsbt({psbt: fundingPsbt.psbt});
|
|
109
|
+
const {psbt} = finalizePsbt({ecp, psbt: fundingPsbt.psbt});
|
|
103
110
|
|
|
104
|
-
const reconstitutedTransaction = extractTransaction({psbt});
|
|
111
|
+
const reconstitutedTransaction = extractTransaction({ecp, psbt});
|
|
105
112
|
|
|
106
113
|
await fundPendingChannels({
|
|
107
114
|
lnd,
|