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,36 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {spawnLightningCluster} = require('ln-docker-daemons');
5
-
6
- const {getChainBalance} = require('./../../');
7
-
8
- const count = 100;
9
- const emptyChainBalance = 0;
10
- const tokens = 5000000000;
11
-
12
- // Getting chain balance should result in a chain balance
13
- test(`Get the chain balance`, async ({end, equal}) => {
14
- const {kill, nodes} = await spawnLightningCluster({});
15
-
16
- const [{generate, lnd}] = nodes;
17
-
18
- // The initial chain balance should be zero
19
- {
20
- const result = await getChainBalance({lnd});
21
-
22
- strictEqual(result.chain_balance, emptyChainBalance, 'Got chain balance');
23
- }
24
-
25
- // Generate some funds for LND
26
- await generate({count});
27
-
28
- // Check that the balance is updated
29
- const postDeposit = await getChainBalance({lnd});
30
-
31
- strictEqual(postDeposit.chain_balance >= tokens, true, 'Got funds');
32
-
33
- await kill({});
34
-
35
- return;
36
- });
@@ -1,63 +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 {createChainAddress} = require('./../../');
8
- const {getChainBalance} = require('./../../');
9
- const {getChainFeeEstimate} = require('./../../');
10
-
11
- const expectedFee = 4625;
12
- const expectedFeeRate = 25;
13
- const format = 'np2wpkh';
14
- const size = 2;
15
- const times = 200;
16
- const tokens = 1e6;
17
-
18
- // Getting a chain fee estimate should return an estimate of the chain fee
19
- test(`Get chain fee estimate`, async () => {
20
- const {kill, nodes} = await spawnLightningCluster({size});
21
-
22
- const [control, {lnd}] = nodes;
23
-
24
- const address1 = (await createChainAddress({lnd})).address;
25
- const address2 = (await createChainAddress({format, lnd})).address;
26
-
27
- // Generate coins for the node
28
- await asyncRetry({times}, async () => {
29
- if (!(await getChainBalance({lnd: control.lnd})).chain_balance) {
30
- await control.generate({});
31
-
32
- throw new Error('ExpectedChainBalance');
33
- }
34
- });
35
-
36
- const estimate = await getChainFeeEstimate({
37
- lnd: control.lnd,
38
- send_to: [
39
- {address: address1, tokens: tokens / [address1, address2].length},
40
- {address: address2, tokens: tokens / [address1, address2].length},
41
- ],
42
- });
43
-
44
- // LND 0.15.4 and below uses P2WPKH as change
45
- if (estimate.fee === 8650) {
46
- strictEqual(estimate.fee, 8650, 'Total fee is estimated');
47
- } else if (estimate.fee === 9250) { // LND 0.18.5 and below fee rate
48
- strictEqual(estimate.fee, 9250, 'Total fee is estimated');
49
- } else {
50
- strictEqual(estimate.fee, expectedFee, 'Total fee is estimated');
51
- }
52
-
53
- // LND 0.18.5 and below fee rate is higher
54
- if (estimate.tokens_per_vbyte === 50) {
55
- strictEqual(estimate.tokens_per_vbyte, 50, 'Got fee/vbyte');
56
- } else {
57
- strictEqual(estimate.tokens_per_vbyte, expectedFeeRate, 'Got fee/vbyte');
58
- }
59
-
60
- await kill({});
61
-
62
- return;
63
- });
@@ -1,83 +0,0 @@
1
- const {equal} = 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 {getChainTransactions} = require('./../../');
8
- const {getWalletInfo} = require('./../../');
9
-
10
- const count = 100;
11
- const defaultFee = 1e3;
12
- const format = 'np2wpkh';
13
- const times = 300;
14
-
15
- // Getting chain transactions should list out the chain transactions
16
- test(`Get chain transactions`, async () => {
17
- const {kill, nodes} = await spawnLightningCluster({});
18
-
19
- const [{generate, lnd}] = nodes;
20
-
21
- // Generate some funds for LND
22
- await generate({count});
23
-
24
- await asyncRetry({interval: 10, times: 6000}, async () => {
25
- const wallet = await getWalletInfo({lnd});
26
-
27
- if (!wallet.is_synced_to_chain) {
28
- throw new Error('ExpectedWalletSyncedToChain');
29
- }
30
-
31
- await generate({});
32
-
33
- if (wallet.current_block_height < count + 1) {
34
- throw new Error('ExpectedFullySyncedToChain');
35
- }
36
- });
37
-
38
- // Wait for generation to be over
39
- const transactions = await asyncRetry({times}, async () => {
40
- const {transactions} = await getChainTransactions({lnd});
41
-
42
- const [tx] = transactions;
43
-
44
- if (!tx.is_confirmed) {
45
- throw new Error('ExpectedTransactionConfirmed');
46
- }
47
-
48
- return transactions;
49
- });
50
-
51
- equal(transactions.length > 1, true, 'Transaction found');
52
-
53
- const [tx] = transactions;
54
-
55
- equal(!!tx.block_id, true, 'Transaction has block id');
56
- equal(!!tx.confirmation_count, true, 'Transaction confirm count');
57
- equal(!!tx.confirmation_height, true, 'Transaction confirm height');
58
- equal(!!tx.created_at, true, 'Transaction record create time');
59
- equal(tx.description, undefined, 'No tx description');
60
- equal(tx.fee, undefined, 'No transaction fee');
61
- equal(!!tx.id, true, 'Transaction id');
62
- equal(tx.is_confirmed, true, 'Transaction is confirmed');
63
- equal(tx.is_outgoing, false, 'Transaction is incoming');
64
- equal(tx.output_addresses.length, 1, 'Tx output address');
65
- equal(tx.tokens, 5000000000, 'Got coinbase reward tokens');
66
- equal(!!tx.transaction, true, 'Got transaction hex');
67
-
68
- const onlyBefore = await getChainTransactions({lnd, before: 2});
69
-
70
- equal(onlyBefore.transactions.length < 100, true, 'Got before txs');
71
-
72
- const between = await getChainTransactions({
73
- lnd,
74
- after: tx.confirmation_height - 1,
75
- before: tx.confirmation_height + 1,
76
- });
77
-
78
- equal(between.transactions.length, [tx].length, 'One transaction');
79
-
80
- await kill({});
81
-
82
- return;
83
- });
@@ -1,64 +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 {getChannel} = require('./../../');
8
- const {getChannels} = require('./../../');
9
-
10
- const {ceil} = Math;
11
- const size = 2;
12
-
13
- // Getting a channel should return channel details from the channel graph
14
- test(`Get channel`, async () => {
15
- const {kill, nodes} = await spawnLightningCluster({size});
16
-
17
- const [{generate, lnd}, target] = nodes;
18
-
19
- await setupChannel({generate, lnd, to: target});
20
-
21
- const [channel] = (await getChannels({lnd})).channels;
22
-
23
- const details = await getChannel({lnd, id: channel.id});
24
-
25
- strictEqual(details.capacity, channel.capacity, 'Capacity');
26
- strictEqual(details.policies.length, size, 'Policies for both nodes');
27
-
28
- details.policies.forEach(policy => {
29
- strictEqual(policy.base_fee_mtokens, '1000', 'Base fee mtokens');
30
- strictEqual([40, 80].includes(policy.cltv_delta), true, 'CLTV policy');
31
- strictEqual(policy.fee_rate, 1, 'Fee rate');
32
- strictEqual(policy.is_disabled, false, 'Disabled flag');
33
- strictEqual(policy.max_htlc_mtokens, `${ceil(details.capacity*0.99)}000`);
34
- strictEqual(!!policy.min_htlc_mtokens, true, 'Min HTLC value');
35
- strictEqual(policy.public_key.length, 66, 'Policy public key');
36
- strictEqual(Date.now()-new Date(policy.updated_at) < 1e5, true, 'Updated');
37
-
38
- return;
39
- });
40
-
41
- strictEqual(details.transaction_id, channel.transaction_id, 'Funding tx id');
42
- strictEqual(details.transaction_vout, channel.transaction_vout, 'Tx vout');
43
-
44
- strictEqual(Date.now()-new Date(details.updated_at) < 1e5, true, 'Updated');
45
-
46
- try {
47
- const details = await getChannel({
48
- lnd,
49
- transaction_id: channel.transaction_id,
50
- transaction_vout: channel.transaction_vout,
51
- });
52
- } catch (err) {
53
- const [code] = err;
54
-
55
- // On LND 0.18.0 and below a transaction id and vout is not supported
56
- if (code !== 404) {
57
- throw err;
58
- }
59
- }
60
-
61
- await kill({});
62
-
63
- return;
64
- });
@@ -1,23 +0,0 @@
1
- const {strictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {spawnLightningCluster} = require('ln-docker-daemons');
5
-
6
- const {getChannelBalance} = require('./../../');
7
-
8
- const emptyBalance = 0;
9
-
10
- // Getting channel balance should result in a channel balance
11
- test(`Get the channel balance`, async () => {
12
- const {kill, nodes} = await spawnLightningCluster({});
13
-
14
- const [{lnd}] = nodes;
15
-
16
- const result = await getChannelBalance({lnd});
17
-
18
- strictEqual(result.channel_balance, emptyBalance, 'Valid channel balance');
19
-
20
- await kill({});
21
-
22
- return;
23
- });
@@ -1,84 +0,0 @@
1
- const {ok} = require('node:assert').strict;
2
- const {strictEqual} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const {setupChannel} = require('ln-docker-daemons');
6
- const {spawnLightningCluster} = require('ln-docker-daemons');
7
-
8
- const {getChannels} = require('./../../');
9
- const {getWalletInfo} = require('./../../');
10
-
11
- const anchorFeatureBit = 23;
12
- const giveTokens = 1e5;
13
- const remoteCsv = 40;
14
- const size = 2;
15
-
16
- // Getting channels should return the list of channels
17
- test(`Get channels`, async () => {
18
- const {kill, nodes} = await spawnLightningCluster({size});
19
-
20
- const [{generate, lnd}, target] = nodes;
21
-
22
- const chan = await setupChannel({
23
- generate,
24
- lnd,
25
- give_tokens: giveTokens,
26
- partner_csv_delay: remoteCsv,
27
- to: target,
28
- });
29
-
30
- const [channel] = (await getChannels({lnd})).channels;
31
- const {features} = await getWalletInfo({lnd});
32
- const [targetChan] = (await getChannels({lnd: target.lnd})).channels;
33
-
34
- strictEqual(targetChan.is_partner_initiated, true, 'Self-init channel');
35
-
36
- if (!!channel.local_given) {
37
- strictEqual(channel.local_given, giveTokens, 'Push tokens are reflected');
38
- strictEqual(channel.remote_given, Number(), 'Push tokens are reflected');
39
- }
40
-
41
- if (!!channel.remote_given) {
42
- strictEqual(channel.local_given, Number(), 'Push tokens are reflected');
43
- strictEqual(channel.remote_given, giveTokens, 'Push tokens are reflected');
44
- }
45
-
46
- if (channel.remote_csv === remoteCsv) {
47
- strictEqual(channel.local_csv, 144, 'Local CSV is returned');
48
- ok(channel.local_dust >= 354, 'Local dust limit is returned');
49
- strictEqual(channel.local_max_htlcs, 483, 'Local max htlcs are returned');
50
- strictEqual(channel.local_max_pending_mtokens, '990000000', 'Local max');
51
- strictEqual(channel.local_min_htlc_mtokens, '1000', 'Local min mtokens');
52
- strictEqual(channel.remote_csv, remoteCsv, 'Remote CSV is returned');
53
- ok(channel.remote_dust >= 354, 'Remote dust limit is returned');
54
- strictEqual(channel.remote_max_htlcs, 483, 'Remote max htlcs returned');
55
- strictEqual(channel.remote_max_pending_mtokens, '990000000', 'Remote');
56
- strictEqual(channel.remote_min_htlc_mtokens, '1', 'Remote min HTLC');
57
- }
58
-
59
- strictEqual(channel.capacity, 1000000, 'Channel capacity');
60
- strictEqual(channel.commit_transaction_fee, 2810, 'Commit fee');
61
- strictEqual(channel.commit_transaction_weight, 1116, 'Commit weight');
62
- strictEqual(channel.id, chan.id, 'Channel id returned');
63
- strictEqual(channel.is_active, true, 'Channel active');
64
- strictEqual(channel.is_closing, false, 'Channel not closing');
65
- strictEqual(channel.is_opening, false, 'Channel not opening');
66
- strictEqual(channel.is_partner_initiated, false, 'Partner made channel');
67
- strictEqual(channel.is_private, false, 'Channel not private');
68
- strictEqual(channel.local_balance, 896530, 'Local balance');
69
- strictEqual(channel.local_reserve, 10000, 'Local reserve');
70
- strictEqual(channel.partner_public_key, target.id, 'Pubkey');
71
- strictEqual(channel.pending_payments.length, 0, 'No pending payments');
72
- strictEqual(channel.received, 0, 'Channel received');
73
- strictEqual(channel.remote_balance, 100000, 'Channel remote balance');
74
- strictEqual(channel.remote_reserve, 10000, 'Remote reserve amount');
75
- strictEqual(channel.sent, 0, 'Channel sent');
76
- strictEqual(channel.transaction_id, chan.transaction_id, 'Chan funding tx');
77
- strictEqual(channel.transaction_vout, 0, 'Channel transactin vout');
78
- strictEqual(channel.type, 'anchor', 'Channel type is returned');
79
- strictEqual(channel.unsettled_balance, 0, 'Channel unsettled balance');
80
-
81
- await kill({});
82
-
83
- return;
84
- });
@@ -1,275 +0,0 @@
1
- const {exit} = require('node:process');
2
- const {strictEqual} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const asyncRetry = require('async/retry');
6
- const {setupChannel} = require('ln-docker-daemons');
7
- const {spawnLightningCluster} = require('ln-docker-daemons');
8
-
9
- const {closeChannel} = require('./../../');
10
- const {createHodlInvoice} = require('./../../');
11
- const {getClosedChannels} = require('./../../');
12
- const {getWalletInfo} = require('./../../');
13
- const {settleHodlInvoice} = require('./../../');
14
- const {subscribeToInvoice} = require('./../../');
15
- const {subscribeToPayViaRequest} = require('./../../');
16
-
17
- const defaultFee = 1e3;
18
- const interval = 125;
19
- const maxChanTokens = Math.pow(2, 24) - 1;
20
- const size = 2;
21
- const times = 1000;
22
-
23
- // Getting closed channels should return closed channels
24
- test(`Get closed channels`, async t => {
25
- const {kill, nodes} = await spawnLightningCluster({size});
26
-
27
- t.after(() => exit());
28
-
29
- const [control, target] = nodes;
30
-
31
- const {generate, lnd} = control;
32
-
33
- const channelOpen = await setupChannel({
34
- generate,
35
- lnd,
36
- capacity: maxChanTokens,
37
- partner_csv_delay: 20,
38
- to: target,
39
- });
40
-
41
- const closing = await closeChannel({
42
- lnd,
43
- tokens_per_vbyte: defaultFee,
44
- transaction_id: channelOpen.transaction_id,
45
- transaction_vout: channelOpen.transaction_vout,
46
- });
47
-
48
- const {features} = await getWalletInfo({lnd});
49
-
50
- const isAnchors = !!features.find(n => n.bit === 23);
51
-
52
- // Wait for channel to close
53
- await asyncRetry({interval, times}, async () => {
54
- await generate({});
55
-
56
- const {channels} = await getClosedChannels({lnd});
57
-
58
- if (!channels.length) {
59
- throw new Error('ExpectedClosedChannel');
60
- }
61
- });
62
-
63
- const {channels} = await getClosedChannels({lnd});
64
-
65
- const [channel] = channels;
66
-
67
- strictEqual(channels.length, [channelOpen].length, 'Channel close listed');
68
-
69
- const spend = maxChanTokens - channel.final_local_balance;
70
-
71
- // LND 0.11.1 and below do not use anchors
72
- if (isAnchors) {
73
- strictEqual([53345, 28473, 2810].includes(spend), true, 'Final');
74
- } else {
75
- strictEqual(spend, 9050, 'Final');
76
- }
77
-
78
- strictEqual(channel.capacity, maxChanTokens, 'Channel capacity reflected');
79
- strictEqual(!!channel.close_confirm_height, true, 'Channel close height');
80
- strictEqual(channel.close_transaction_id, closing.transaction_id, 'Close');
81
- strictEqual(channel.final_time_locked_balance, 0, 'Final locked balance');
82
- strictEqual(!!channel.id, true, 'Channel id');
83
- strictEqual(channel.is_breach_close, false, 'Not breach close');
84
- strictEqual(channel.is_cooperative_close, true, 'Is cooperative close');
85
- strictEqual(channel.is_funding_cancel, false, 'Not funding cancel');
86
- strictEqual(channel.is_local_force_close, false, 'Not local force close');
87
- strictEqual(channel.is_partner_closed, false, 'Partner did not close');
88
- strictEqual(channel.is_partner_initiated, false, 'Partner did not open');
89
- strictEqual(channel.is_remote_force_close, false, 'Not remote force close');
90
- strictEqual(channel.partner_public_key, target.id, 'Pubkey');
91
- strictEqual(channel.transaction_id, channelOpen.transaction_id, 'Channel');
92
- strictEqual(channel.transaction_vout, channelOpen.transaction_vout, 'Vout');
93
-
94
- // Setup a force close to show force close channel output
95
- const toForceClose = await setupChannel({
96
- generate,
97
- lnd,
98
- capacity: 7e5,
99
- give_tokens: 3e5,
100
- partner_csv_delay: 20,
101
- to: target,
102
- });
103
-
104
- const cancelInvoice = await createHodlInvoice({
105
- lnd,
106
- cltv_delta: 20,
107
- tokens: 1e5,
108
- });
109
-
110
- const settleInvoice = await createHodlInvoice({
111
- lnd,
112
- cltv_delta: 144,
113
- tokens: 1e5,
114
- });
115
-
116
- const subCancelInvoice = subscribeToInvoice({lnd, id: cancelInvoice.id});
117
- const subSettleInvoice = subscribeToInvoice({lnd, id: settleInvoice.id});
118
-
119
- const cancelInvoiceUpdates = [];
120
- const settleInvoiceUpdates = [];
121
-
122
- subCancelInvoice.on('invoice_updated', n => cancelInvoiceUpdates.push(n));
123
- subSettleInvoice.on('invoice_updated', n => settleInvoiceUpdates.push(n));
124
-
125
- // Kick off a payment to the cancel invoice
126
- const payToCancel = subscribeToPayViaRequest({
127
- lnd: target.lnd,
128
- request: cancelInvoice.request,
129
- });
130
-
131
- // Kick off a payment to the settle invoice
132
- const payToSettle = subscribeToPayViaRequest({
133
- lnd: target.lnd,
134
- request: settleInvoice.request,
135
- });
136
-
137
- await asyncRetry({interval, times}, async () => {
138
- if (!cancelInvoiceUpdates.filter(n => !!n.is_held).length) {
139
- throw new Error('WaitingForLockToCancelInvoice');
140
- }
141
-
142
- if (!settleInvoiceUpdates.filter(n => !!n.is_held).length) {
143
- throw new Error('WaitingForLockToSettleInvoice');
144
- }
145
-
146
- // Push the held HTLCs to chain
147
- await closeChannel({
148
- lnd: target.lnd,
149
- is_force_close: true,
150
- transaction_id: toForceClose.transaction_id,
151
- transaction_vout: toForceClose.transaction_vout,
152
- });
153
- });
154
-
155
- // Use the preimage to sweep the settle invoice on chain
156
- await settleHodlInvoice({lnd, secret: settleInvoice.secret});
157
-
158
- // LND 0.12.0 requires a delay before sweeps start
159
- const deadChans = await asyncRetry({interval: 1000, times: 99}, async () => {
160
- const {channels} = await getClosedChannels({lnd});
161
-
162
- if (channels.length === [toForceClose, channelOpen].length) {
163
- return channels;
164
- }
165
-
166
- await target.generate({});
167
- await generate({});
168
-
169
- throw new Error('WaitingForForceClose');
170
- });
171
-
172
- const forced = deadChans.find(n => !!n.is_remote_force_close);
173
-
174
- strictEqual(forced.capacity, 7e5, 'Got force close capacity');
175
- strictEqual(!!forced.close_balance_spent_by, true, 'Got a spend id');
176
- strictEqual(forced.close_balance_vout !== undefined, true, 'Got a vout');
177
- strictEqual(!!forced.close_confirm_height !== undefined, true, 'Height');
178
- strictEqual(forced.close_payments.length, 2, '2 pending payments');
179
- strictEqual(!!forced.close_transaction_id, true, 'Got closed tx id');
180
- strictEqual(!!forced.final_local_balance, true, 'Got final balance');
181
- strictEqual(forced.final_time_locked_balance, 0, 'Got timelock balance');
182
- strictEqual(forced.id, toForceClose.id, 'Got closed channel id');
183
- strictEqual(forced.is_breach_close, false, 'Not a breach');
184
- strictEqual(forced.is_cooperative_close, false, 'Not a coop close');
185
- strictEqual(forced.is_funding_cancel, false, 'Not a cancel');
186
- strictEqual(forced.is_local_force_close, false, 'Not a local force close');
187
- strictEqual(forced.is_partner_closed, true, 'The remote closed');
188
- strictEqual(forced.is_partner_initiated, false, 'Local initiated');
189
- strictEqual(forced.is_remote_force_close, true, 'Remote force closed');
190
- strictEqual(forced.partner_public_key, target.id, 'Got remote public key');
191
- strictEqual(forced.transaction_id, toForceClose.transaction_id, 'Got txid');
192
- strictEqual(forced.transaction_vout, toForceClose.transaction_vout, 'Vout');
193
-
194
- const cancelHtlc = forced.close_payments.find(n => !n.is_paid);
195
-
196
- strictEqual(cancelHtlc.is_outgoing, false, 'HTLC is incoming');
197
- strictEqual(cancelHtlc.is_paid, false, 'HTLC is not settled');
198
- strictEqual(cancelHtlc.is_pending, false, 'HTLC cannot be settled');
199
- strictEqual(cancelHtlc.is_refunded, false, 'HTLC has not been refunded');
200
- strictEqual(cancelHtlc.spent_by, undefined, 'HTLC has no sweep tx');
201
- strictEqual(cancelHtlc.tokens, 1e5, 'HTLC has invoice value');
202
- strictEqual(!!cancelHtlc.transaction_id, true, 'HTLC has tx id');
203
- strictEqual(cancelHtlc.transaction_vout !== undefined, true, 'HTLC vout');
204
-
205
- const settleHtlc = forced.close_payments.find(n => !!n.is_paid);
206
-
207
- strictEqual(settleHtlc.is_outgoing, false, 'Settle is incoming');
208
- strictEqual(settleHtlc.is_paid, true, 'Settle is paid');
209
- strictEqual(settleHtlc.is_pending, false, 'Already settled');
210
- strictEqual(settleHtlc.is_refunded, false, 'No refund available');
211
- strictEqual(!!settleHtlc.spent_by, true, 'Swept with preimage tx');
212
- strictEqual(settleHtlc.tokens, 1e5, 'Settled with invoice value');
213
- strictEqual(!!settleHtlc.transaction_id, true, 'Output tx id');
214
- strictEqual(settleHtlc.transaction_vout !== undefined, true, 'Output vout');
215
-
216
- const alsoDead = await asyncRetry({interval: 20, times: 7000}, async () => {
217
- const {channels} = await getClosedChannels({lnd: target.lnd});
218
-
219
- if (channels.length === [toForceClose, channelOpen].length) {
220
- return channels;
221
- }
222
-
223
- await target.generate({});
224
-
225
- throw new Error('WaitingForTargetForceClose');
226
- });
227
-
228
- const forceClosed = alsoDead.find(n => !!n.is_local_force_close);
229
-
230
- strictEqual(forceClosed.capacity, 7e5, 'Target capacity reflected');
231
- strictEqual(!!forceClosed.close_balance_spent_by, true, 'Target spent by');
232
- strictEqual(forceClosed.close_balance_vout !== undefined, true, 'Balance');
233
- strictEqual(!!forceClosed.close_confirm_height, true, 'Has confirm height');
234
- strictEqual(!!forceClosed.close_payments.length, true, 'Has close payments');
235
- strictEqual(!!forceClosed.close_transaction_id, true, 'Has close id');
236
- strictEqual(forceClosed.final_local_balance, 1e5, 'Has local balance');
237
- strictEqual(forceClosed.final_time_locked_balance, 3e5, 'Timelock balance');
238
- strictEqual(forceClosed.id, toForceClose.id, 'Has channel id');
239
- strictEqual(forceClosed.is_breach_close, false, 'Not breach close');
240
- strictEqual(forceClosed.is_cooperative_close, false, 'Not coop close');
241
- strictEqual(forceClosed.is_funding_cancel, false, 'Not funding cancel');
242
- strictEqual(forceClosed.is_local_force_close, true, 'Locally forced closed');
243
- strictEqual(forceClosed.is_partner_closed, false, 'Not remote closed');
244
- strictEqual(forceClosed.is_partner_initiated, true, 'Remote create channel');
245
- strictEqual(forceClosed.is_remote_force_close, false, 'Remote not force');
246
- strictEqual(forceClosed.partner_public_key, control.id, 'Got peer key');
247
- strictEqual(forceClosed.transaction_id, toForceClose.transaction_id, 'Tx');
248
- strictEqual(forceClosed.transaction_vout, toForceClose.transaction_vout);
249
-
250
- const forcePay = forceClosed.close_payments.find(n => !!n.is_paid);
251
-
252
- strictEqual(forcePay.is_outgoing, true, 'Payment was outgoing');
253
- strictEqual(forcePay.is_paid, true, 'Payment was sent');
254
- strictEqual(forcePay.is_pending, false, 'Payment is settled');
255
- strictEqual(forcePay.is_refunded, false, 'Payment completed successfully');
256
- strictEqual(!!forcePay.spent_by, true, 'Payment was swept with preimage');
257
- strictEqual(forcePay.tokens, 1e5, 'Payment tokens amount');
258
- strictEqual(!!forcePay.transaction_id, true, 'Got payment transaction id');
259
- strictEqual(forcePay.transaction_vout !== undefined, true, 'Got vout');
260
-
261
- const refundedHtlc = forceClosed.close_payments.find(n => !!n.is_refunded);
262
-
263
- strictEqual(refundedHtlc.is_outgoing, true, 'Payment was outgoing');
264
- strictEqual(refundedHtlc.is_paid, false, 'Payment was not paid');
265
- strictEqual(refundedHtlc.is_pending, false, 'Payment is resolved back');
266
- strictEqual(refundedHtlc.is_refunded, true, 'Payment refunded successfully');
267
- strictEqual(!!refundedHtlc.spent_by, true, 'Payment was swept');
268
- strictEqual(refundedHtlc.tokens, 1e5, 'Payment refund tokens amount');
269
- strictEqual(!!refundedHtlc.transaction_id, true, 'Got refund tx id');
270
- strictEqual(refundedHtlc.transaction_vout !== undefined, true, 'Got vout');
271
-
272
- await kill({});
273
-
274
- return;
275
- });
@@ -1,35 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const {equal} = require('node:assert').strict;
3
- const {ok} = require('node:assert').strict;
4
- const test = require('node:test');
5
-
6
- const asyncRetry = require('async/retry');
7
- const {spawnLightningCluster} = require('ln-docker-daemons');
8
-
9
- const {getConfiguration} = require('./../../');
10
- const {getWalletInfo} = require('./../../');
11
-
12
- // Getting the configuration info should return info about the config
13
- test(`Get configuration info`, async () => {
14
- const {kill, nodes} = await spawnLightningCluster({});
15
-
16
- const [{lnd}] = nodes;
17
-
18
- try {
19
- const {log, options} = await getConfiguration({lnd});
20
-
21
- ok(!!log.length, 'Got the log lines');
22
-
23
- const color = options.find(n => n.type === 'color').value.toLowerCase();
24
-
25
- equal(color, (await getWalletInfo({lnd})).color, 'Got color from config');
26
-
27
- await kill({});
28
- } catch (err) {
29
- await kill({});
30
-
31
- deepEqual(err, [501, 'GetDebugConfigurationInfoNotSupported'], '404');
32
- }
33
-
34
- return;
35
- });