ln-service 59.5.0 → 59.7.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.
Files changed (168) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +93 -9
  3. package/package.json +7 -2
  4. package/.gitattributes +0 -1
  5. package/.tm_properties +0 -1
  6. package/test/autopilotrpc-integration/test_autopilot.js +0 -87
  7. package/test/chainrpc-integration/test_get_block.js +0 -58
  8. package/test/chainrpc-integration/test_get_block_header.js +0 -62
  9. package/test/chainrpc-integration/test_get_height.js +0 -42
  10. package/test/chainrpc-integration/test_subscribe_to_blocks.js +0 -97
  11. package/test/chainrpc-integration/test_subscribe_to_chain_address.js +0 -119
  12. package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +0 -116
  13. package/test/integration/test_add_peer.js +0 -59
  14. package/test/integration/test_cancel_pending_channel.js +0 -46
  15. package/test/integration/test_close_channel.js +0 -60
  16. package/test/integration/test_close_wait_pending.js +0 -121
  17. package/test/integration/test_create_chain_address.js +0 -63
  18. package/test/integration/test_create_invoice.js +0 -49
  19. package/test/integration/test_decode_payment_request.js +0 -75
  20. package/test/integration/test_delete_payment.js +0 -38
  21. package/test/integration/test_delete_payments.js +0 -42
  22. package/test/integration/test_delete_pending_channel.js +0 -202
  23. package/test/integration/test_encrypted_routes.js +0 -162
  24. package/test/integration/test_get_access_ids.js +0 -27
  25. package/test/integration/test_get_backup.js +0 -40
  26. package/test/integration/test_get_backups.js +0 -38
  27. package/test/integration/test_get_chain_balance.js +0 -36
  28. package/test/integration/test_get_chain_fee_estimate.js +0 -63
  29. package/test/integration/test_get_chain_transactions.js +0 -83
  30. package/test/integration/test_get_channel.js +0 -64
  31. package/test/integration/test_get_channel_balance.js +0 -23
  32. package/test/integration/test_get_channels.js +0 -84
  33. package/test/integration/test_get_closed_channels.js +0 -275
  34. package/test/integration/test_get_configuration.js +0 -35
  35. package/test/integration/test_get_failed_payments.js +0 -164
  36. package/test/integration/test_get_fee_rates.js +0 -40
  37. package/test/integration/test_get_forwards.js +0 -144
  38. package/test/integration/test_get_invoice.js +0 -67
  39. package/test/integration/test_get_invoices.js +0 -88
  40. package/test/integration/test_get_methods.js +0 -30
  41. package/test/integration/test_get_network_centrality.js +0 -72
  42. package/test/integration/test_get_network_graph.js +0 -87
  43. package/test/integration/test_get_network_info.js +0 -33
  44. package/test/integration/test_get_node.js +0 -117
  45. package/test/integration/test_get_payments.js +0 -69
  46. package/test/integration/test_get_peers.js +0 -58
  47. package/test/integration/test_get_pending_coop.js +0 -122
  48. package/test/integration/test_get_pending_force.js +0 -172
  49. package/test/integration/test_get_pending_payments.js +0 -86
  50. package/test/integration/test_get_route_to_destination.js +0 -153
  51. package/test/integration/test_get_settlement_status.js +0 -78
  52. package/test/integration/test_get_utxos.js +0 -49
  53. package/test/integration/test_get_wallet_info.js +0 -55
  54. package/test/integration/test_grant_access.js +0 -69
  55. package/test/integration/test_open_channel.js +0 -93
  56. package/test/integration/test_open_channel_max.js +0 -92
  57. package/test/integration/test_open_channels.js +0 -164
  58. package/test/integration/test_open_low_reserve.js +0 -92
  59. package/test/integration/test_open_simplified_taproot.js +0 -174
  60. package/test/integration/test_open_standard_taproot.js +0 -94
  61. package/test/integration/test_pay.js +0 -149
  62. package/test/integration/test_pay_private_invoice.js +0 -120
  63. package/test/integration/test_payment_errors.js +0 -102
  64. package/test/integration/test_propose_channel.js +0 -474
  65. package/test/integration/test_push_funds.js +0 -82
  66. package/test/integration/test_rebalance.js +0 -70
  67. package/test/integration/test_recover_funds_from_channel.js +0 -207
  68. package/test/integration/test_recover_funds_from_channels.js +0 -203
  69. package/test/integration/test_remove_peer.js +0 -52
  70. package/test/integration/test_restrict_macaroon.js +0 -96
  71. package/test/integration/test_revoke_access.js +0 -41
  72. package/test/integration/test_send_message_to_peer.js +0 -91
  73. package/test/integration/test_send_to_chain_address.js +0 -109
  74. package/test/integration/test_send_to_chain_addresses.js +0 -71
  75. package/test/integration/test_sign_message.js +0 -22
  76. package/test/integration/test_stop_daemon.js +0 -33
  77. package/test/integration/test_subscribe_to_backups.js +0 -94
  78. package/test/integration/test_subscribe_to_channels.js +0 -186
  79. package/test/integration/test_subscribe_to_graph.js +0 -176
  80. package/test/integration/test_subscribe_to_invoices.js +0 -147
  81. package/test/integration/test_subscribe_to_messages.js +0 -180
  82. package/test/integration/test_subscribe_to_open_requests.js +0 -167
  83. package/test/integration/test_subscribe_to_peer_messages.js +0 -130
  84. package/test/integration/test_subscribe_to_peers.js +0 -61
  85. package/test/integration/test_subscribe_to_rpc_requests.js +0 -309
  86. package/test/integration/test_subscribe_to_transactions.js +0 -93
  87. package/test/integration/test_trusted_funding.js +0 -302
  88. package/test/integration/test_trusted_open.js +0 -94
  89. package/test/integration/test_update_routing_fees.js +0 -108
  90. package/test/integration/test_verify_access.js +0 -38
  91. package/test/integration/test_verify_backup.js +0 -53
  92. package/test/integration/test_verify_backups.js +0 -54
  93. package/test/integration/test_verify_message.js +0 -24
  94. package/test/invoicesrpc-integration/test_cancel_invoice.js +0 -91
  95. package/test/invoicesrpc-integration/test_create_hinted_invoice.js +0 -95
  96. package/test/invoicesrpc-integration/test_get_sweep_transactions.js +0 -124
  97. package/test/invoicesrpc-integration/test_push_payment.js +0 -92
  98. package/test/invoicesrpc-integration/test_settle_invoice.js +0 -136
  99. package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +0 -124
  100. package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +0 -123
  101. package/test/macros/index.js +0 -19
  102. package/test/macros/setup_channel.js +0 -101
  103. package/test/macros/wait_for_channel.js +0 -99
  104. package/test/macros/wait_for_pending_channel.js +0 -52
  105. package/test/macros/wait_for_route.js +0 -76
  106. package/test/macros/wait_for_termination.js +0 -29
  107. package/test/macros/wait_for_utxo.js +0 -56
  108. package/test/peersrpc-integration/test_add_advertised_feature.js +0 -43
  109. package/test/peersrpc-integration/test_add_external_socket.js +0 -36
  110. package/test/peersrpc-integration/test_remove_advertised_feature.js +0 -37
  111. package/test/peersrpc-integration/test_remove_external_socket.js +0 -34
  112. package/test/peersrpc-integration/test_update_alias.js +0 -33
  113. package/test/peersrpc-integration/test_update_color.js +0 -33
  114. package/test/routerrpc-integration/test_delete_forwarding_reputations.js +0 -101
  115. package/test/routerrpc-integration/test_disable_channel.js +0 -41
  116. package/test/routerrpc-integration/test_get_forwarding_confidence.js +0 -90
  117. package/test/routerrpc-integration/test_get_forwarding_reputations.js +0 -128
  118. package/test/routerrpc-integration/test_get_pathfinding_settings.js +0 -40
  119. package/test/routerrpc-integration/test_get_payment.js +0 -130
  120. package/test/routerrpc-integration/test_get_route_confidence.js +0 -77
  121. package/test/routerrpc-integration/test_get_route_through_hops.js +0 -148
  122. package/test/routerrpc-integration/test_get_routing_fee_estimate.js +0 -76
  123. package/test/routerrpc-integration/test_is_destination_payable.js +0 -53
  124. package/test/routerrpc-integration/test_multipath_payment.js +0 -178
  125. package/test/routerrpc-integration/test_pay_via_payment_details.js +0 -175
  126. package/test/routerrpc-integration/test_pay_via_payment_request.js +0 -151
  127. package/test/routerrpc-integration/test_pay_via_routes.js +0 -224
  128. package/test/routerrpc-integration/test_probe_for_route.js +0 -153
  129. package/test/routerrpc-integration/test_route_from_channels_complex.js +0 -327
  130. package/test/routerrpc-integration/test_route_from_channels_simple.js +0 -151
  131. package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +0 -225
  132. package/test/routerrpc-integration/test_subscribe_to_forwards.js +0 -552
  133. package/test/routerrpc-integration/test_subscribe_to_past_payments.js +0 -81
  134. package/test/routerrpc-integration/test_subscribe_to_payments.js +0 -115
  135. package/test/routerrpc-integration/test_update_pathfinding_settings.js +0 -71
  136. package/test/runner.js +0 -30
  137. package/test/signerrpc-integration/test_begin_group_signing_session.js +0 -505
  138. package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +0 -37
  139. package/test/signerrpc-integration/test_sign_bytes.js +0 -76
  140. package/test/signerrpc-integration/test_sign_taproot.js +0 -436
  141. package/test/signerrpc-integration/test_sign_transaction.js +0 -35
  142. package/test/signerrpc-integration/test_verify_bytes_signature.js +0 -103
  143. package/test/tower_clientrpc-integration/test_connect_watchtower.js +0 -60
  144. package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +0 -70
  145. package/test/tower_serverrpc-integration/test_get_tower_server_info.js +0 -34
  146. package/test/versionrpc-integration/test_get_wallet_version.js +0 -38
  147. package/test/walletrpc-integration/test_broadcast_chain_transaction.js +0 -62
  148. package/test/walletrpc-integration/test_create_funded_psbt.js +0 -141
  149. package/test/walletrpc-integration/test_delete_chain_transaction.js +0 -82
  150. package/test/walletrpc-integration/test_fund_psbt.js +0 -489
  151. package/test/walletrpc-integration/test_get_chain_addresses.js +0 -60
  152. package/test/walletrpc-integration/test_get_chain_fee_rate.js +0 -24
  153. package/test/walletrpc-integration/test_get_chain_transaction.js +0 -70
  154. package/test/walletrpc-integration/test_get_locked_utxos.js +0 -67
  155. package/test/walletrpc-integration/test_get_master_public_keys.js +0 -84
  156. package/test/walletrpc-integration/test_get_minimum_relay_fee.js +0 -26
  157. package/test/walletrpc-integration/test_get_pending_sweeps.js +0 -83
  158. package/test/walletrpc-integration/test_get_public_key.js +0 -28
  159. package/test/walletrpc-integration/test_lock_utxo.js +0 -80
  160. package/test/walletrpc-integration/test_partially_sign_psbt.js +0 -224
  161. package/test/walletrpc-integration/test_request_batched_fee_increase.js +0 -60
  162. package/test/walletrpc-integration/test_request_chain_fee_increase.js +0 -63
  163. package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +0 -69
  164. package/test/walletrpc-integration/test_sign_chain_address_message.js +0 -32
  165. package/test/walletrpc-integration/test_sign_psbt.js +0 -108
  166. package/test/walletrpc-integration/test_unlock_utxo.js +0 -72
  167. package/test/walletrpc-integration/test_update_chain_transaction.js +0 -43
  168. package/test/walletrpc-integration/test_verify_chain_address_message.js +0 -60
@@ -1,33 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {setupChannel} = require('ln-docker-daemons');
5
- const {spawnLightningCluster} = require('ln-docker-daemons');
6
-
7
- const {getNetworkInfo} = require('./../../');
8
-
9
- const size = 2;
10
- const tokens = 1e6;
11
-
12
- // Getting the network info should return basic network statistics
13
- test(`Get network info`, async () => {
14
- const {kill, nodes} = await spawnLightningCluster({size});
15
-
16
- const [{generate, lnd}, target] = nodes;
17
-
18
- await setupChannel({generate, lnd, to: target});
19
-
20
- const result = await getNetworkInfo({lnd});
21
-
22
- strictEqual(result.average_channel_size, tokens, 'Average channel size');
23
- strictEqual(result.channel_count, 1, 'Channel count');
24
- strictEqual(result.max_channel_size, tokens, 'Maximum channel size');
25
- strictEqual(result.median_channel_size, tokens, 'Median channel size');
26
- strictEqual(result.min_channel_size, tokens, 'Minimum channel size');
27
- strictEqual(result.not_recently_updated_policy_count, 0, 'No updated count');
28
- strictEqual(result.total_capacity, tokens, 'Total capacity');
29
-
30
- await kill({});
31
-
32
- return;
33
- });
@@ -1,117 +0,0 @@
1
- const {strictEqual} = 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 {addPeer} = require('./../../');
9
- const {getIdentity} = require('./../../');
10
- const {getNode} = require('./../../');
11
- const {updateRoutingFees} = require('./../../');
12
-
13
- const baseFee = 1337;
14
- const channelCapacityTokens = 1e6;
15
- const cltvDelta = 42;
16
- const confirmationCount = 20;
17
- const defaultFee = 1e3;
18
- const defaultAliasLength = '00000000000000000000'.length;
19
- const delay = n => new Promise(resolve => setTimeout(resolve, n));
20
- const feeRate = 21;
21
- const interval = 10;
22
- const mtokPerTok = BigInt(1e3);
23
- const size = 3;
24
- const times = 1000;
25
-
26
- // Getting a node should return the public graph node info
27
- test(`Get node`, async () => {
28
- const {kill, nodes} = await spawnLightningCluster({size});
29
-
30
- const [{generate, id, lnd}, target, remote] = nodes;
31
-
32
- try {
33
- const controlToTarget = await asyncRetry({interval, times}, async () => {
34
- await generate({});
35
-
36
- return await setupChannel({generate, lnd, to: target});
37
- });
38
-
39
- const targetToRemote = await asyncRetry({interval, times}, async () => {
40
- await target.generate({});
41
-
42
- return await setupChannel({
43
- generate: target.generate,
44
- lnd: target.lnd,
45
- to: remote,
46
- });
47
- });
48
-
49
- await updateRoutingFees({
50
- lnd,
51
- base_fee_tokens: baseFee,
52
- cltv_delta: cltvDelta,
53
- fee_rate: feeRate,
54
- transaction_id: controlToTarget.transaction_id,
55
- transaction_vout: controlToTarget.transaction_vout,
56
- });
57
-
58
- await asyncRetry({interval, times}, async () => {
59
- await generate({});
60
-
61
- await addPeer({
62
- lnd,
63
- public_key: remote.id,
64
- retry_count: 1,
65
- retry_delay: 1,
66
- socket: remote.socket,
67
- timeout: 1000,
68
- });
69
- });
70
-
71
- const node = await getNode({lnd, public_key: id});
72
-
73
- {
74
- const {channels} = await getNode({
75
- lnd,
76
- is_omitting_channels: true,
77
- public_key: id,
78
- });
79
-
80
- strictEqual(channels.length, [].length, 'Channels are omitted');
81
- }
82
-
83
- if (!!node.channels.length) {
84
- const [{policies}] = node.channels;
85
-
86
- const policy = policies.find(n => n.public_key === id);
87
-
88
- strictEqual(
89
- BigInt(policy.base_fee_mtokens),
90
- BigInt(baseFee) * mtokPerTok,
91
- 'bf'
92
- );
93
- strictEqual(policy.cltv_delta, cltvDelta, 'Got expected cltv delta');
94
- strictEqual(policy.fee_rate, feeRate, 'Got expected fee rate');
95
- strictEqual(policy.is_disabled, false, 'Channel is not disabled');
96
- strictEqual(policy.max_htlc_mtokens, '990000000', 'Max HTLC returned');
97
- strictEqual(policy.min_htlc_mtokens, '1000', 'Min HTLC returned');
98
- }
99
-
100
- const [socket] = node.sockets;
101
-
102
- strictEqual(node.alias, id.slice(0, defaultAliasLength), 'Alias');
103
- strictEqual(node.color, '#3399ff', 'Color');
104
- strictEqual(node.sockets.length, 1, 'Socket');
105
- strictEqual(!!socket.socket, true, 'Ip, port');
106
- strictEqual(socket.type, 'tcp', 'Socket type');
107
- strictEqual(node.updated_at.length, 24, 'Update date');
108
-
109
- await kill({});
110
- } catch (err) {
111
- await kill({});
112
-
113
- strictEqual(err, null, 'Expected no error');
114
- }
115
-
116
- return;
117
- });
@@ -1,69 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const asyncTimesSeries = require('async/timesSeries');
5
- const {setupChannel} = require('ln-docker-daemons');
6
- const {spawnLightningCluster} = require('ln-docker-daemons');
7
-
8
- const {createInvoice} = require('./../../');
9
- const {getPayments} = require('./../../');
10
- const {pay} = require('./../../');
11
-
12
- const start = new Date().toISOString();
13
- const size = 2;
14
- const tokens = 100;
15
-
16
- // Getting payments should return the list of payments
17
- test('Get payments', async () => {
18
- const {kill, nodes} = await spawnLightningCluster({size});
19
-
20
- const [{generate, lnd}, target] = nodes;
21
-
22
- await setupChannel({generate, lnd, to: target});
23
-
24
- const invoice = await createInvoice({tokens, lnd: target.lnd});
25
-
26
- const paid = await pay({lnd, request: invoice.request});
27
-
28
- const [payment] = (await getPayments({lnd})).payments;
29
-
30
- strictEqual(payment.destination, target.id, 'Destination');
31
- strictEqual(payment.confirmed_at > start, true, 'Got confirmed date');
32
- strictEqual(payment.created_at.length, 24, 'Created at time');
33
- strictEqual(payment.fee, 0, 'Fee paid');
34
- strictEqual(payment.hops.length, [].length, 'Hops');
35
- strictEqual(payment.id, invoice.id, 'Id');
36
- strictEqual(payment.is_confirmed, true, 'Confirmed');
37
- strictEqual(payment.is_outgoing, true, 'Outgoing');
38
- strictEqual(payment.mtokens, (BigInt(tokens) * BigInt(1e3)).toString(), 'M');
39
- strictEqual(payment.secret, invoice.secret, 'Payment secret');
40
- strictEqual(payment.tokens, tokens, 'Paid tokens');
41
-
42
- if (!!payment.request) {
43
- strictEqual(payment.request, invoice.request, 'Returns original request');
44
- }
45
-
46
- await asyncTimesSeries(4, async () => {
47
- const {request} = await createInvoice({tokens, lnd: target.lnd});
48
-
49
- const paid = await pay({lnd, request});
50
- });
51
-
52
- const page1 = await getPayments({lnd, limit: 2});
53
-
54
- const [firstOfPage1] = page1.payments;
55
-
56
- const page2 = await getPayments({lnd, token: page1.next});
57
-
58
- const [firstOfPage2] = page2.payments;
59
-
60
- strictEqual(firstOfPage2.index, 3, 'Got payment index');
61
-
62
- const page3 = await getPayments({lnd, token: page2.next});
63
-
64
- strictEqual(!!page3.next, false, 'There is no page 4');
65
-
66
- await kill({});
67
-
68
- return;
69
- });
@@ -1,58 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const asyncRetry = require('async/retry');
5
- const {spawnLightningCluster} = require('ln-docker-daemons');
6
-
7
- const {addPeer} = require('./../../');
8
- const {getPeers} = require('./../../');
9
-
10
- const interval = 10
11
- const size = 2;
12
- const times = 2000;
13
-
14
- // Getting peers should return the list of peers
15
- test('Get peers', async () => {
16
- const {kill, nodes} = await spawnLightningCluster({size});
17
-
18
- const [{generate, lnd}, target] = nodes;
19
-
20
- try {
21
- await asyncRetry({interval, times}, async () => {
22
- await generate({});
23
-
24
- await addPeer({
25
- lnd,
26
- public_key: target.id,
27
- retry_count: 1,
28
- retry_delay: 1,
29
- socket: target.socket,
30
- timeout: 100,
31
- });
32
-
33
- const [peer] = (await getPeers({lnd})).peers;
34
-
35
- if (!peer || !peer.is_sync_peer) {
36
- throw new Error('ExpectedSyncPeer');
37
- }
38
-
39
- strictEqual(peer.bytes_received !== undefined, true, 'Bytes received');
40
- strictEqual(peer.bytes_sent !== undefined, true, 'Bytes sent');
41
- strictEqual(peer.is_inbound, false, 'Is inbound peer');
42
- strictEqual(peer.is_sync_peer, true, 'Is sync peer');
43
- strictEqual(peer.ping_time, 0, 'Ping time');
44
- strictEqual(peer.public_key, target.id, 'Public key');
45
- strictEqual(!!peer.socket, true, 'Socket');
46
- strictEqual(peer.tokens_received, 0, 'Tokens received');
47
- strictEqual(peer.tokens_sent, 0, 'Tokens sent');
48
-
49
- return;
50
- });
51
- } catch (err) {
52
- strictEqual(err, null, 'Expected no error');
53
- }
54
-
55
- await kill({});
56
-
57
- return;
58
- });
@@ -1,122 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const {strictEqual} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const asyncRetry = require('async/retry');
6
- const {componentsOfTransaction} = require('@alexbosworth/blockchain');
7
- const {idForTransactionComponents} = require('@alexbosworth/blockchain');
8
- const {setupChannel} = require('ln-docker-daemons');
9
- const {spawnLightningCluster} = require('ln-docker-daemons');
10
-
11
- const {closeChannel} = require('./../../');
12
- const {getPendingChannels} = require('./../../');
13
- const {getWalletInfo} = require('./../../');
14
-
15
- const defaultFee = 1e3;
16
- const give = 1e4;
17
- const hexAsBuffer = hex => Buffer.from(hex, 'hex');
18
- const interval = 10;
19
- const size = 2;
20
- const times = 2000;
21
-
22
- // Getting pending channels should show pending channels
23
- test(`Get pending channels`, async () => {
24
- const {kill, nodes} = await spawnLightningCluster({size});
25
-
26
- const [{generate, lnd}, target] = nodes;
27
-
28
- try {
29
- const {features} = await getWalletInfo({lnd});
30
-
31
- // Target starts a channel with control
32
- const coopChan = await setupChannel({
33
- generate,
34
- lnd,
35
- give_tokens: give,
36
- to: target,
37
- });
38
-
39
- // Target closes the channel
40
- const niceClose = await closeChannel({
41
- lnd: target.lnd,
42
- tokens_per_vbyte: 100,
43
- transaction_id: coopChan.transaction_id,
44
- transaction_vout: coopChan.transaction_vout,
45
- });
46
-
47
- // Control views their pending channels
48
- const {channel} = await asyncRetry({interval, times}, async () => {
49
- const res = await getPendingChannels({lnd});
50
-
51
- const id = coopChan.transaction_id;
52
-
53
- const channel = res.pending_channels.find(n => n.transaction_id === id);
54
-
55
- if (!channel) {
56
- throw new Error('FailedToFindPendingChannelWithTransactionId');
57
- }
58
-
59
- return {channel};
60
- });
61
-
62
- const transaction = channel.close_transaction;
63
-
64
- // LND 0.17.4 and below do not support close_transaction
65
- if (!!transaction) {
66
- const components = componentsOfTransaction({transaction});
67
-
68
- const closing = idForTransactionComponents({
69
- inputs: components.inputs.map(input => ({
70
- hash: hexAsBuffer(input.id).reverse(),
71
- script: hexAsBuffer(input.script),
72
- sequence: input.sequence,
73
- vout: input.vout,
74
- })),
75
- locktime: components.locktime,
76
- outputs: components.outputs.map(output => ({
77
- script: hexAsBuffer(output.script),
78
- tokens: output.tokens,
79
- })),
80
- version: components.version,
81
- });
82
-
83
- equal(closing.id, channel.close_transaction_id, 'Got closing tx');
84
- }
85
-
86
- if (channel.is_partner_initiated !== undefined) {
87
- strictEqual(channel.is_partner_initiated, false, 'Channel initiated');
88
- }
89
-
90
- strictEqual(channel.local_balance, 986530, 'Original balance');
91
- strictEqual(channel.pending_balance, 986530, 'Waiting on balance');
92
-
93
- strictEqual(channel.capacity, 1000000, 'Got channel capacity');
94
- strictEqual(channel.is_active, false, 'Ended');
95
- strictEqual(channel.is_closing, true, 'Closing');
96
- strictEqual(channel.is_opening, false, 'Not Opening');
97
- strictEqual(channel.local_reserve, 10000, 'Local reserve');
98
- strictEqual(channel.partner_public_key, target.id, 'Target public key');
99
- strictEqual(channel.pending_payments, undefined, 'No pending payments');
100
- strictEqual(channel.received, 0, 'Never received');
101
- strictEqual(channel.recovered_tokens, undefined, 'Nothing to recover');
102
- strictEqual(channel.remote_reserve, 10000, 'Remote reserve');
103
- strictEqual(channel.sent, 0, 'Never sent anything');
104
- strictEqual(channel.timelock_expiration, undefined, 'No timelock in coop');
105
- strictEqual(channel.transaction_fee, null, 'No transaction fee data');
106
- strictEqual(channel.transaction_id, coopChan.transaction_id, 'funding tx');
107
- strictEqual(channel.transaction_vout, coopChan.transaction_vout, 'Vout');
108
- strictEqual(channel.transaction_weight, null, 'No funding tx weight data');
109
-
110
- if (!!channel.remote_balance) {
111
- strictEqual(channel.remote_balance, give, 'Opposing channel balance');
112
- }
113
-
114
- await kill({});
115
- } catch (err) {
116
- await kill({});
117
-
118
- strictEqual(err, null, 'Expected no error');
119
- }
120
-
121
- return;
122
- });
@@ -1,172 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const asyncRetry = require('async/retry');
5
- const {spawnLightningCluster} = require('ln-docker-daemons');
6
-
7
- const {addPeer} = require('./../../');
8
- const {closeChannel} = require('./../../');
9
- const {getChannels} = require('./../../');
10
- const {getHeight} = require('./../../');
11
- const {getPendingChannels} = require('./../../');
12
- const {getWalletInfo} = require('./../../');
13
- const {openChannel} = require('./../../');
14
-
15
- const anchorFeatureBit = 23;
16
- const channelCapacityTokens = 1e6;
17
- const confirmationCount = 20;
18
- const count = 100;
19
- const defaultFee = 1e3;
20
- const defaultVout = 0;
21
- const giftTokens = 1e4;
22
- const interval = 10;
23
- const size = 2;
24
- const spendableRatio = 0.99;
25
- const times = 2000;
26
-
27
- // Getting pending channels should show pending channels
28
- test(`Get pending channels`, async () => {
29
- const {kill, nodes} = await spawnLightningCluster({size});
30
-
31
- const [{generate, lnd}, target] = nodes;
32
-
33
- const {features} = await getWalletInfo({lnd});
34
-
35
- const isAnchors = !!features.find(n => n.bit === anchorFeatureBit);
36
- const startHeight = (await getHeight({lnd})).current_block_height;
37
-
38
- await generate({count});
39
-
40
- const channelOpen = await asyncRetry({interval, times}, async () => {
41
- await addPeer({lnd, public_key: target.id, socket: target.socket});
42
-
43
- return await openChannel({
44
- lnd,
45
- chain_fee_tokens_per_vbyte: defaultFee,
46
- give_tokens: giftTokens,
47
- local_tokens: channelCapacityTokens,
48
- partner_csv_delay: 10,
49
- partner_public_key: target.id,
50
- socket: target.socket,
51
- });
52
- });
53
-
54
- await getPendingChannels({lnd, id: channelOpen.transaction_id});
55
-
56
- const [pendingOpen] = (await getPendingChannels({lnd})).pending_channels;
57
-
58
- strictEqual(pendingOpen.local_balance, 986530, 'Local balance minus gift');
59
- strictEqual(pendingOpen.transaction_fee, 2810, 'Transaction fee tokens');
60
- strictEqual(pendingOpen.transaction_weight, 1116, 'Channel tx weight');
61
-
62
- strictEqual(pendingOpen.capacity, 1000000, 'Got channel opening capacity');
63
- strictEqual(pendingOpen.is_active, false, 'Not active yet');
64
- strictEqual(pendingOpen.is_closing, false, 'Not closing yet');
65
- strictEqual(pendingOpen.is_opening, true, 'Channel is opening');
66
- strictEqual(pendingOpen.local_reserve, 10000, 'Local reserve amount');
67
- strictEqual(pendingOpen.partner_public_key, target.id, 'Key');
68
- strictEqual(pendingOpen.pending_balance, undefined, 'No pending balance');
69
- strictEqual(pendingOpen.pending_payments, undefined, 'No pending payments');
70
- strictEqual(pendingOpen.received, 0, 'Nothing received');
71
- strictEqual(pendingOpen.recovered_tokens, undefined, 'Nothing recovered');
72
- strictEqual(pendingOpen.remote_balance, giftTokens, 'Tokens gifted');
73
- strictEqual(pendingOpen.remote_reserve, 10000, 'Remote reserve amount');
74
- strictEqual(pendingOpen.sent, 0, 'Nothing sent');
75
- strictEqual(pendingOpen.timelock_expiration, undefined, 'Not timelocked');
76
- strictEqual(pendingOpen.transaction_id, channelOpen.transaction_id, 'Tx id');
77
- strictEqual(pendingOpen.transaction_vout, channelOpen.transaction_vout, 'V');
78
-
79
- await generate({count: confirmationCount});
80
-
81
- await getChannels({lnd, id: channelOpen.transaction_id});
82
-
83
- const channelClose = await closeChannel({
84
- lnd,
85
- is_force_close: true,
86
- transaction_id: channelOpen.transaction_id,
87
- transaction_vout: channelOpen.transaction_vout,
88
- });
89
-
90
- await getPendingChannels({lnd, id: channelOpen.transaction_id});
91
-
92
- const [waitClose] = (await getPendingChannels({lnd})).pending_channels;
93
-
94
- strictEqual(waitClose.local_balance, 986530, 'Original balance');
95
- strictEqual(waitClose.pending_balance, 986530, 'Waiting on balance');
96
-
97
- strictEqual(waitClose.capacity, 1000000, 'Got channel closing capacity');
98
- strictEqual(waitClose.is_active, false, 'Not active yet');
99
- strictEqual(waitClose.is_closing, true, 'Channel is closing');
100
- strictEqual(waitClose.is_opening, false, 'Not opening channel');
101
- strictEqual(waitClose.local_reserve, 10000, 'Local reserve of closing');
102
- strictEqual(waitClose.partner_public_key, target.id, 'Pkey');
103
- strictEqual(waitClose.pending_payments, undefined, 'No pending payments');
104
- strictEqual(waitClose.received, 0, 'Nothing received');
105
- strictEqual(waitClose.recovered_tokens, undefined, 'Funds not recovered');
106
- strictEqual(waitClose.remote_reserve, 10000, 'Remote reserve');
107
- strictEqual(waitClose.sent, 0, 'No sent tokens');
108
- strictEqual(waitClose.timelock_expiration, undefined, 'No timelock data');
109
- strictEqual(waitClose.transaction_fee, null, 'No tx fee data');
110
- strictEqual(waitClose.transaction_id, channelOpen.transaction_id, 'Txid');
111
- strictEqual(waitClose.transaction_vout, channelOpen.transaction_vout, 'Vt');
112
- strictEqual(waitClose.transaction_weight, null, 'No funding tx weight data');
113
-
114
- if (!!waitClose.remote_balance) {
115
- strictEqual(waitClose.remote_balance, giftTokens, 'Remote tokens');
116
- }
117
-
118
- strictEqual(waitClose.sent, 0, 'Channel never sent funds');
119
- strictEqual(waitClose.timelock_expiration, undefined, 'Not timelocked yet');
120
- strictEqual(waitClose.transaction_id, channelOpen.transaction_id, 'txid');
121
- strictEqual(waitClose.transaction_vout, channelOpen.transaction_vout, 'out');
122
-
123
- // Wait for generation to be over
124
- await asyncRetry({interval, times}, async () => {
125
- // Generate to confirm the tx
126
- await generate({});
127
-
128
- const [forceClose] = (await getPendingChannels({lnd})).pending_channels;
129
-
130
- if (!forceClose.close_transaction_id) {
131
- throw new Error('ExpectedCloseTransactionId');
132
- }
133
-
134
- if (!forceClose.timelock_expiration) {
135
- throw new Error('ExpectedTimelockExpiration');
136
- }
137
-
138
- return;
139
- });
140
-
141
- const [forceClose] = (await getPendingChannels({lnd})).pending_channels;
142
-
143
- strictEqual(forceClose.local_balance, 986530, 'Original balance');
144
- strictEqual(forceClose.pending_balance, 986860, 'Waiting on balance');
145
-
146
- strictEqual(forceClose.capacity, 1000000, 'Got channel close capacity');
147
- strictEqual(forceClose.close_transaction_id, channelClose.transaction_id);
148
- strictEqual(forceClose.is_active, false, 'Not active anymore');
149
- strictEqual(forceClose.is_closing, true, 'Channel is force closing');
150
- strictEqual(forceClose.is_timelocked, true, 'Force close funds timelocked');
151
- strictEqual(forceClose.is_opening, false, 'Channel is not opening');
152
- strictEqual(forceClose.partner_public_key, target.id, 'pk');
153
- strictEqual(forceClose.received, 0, 'No receive amount');
154
- strictEqual(forceClose.recovered_tokens, undefined, 'No recovered amount');
155
-
156
- // LND 0.14.5 and below do not support remote balance info
157
- if (!!forceClose.remote_balance) {
158
- strictEqual(forceClose.remote_balance, giftTokens, 'Got gift remote');
159
- } else {
160
- strictEqual(forceClose.remote_balance, 0, 'No remote balance');
161
- }
162
-
163
- strictEqual(forceClose.sent, 0, 'No sent amount');
164
- strictEqual(!!forceClose.timelock_blocks, true, 'Timelock blocks set');
165
- strictEqual(forceClose.timelock_expiration, startHeight + 265, 'Funds lock');
166
- strictEqual(forceClose.transaction_id, channelOpen.transaction_id, 'Txid');
167
- strictEqual(forceClose.transaction_vout, channelOpen.transaction_vout, 'V');
168
-
169
- await kill({});
170
-
171
- return;
172
- });
@@ -1,86 +0,0 @@
1
- const {deepStrictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {setupChannel} = require('ln-docker-daemons');
5
- const {spawnLightningCluster} = require('ln-docker-daemons');
6
-
7
- const {addPeer} = require('./../../');
8
- const {createInvoice} = require('./../../');
9
- const {deleteForwardingReputations} = require('./../../');
10
- const {getHeight} = require('./../../');
11
- const {getInvoice} = require('./../../');
12
- const {getPayment} = require('./../../');
13
- const {getPendingPayments} = require('./../../');
14
- const {payViaPaymentRequest} = require('./../../');
15
- const {subscribeToForwardRequests} = require('./../../');
16
- const {subscribeToPayViaRequest} = require('./../../');
17
- const waitForRoute = require('./../macros/wait_for_route');
18
-
19
- const size = 3;
20
- const tokens = 100;
21
-
22
- // Getting pending payments should list out payments in flight
23
- test(`Get pending payments`, async () => {
24
- const {kill, nodes} = await spawnLightningCluster({size});
25
-
26
- const [{generate, lnd}, target, remote] = nodes;
27
-
28
- const channel = await setupChannel({generate, lnd, to: target});
29
-
30
- await remote.generate({count: 100});
31
-
32
- const remoteChan = await setupChannel({
33
- lnd: target.lnd,
34
- generate: target.generate,
35
- to: remote,
36
- });
37
-
38
- await addPeer({lnd, public_key: remote.id, socket: remote.socket});
39
-
40
- const {routes} = await waitForRoute({lnd, tokens, destination: remote.id});
41
-
42
- let height;
43
- const [route] = routes;
44
-
45
- {
46
- const invoice = await createInvoice({tokens, lnd: remote.lnd});
47
-
48
- const sub = subscribeToForwardRequests({lnd: target.lnd});
49
-
50
- sub.once('forward_request', async forward => {
51
- const {pending} = await getPayment({lnd, id: invoice.id});
52
-
53
- const {next, payments} = await getPendingPayments({lnd});
54
-
55
- deepStrictEqual(next, undefined, 'No more pages');
56
- deepStrictEqual(payments.length, 1, 'A single pending payment');
57
-
58
- const [payment] = payments;
59
-
60
- deepStrictEqual(payment.destination, remote.id, 'Paying to remote');
61
- deepStrictEqual(payment.index, 1, 'First payment');
62
- deepStrictEqual(payment.request, invoice.request, 'Paying request');
63
- deepStrictEqual(payment.confirmed_at, undefined, 'Not a payment');
64
- deepStrictEqual(!!payment.created_at, true, 'Has created date');
65
- deepStrictEqual(payment.fee, undefined, 'No fee yet');
66
- deepStrictEqual(payment.fee_mtokens, undefined, 'No fee mtokens');
67
- deepStrictEqual(payment.hops.length, 1, 'Going through hops');
68
- deepStrictEqual(payment.id, invoice.id, 'Paying to the same hash');
69
- deepStrictEqual(payment.is_confirmed, false, 'Payment is pending');
70
- deepStrictEqual(payment.is_outgoing, true, 'Outgoing payment type');
71
- deepStrictEqual(payment.mtokens, invoice.mtokens, 'Paying invoiced');
72
- deepStrictEqual(payment.safe_fee, undefined, 'No fee paid yet');
73
- deepStrictEqual(payment.safe_tokens, invoice.tokens, 'Paying tokens');
74
- deepStrictEqual(payment.secret, undefined, 'Preimage not yet known');
75
- deepStrictEqual(payment.tokens, invoice.tokens, 'Paying invoiced');
76
-
77
- return forward.accept();
78
- });
79
-
80
- await payViaPaymentRequest({lnd, request: invoice.request});
81
- }
82
-
83
- await kill({});
84
-
85
- return;
86
- });