ln-service 53.6.0 → 53.7.3

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +11 -3
  3. package/index.js +2 -2
  4. package/package.json +5 -4
  5. package/test/integration/test_add_peer.js +26 -20
  6. package/test/integration/test_delete_pending_channel.js +5 -2
  7. package/test/integration/test_get_closed_channels.js +0 -2
  8. package/test/integration/test_get_failed_payments.js +123 -119
  9. package/test/integration/test_get_invoice.js +0 -1
  10. package/test/integration/test_get_node.js +65 -49
  11. package/test/integration/test_get_peers.js +32 -21
  12. package/test/integration/test_get_pending_force.js +1 -1
  13. package/test/integration/test_get_wallet_info.js +35 -18
  14. package/test/integration/test_open_channels.js +22 -15
  15. package/test/integration/test_pay.js +0 -1
  16. package/test/integration/test_pay_private_invoice.js +0 -1
  17. package/test/integration/test_propose_channel.js +438 -421
  18. package/test/integration/test_remove_peer.js +13 -9
  19. package/test/integration/test_send_message_to_peer.js +39 -28
  20. package/test/integration/test_subscribe_to_channels.js +1 -2
  21. package/test/integration/test_subscribe_to_invoices.js +80 -78
  22. package/test/integration/test_subscribe_to_peer_messages.js +81 -73
  23. package/test/integration/test_subscribe_to_peers.js +23 -19
  24. package/test/invoicesrpc-integration/test_get_sweep_transactions.js +0 -2
  25. package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +0 -1
  26. package/test/macros/wait_for_channel.js +1 -1
  27. package/test/routerrpc-integration/test_delete_forwarding_reputations.js +61 -27
  28. package/test/routerrpc-integration/test_get_forwarding_reputations.js +74 -42
  29. package/test/routerrpc-integration/test_get_route_confidence.js +38 -34
  30. package/test/routerrpc-integration/test_get_route_through_hops.js +45 -17
  31. package/test/routerrpc-integration/test_multipath_payment.js +0 -1
  32. package/test/routerrpc-integration/test_pay_via_payment_details.js +118 -111
  33. package/test/routerrpc-integration/test_pay_via_payment_request.js +92 -80
  34. package/test/routerrpc-integration/test_pay_via_routes.js +19 -1
  35. package/test/routerrpc-integration/test_probe_for_route.js +78 -74
  36. package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +2 -3
  37. package/test/routerrpc-integration/test_subscribe_to_forwards.js +518 -505
  38. package/test/routerrpc-integration/test_subscribe_to_past_payments.js +0 -3
  39. package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +0 -3
  40. package/test/walletrpc-integration/test_fund_psbt.js +113 -1
  41. package/test/walletrpc-integration/test_partially_sign_psbt.js +12 -5
  42. package/test/walletrpc-integration/test_sign_psbt.js +4 -1
@@ -15,27 +15,38 @@ test('Get peers', async ({end, equal}) => {
15
15
 
16
16
  const [{lnd}, target] = nodes;
17
17
 
18
- await asyncRetry({interval, times}, async () => {
19
- await addPeer({lnd, public_key: target.id, socket: target.socket});
20
-
21
- const [peer] = (await getPeers({lnd})).peers;
22
-
23
- if (!peer || !peer.is_sync_peer) {
24
- throw new Error('ExpectedSyncPeer');
25
- }
26
-
27
- equal(peer.bytes_received !== undefined, true, 'Bytes received');
28
- equal(peer.bytes_sent !== undefined, true, 'Bytes sent');
29
- equal(peer.is_inbound, false, 'Is inbound peer');
30
- equal(peer.is_sync_peer, true, 'Is sync peer');
31
- equal(peer.ping_time, 0, 'Ping time');
32
- equal(peer.public_key, target.id, 'Public key');
33
- equal(!!peer.socket, true, 'Socket');
34
- equal(peer.tokens_received, 0, 'Tokens received');
35
- equal(peer.tokens_sent, 0, 'Tokens sent');
36
-
37
- return;
38
- });
18
+ try {
19
+ await asyncRetry({interval, times}, async () => {
20
+ await addPeer({
21
+ lnd,
22
+ public_key: target.id,
23
+ retry_count: 1,
24
+ retry_delay: 1,
25
+ socket: target.socket,
26
+ timeout: 100,
27
+ });
28
+
29
+ const [peer] = (await getPeers({lnd})).peers;
30
+
31
+ if (!peer || !peer.is_sync_peer) {
32
+ throw new Error('ExpectedSyncPeer');
33
+ }
34
+
35
+ equal(peer.bytes_received !== undefined, true, 'Bytes received');
36
+ equal(peer.bytes_sent !== undefined, true, 'Bytes sent');
37
+ equal(peer.is_inbound, false, 'Is inbound peer');
38
+ equal(peer.is_sync_peer, true, 'Is sync peer');
39
+ equal(peer.ping_time, 0, 'Ping time');
40
+ equal(peer.public_key, target.id, 'Public key');
41
+ equal(!!peer.socket, true, 'Socket');
42
+ equal(peer.tokens_received, 0, 'Tokens received');
43
+ equal(peer.tokens_sent, 0, 'Tokens sent');
44
+
45
+ return;
46
+ });
47
+ } catch (err) {
48
+ equal(err, null, 'Expected no error');
49
+ }
39
50
 
40
51
  await kill({});
41
52
 
@@ -178,7 +178,7 @@ test(`Get pending channels`, async ({end, equal}) => {
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.1 and below do not support remote balance info
181
+ // LND 0.14.2 and below do not support remote balance info
182
182
  if (!!forceClose.remote_balance) {
183
183
  equal(forceClose.remote_balance, giftTokens, 'Got gift remote balance');
184
184
  } else {
@@ -1,34 +1,51 @@
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
12
- test(`Get wallet info`, async ({end, equal, strictSame}) => {
15
+ test(`Get wallet info`, async ({end, equal, ok, strictSame}) => {
13
16
  const {kill, nodes} = await spawnLightningCluster({});
14
17
 
15
- const [{lnd}] = nodes;
16
-
17
- const result = await getWalletInfo({lnd});
18
-
19
- equal(result.active_channels_count, 0, 'Expected channels count');
20
- equal(!!result.alias, true, 'Expected alias');
21
- strictSame(result.chains, [regtestChainId], 'Got chains');
22
- equal(!!result.current_block_hash, true, 'Expected best block hash');
23
- equal(result.current_block_height, initHeight, 'Expected best block height');
24
- equal(!!result.latest_block_at, true, 'Last block time');
25
- equal(result.peers_count, 0, 'Expected wallet peers count');
26
- equal(result.pending_channels_count, 0, 'Expected pending channels count');
27
- equal(result.public_key.length, pubKeyHexLength, 'Expected public key');
28
- strictSame(result.uris.length, 1, 'Expected node URI');
29
- equal(!!result.version, true, 'Expected version');
30
-
31
- await kill({});
18
+ const [{generate, lnd}] = nodes;
19
+
20
+ try {
21
+ const result = await asyncRetry({interval, times}, async () => {
22
+ await generate({});
23
+
24
+ const result = await getWalletInfo({lnd});
25
+
26
+ if (result.current_block_height >= initHeight) {
27
+ return result;
28
+ }
29
+
30
+ throw new Error('ExpectedBlockHeightAtInitHeight');
31
+ });
32
+
33
+ equal(result.active_channels_count, 0, 'Expected channels count');
34
+ equal(!!result.alias, true, 'Expected alias');
35
+ strictSame(result.chains, [regtestChainId], 'Got chains');
36
+ equal(!!result.current_block_hash, true, 'Expected best block hash');
37
+ ok(result.current_block_height >= initHeight, 'Expected block height');
38
+ equal(!!result.latest_block_at, true, 'Last block time');
39
+ equal(result.peers_count, 0, 'Expected wallet peers count');
40
+ equal(result.pending_channels_count, 0, 'Expected pending channels count');
41
+ equal(result.public_key.length, pubKeyHexLength, 'Expected public key');
42
+ strictSame(result.uris.length, 1, 'Expected node URI');
43
+ equal(!!result.version, true, 'Expected version');
44
+ } catch (err) {
45
+ equal(err, null, 'Expected no error');
46
+ } finally {
47
+ await kill({});
48
+ }
32
49
 
33
50
  return end();
34
51
  });
@@ -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
- await generate({count: maturity});
39
+ try {
40
+ await generate({count: maturity});
37
41
 
38
- await asyncRetry({interval, times}, async () => {
39
- const lnds = [lnd, target.lnd, remote.lnd];
42
+ await asyncRetry({interval, times}, async () => {
43
+ const lnds = [lnd, target.lnd, remote.lnd];
40
44
 
41
- const heights = await asyncMap(lnds, async lnd => {
42
- return (await getHeight({lnd})).current_block_height;
43
- });
45
+ const heights = await asyncMap(lnds, async lnd => {
46
+ return (await getHeight({lnd})).current_block_height;
47
+ });
44
48
 
45
- const [controlHeight, targetHeight, remoteHeight] = heights;
49
+ const [controlHeight, targetHeight, remoteHeight] = heights;
46
50
 
47
- if (controlHeight !== targetHeight || controlHeight !== remoteHeight) {
48
- throw new Error('ExpectedSyncHeights');
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({spending, transaction: fundTx});
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,
@@ -10,7 +10,6 @@ const {createInvoice} = require('./../../');
10
10
  const {decodePaymentRequest} = require('./../../');
11
11
  const {delay} = require('./../macros');
12
12
  const {getChannel} = require('./../../');
13
- const {getChannels} = require('./../../');
14
13
  const {getHeight} = require('./../../');
15
14
  const {getNetworkGraph} = require('./../../');
16
15
  const {getRouteToDestination} = require('./../../');
@@ -8,7 +8,6 @@ const {cancelHodlInvoice} = require('./../../');
8
8
  const {createInvoice} = require('./../../');
9
9
  const {decodePaymentRequest} = require('./../../');
10
10
  const {getChannel} = require('./../../');
11
- const {getChannels} = require('./../../');
12
11
  const {getInvoice} = require('./../../');
13
12
  const {getRouteToDestination} = require('./../../');
14
13
  const {openChannel} = require('./../../');