ln-service 59.4.1 → 59.6.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 +15 -0
  2. package/README.md +57 -8
  3. package/package.json +9 -4
  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 -66
  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 -298
  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 -150
  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,75 +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 {createInvoice} = require('./../../');
8
- const {decodePaymentRequest} = require('./../../');
9
- const {getIdentity} = require('./../../');
10
- const {getWalletInfo} = require('./../../');
11
-
12
- const interval = 50;
13
- const times = 4000;
14
-
15
- const tests = [
16
- {
17
- description: "Test invoice",
18
- expected: {
19
- cltv_delta: 99,
20
- description: 'Read: Global Cryptocurrency Regulation',
21
- id: '7426ba0604c3f8682c7016b44673f85c5bd9da2fa6c1080810cf53ae320c9863',
22
- mtokens: '150000',
23
- secret: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
24
- safe_tokens: 150,
25
- tokens: 150,
26
- },
27
- },
28
- ];
29
-
30
- tests.forEach(({description, expected}) => {
31
- return test(description, async () => {
32
- const [{generate, kill, lnd}] = (await spawnLightningCluster({})).nodes;
33
-
34
- await asyncRetry({interval, times}, async () => {
35
- const wallet = await getWalletInfo({lnd});
36
-
37
- await generate({});
38
-
39
- if (!wallet.is_synced_to_chain) {
40
- throw new Error('NotSyncedToChain');
41
- }
42
- });
43
-
44
- try {
45
- const {request} = await createInvoice({
46
- lnd,
47
- cltv_delta: expected.cltv_delta,
48
- description: expected.description,
49
- secret: expected.secret,
50
- tokens: expected.tokens,
51
- });
52
-
53
- const decoded = await decodePaymentRequest({lnd, request});
54
- const identity = (await getIdentity({lnd})).public_key;
55
-
56
- strictEqual(decoded.chain_addresses, expected.chain_addresses, 'Addr');
57
- strictEqual(decoded.cltv_delta, expected.cltv_delta, 'Decode cltv');
58
- strictEqual(!!decoded.created_at, true, 'Created at date');
59
- strictEqual(decoded.description, expected.description, 'Decode desc');
60
- strictEqual(decoded.description_hash, expected.description_hash, 'Hash');
61
- strictEqual(decoded.destination, identity, 'Got public key');
62
- strictEqual(!!decoded.expires_at, true, 'Expiration date decoded');
63
- strictEqual(decoded.id, expected.id, 'Decoded payment hash');
64
- strictEqual(decoded.mtokens, expected.mtokens, 'Decode millitokens');
65
- strictEqual(decoded.safe_tokens, expected.safe_tokens, 'Safe amount');
66
- strictEqual(decoded.tokens, expected.tokens, 'Decode tokens amount');
67
- } catch (err) {
68
- strictEqual(err, null, 'Expected no error');
69
- }
70
-
71
- await kill({});
72
-
73
- return;
74
- });
75
- });
@@ -1,38 +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 {createInvoice} = require('./../../');
8
- const {deletePayment} = require('./../../');
9
- const {getPayments} = require('./../../');
10
- const {pay} = require('./../../');
11
-
12
- const size = 2;
13
- const tokens = 100;
14
-
15
- // Deleting a payment should delete the payment record
16
- test('Delete payment', async () => {
17
- const {kill, nodes} = await spawnLightningCluster({size});
18
-
19
- const [{generate, lnd}, target] = nodes;
20
-
21
- await setupChannel({generate, lnd, to: target});
22
-
23
- const invoice = await createInvoice({tokens, lnd: target.lnd});
24
-
25
- const paid = await pay({lnd, request: invoice.request});
26
-
27
- const priorLength = (await getPayments({lnd})).payments.length;
28
-
29
- await deletePayment({lnd, id: invoice.id});
30
-
31
- const wipedLength = (await getPayments({lnd})).payments.length;
32
-
33
- strictEqual(priorLength - wipedLength, [paid].length, 'Payment deleted');
34
-
35
- await kill({});
36
-
37
- return;
38
- });
@@ -1,42 +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 {createInvoice} = require('./../../');
9
- const {deletePayments} = require('./../../');
10
- const {getPayments} = require('./../../');
11
- const {pay} = require('./../../');
12
-
13
- const size = 2;
14
- const times = 1000;
15
- const tokens = 100;
16
-
17
- // Deleting payments should delete all payments
18
- test('Delete payments', async () => {
19
- const {kill, nodes} = await spawnLightningCluster({size});
20
-
21
- const [{generate, lnd}, target] = nodes;
22
-
23
- await setupChannel({generate, lnd, to: target});
24
-
25
- const invoice = await createInvoice({tokens, lnd: target.lnd});
26
-
27
- const paid = await asyncRetry({times}, async () => {
28
- return await pay({lnd, request: invoice.request});
29
- });
30
-
31
- const priorLength = (await getPayments({lnd})).payments.length;
32
-
33
- await deletePayments({lnd});
34
-
35
- const wipedLength = (await getPayments({lnd})).payments.length;
36
-
37
- strictEqual(priorLength - wipedLength, [paid].length, 'History deleted');
38
-
39
- await kill({});
40
-
41
- return;
42
- });
@@ -1,202 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const asyncEach = require('async/each');
5
- const asyncRetry = require('async/retry');
6
- const asyncTimeout = require('async/timeout');
7
- const {extractTransaction} = require('psbt');
8
- const {spawnLightningCluster} = require('ln-docker-daemons');
9
- const tinysecp = require('tiny-secp256k1');
10
-
11
- const {addPeer} = require('./../../');
12
- const {broadcastChainTransaction} = require('./../../');
13
- const {cancelPendingChannel} = require('./../../');
14
- const {deletePendingChannel} = require('./../../');
15
- const {fundPendingChannels} = require('./../../');
16
- const {fundPsbt} = require('./../../');
17
- const {getChainBalance} = require('./../../');
18
- const {getChannels} = require('./../../');
19
- const {getLockedUtxos} = require('./../../');
20
- const {getMasterPublicKeys} = require('./../../');
21
- const {getPendingChannels} = require('./../../');
22
- const {getWalletInfo} = require('./../../');
23
- const {openChannels} = require('./../../');
24
- const {signPsbt} = require('./../../');
25
- const {unlockUtxo} = require('./../../');
26
-
27
- const capacity = 1e6;
28
- const count = 100;
29
- const delay = n => new Promise(resolve => setTimeout(resolve, n));
30
- const description = 'description';
31
- const interval = 100;
32
- const race = promises => Promise.race(promises);
33
- const size = 3;
34
- const timeout = 1000 * 20;
35
- const times = 2000;
36
-
37
- // Forfeiting a pending channel should remove the pending channel
38
- test(`Forfeit pending channel`, async t => {
39
- const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
40
-
41
- const {kill, nodes} = await spawnLightningCluster({size});
42
-
43
- const [{generate, lnd}, target, remote] = nodes;
44
-
45
- await asyncRetry({interval, times}, async () => {
46
- const wallet = await getWalletInfo({lnd});
47
-
48
- await generate({});
49
-
50
- if (!wallet.is_synced_to_chain) {
51
- throw new Error('NotSyncedToChain');
52
- }
53
- });
54
-
55
- await generate({count});
56
-
57
- await asyncEach([target, remote], async node => {
58
- return await addPeer({lnd, public_key: node.id, socket: node.socket});
59
- });
60
-
61
- const channels = [{
62
- capacity,
63
- description,
64
- is_private: true,
65
- partner_public_key: target.id,
66
- }];
67
-
68
- // Propose a channel to target
69
- const proposeToTarget = await asyncRetry({interval: 1000, times}, cbk => {
70
- return asyncTimeout(openChannels, 1000 * 3)({
71
- channels,
72
- lnd,
73
- is_avoiding_broadcast: true,
74
- },
75
- async (err, res) => {
76
- await generate({});
77
-
78
- await asyncEach([target, remote], async node => {
79
- return await addPeer({lnd, public_key: node.id, socket: node.socket});
80
- });
81
-
82
- return cbk(err, res)
83
- });
84
- });
85
-
86
- // Setup funding for the target
87
- const fundTarget = await fundPsbt({lnd, outputs: proposeToTarget.pending});
88
-
89
- // Sign the funding to the target
90
- const signTarget = await signPsbt({lnd, psbt: fundTarget.psbt});
91
-
92
- // Fund the target channel that will get stuck
93
- await fundPendingChannels({
94
- lnd,
95
- channels: proposeToTarget.pending.map(n => n.id),
96
- funding: signTarget.psbt,
97
- });
98
-
99
- await asyncEach((await getLockedUtxos({lnd})).utxos, async utxo => {
100
- return await unlockUtxo({
101
- lnd,
102
- id: utxo.lock_id,
103
- transaction_id: utxo.transaction_id,
104
- transaction_vout: utxo.transaction_vout,
105
- });
106
- });
107
-
108
- // Propose a channel to remote
109
- const proposeToRemote = await asyncRetry({interval: 1000, times}, cbk => {
110
- return asyncTimeout(openChannels, 1000 * 3)({
111
- lnd,
112
- channels: [{
113
- capacity,
114
- description,
115
- is_private: true,
116
- partner_public_key: remote.id,
117
- }],
118
- is_avoiding_broadcast: true,
119
- },
120
- cbk);
121
- });
122
-
123
- // Setup funding for the remote, using the same inputs
124
- const fundRemote = await fundPsbt({
125
- lnd,
126
- inputs: fundTarget.inputs,
127
- outputs: proposeToRemote.pending
128
- });
129
-
130
- // Sign the funding to the target
131
- const signRemote = await signPsbt({lnd, psbt: fundRemote.psbt});
132
-
133
- // Fund the remote channel
134
- await fundPendingChannels({
135
- lnd,
136
- channels: proposeToRemote.pending.map(n => n.id),
137
- funding: signRemote.psbt,
138
- });
139
-
140
- await delay(2000);
141
-
142
- const {transaction} = extractTransaction({ecp, psbt: signRemote.psbt});
143
-
144
- await broadcastChainTransaction({lnd, transaction});
145
-
146
- await generate({});
147
-
148
- const channel = await asyncRetry({interval: 1000, times}, async () => {
149
- const [channel] = (await getChannels({lnd})).channels;
150
-
151
- // Exit early when the channel is created
152
- if (!!channel) {
153
- return channel;
154
- }
155
-
156
- await broadcastChainTransaction({lnd, transaction});
157
-
158
- await generate({});
159
-
160
- throw new Error('ExpectedNewChannelCreated');
161
- });
162
-
163
- const [pending] = (await getPendingChannels({lnd})).pending_channels;
164
-
165
- // Description is not supported in LND 0.16.4 or before
166
- if (!!pending.description) {
167
- deepEqual(pending.description, description, 'Got expected description');
168
- deepEqual(pending.is_private, true, 'Got pending private status');
169
- }
170
-
171
- const stuckTx = extractTransaction({ecp, psbt: signTarget.psbt});
172
-
173
- const [stuckPending] = proposeToTarget.pending;
174
-
175
- // Try to cancel the pending channel, it will fail
176
- try {
177
- await cancelPendingChannel({lnd, id: stuckPending.id});
178
- } catch (err) {
179
- const [code] = err;
180
-
181
- deepEqual(code, 503, 'Pending channel cannot be canceled');
182
- }
183
-
184
- try {
185
- await deletePendingChannel({
186
- lnd,
187
- confirmed_transaction: transaction,
188
- pending_transaction: stuckTx.transaction,
189
- pending_transaction_vout: pending.transaction_vout,
190
- });
191
-
192
- const [notPending] = (await getPendingChannels({lnd})).pending_channels;
193
-
194
- deepEqual(notPending, undefined, 'Conflicting pending deleted');
195
- } catch (err) {
196
- deepEqual(err, [501, 'DeletePendingChannelMethodNotSupported']);
197
- }
198
-
199
- await kill({});
200
-
201
- return;
202
- });
@@ -1,66 +0,0 @@
1
- const asyncRetry = require('async/retry');
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 {addPeer} = require('./../../');
9
- const {createInvoice} = require('./../../');
10
- const {decodePaymentRequest} = require('./../../');
11
- const {getWalletInfo} = require('./../../');
12
- const {parsePaymentRequest} = require('./../../');
13
- const {pay} = require('./../../');
14
-
15
- const count = 100;
16
- const expiry = () => new Date(Date.now() + (4 * 60 * 60 * 1000)).toISOString();
17
- const give = 500000;
18
- const interval = 100;
19
- const size = 3;
20
- const times = 10000;
21
- const tokens = 100;
22
-
23
- // Paying to an encrypted routes invoice should result in a payment
24
- test(`Create an invoice`, async () => {
25
- const {kill, nodes} = await spawnLightningCluster({size});
26
-
27
- const [{generate, lnd}, target, remote] = nodes;
28
-
29
- await generate({count});
30
-
31
- try {
32
- await setupChannel({generate, lnd, give_tokens: give, to: target});
33
-
34
- await addPeer({lnd, public_key: remote.id, socket: remote.socket});
35
-
36
- await setupChannel({
37
- generate: target.generate,
38
- give_tokens: give,
39
- lnd: target.lnd,
40
- to: remote,
41
- });
42
-
43
- await asyncRetry({interval, times}, async () => {
44
- await generate({});
45
-
46
- const invoice = await createInvoice({
47
- lnd,
48
- tokens,
49
- expires_at: expiry(),
50
- is_encrypting_routes: true,
51
- });
52
-
53
- await addPeer({lnd, public_key: remote.id, socket: remote.socket});
54
-
55
- await pay({lnd: remote.lnd, request: invoice.request});
56
- });
57
-
58
- await kill({});
59
- } catch (err) {
60
- await kill({});
61
-
62
- strictEqual(err, null, 'Expected no error in create invoice');
63
- }
64
-
65
- return;
66
- });
@@ -1,27 +0,0 @@
1
- const {deepStrictEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {spawnLightningCluster} = require('ln-docker-daemons');
5
-
6
- const {getAccessIds} = require('./../../');
7
- const {grantAccess} = require('./../../');
8
-
9
- const defaultId = '0';
10
- const id = '1';
11
-
12
- // Getting access ids should return root macaroon ids
13
- test(`Get access ids`, async () => {
14
- const {kill, nodes} = await spawnLightningCluster({});
15
-
16
- const [{lnd}] = nodes;
17
-
18
- await grantAccess({id, lnd, is_ok_to_create_chain_addresses: true});
19
-
20
- const {ids} = await getAccessIds({lnd});
21
-
22
- deepStrictEqual(ids, [defaultId, id], 'Got expected access ids');
23
-
24
- await kill({});
25
-
26
- return;
27
- });
@@ -1,40 +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 {getBackup} = require('./../../');
8
- const {verifyBackup} = require('./../../');
9
-
10
- const size = 2;
11
-
12
- // Getting a channel backup should return a channel backup
13
- test(`Get channel backup`, async () => {
14
- const {kill, nodes} = await spawnLightningCluster({size});
15
-
16
- const [{generate, lnd}, target] = nodes;
17
-
18
- const channel = await setupChannel({generate, lnd, to: target});
19
-
20
- const {backup} = await getBackup({
21
- lnd,
22
- transaction_id: channel.transaction_id,
23
- transaction_vout: channel.transaction_vout,
24
- });
25
-
26
- deepStrictEqual(!!backup, true, 'Channel backup is returned');
27
-
28
- const channelBackup = await verifyBackup({
29
- backup,
30
- lnd,
31
- transaction_id: channel.transaction_id,
32
- transaction_vout: channel.transaction_vout,
33
- });
34
-
35
- deepStrictEqual(channelBackup.is_valid, true, 'Is a valid backup');
36
-
37
- await kill({});
38
-
39
- return;
40
- });
@@ -1,38 +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 {getBackups} = require('./../../');
9
-
10
- const size = 2;
11
-
12
- // Getting a set of channel backups should return channel backups
13
- test(`Get channel backup`, async () => {
14
- await asyncRetry({}, async () => {
15
- const {kill, nodes} = await spawnLightningCluster({size});
16
-
17
- const [{generate, lnd}, target] = nodes;
18
-
19
- const channel = await setupChannel({generate, lnd, to: target});
20
-
21
- const {backup, channels} = await getBackups({lnd});
22
-
23
- strictEqual(!!backup, true, 'Multi-backup blob is returned');
24
- strictEqual(channels.length, [channel].length, 'Individualized backup');
25
-
26
- const [chanBackup] = channels;
27
-
28
- strictEqual(!!chanBackup.backup.length, true, 'Channel backup has blob');
29
- strictEqual(chanBackup.transaction_id, channel.transaction_id, 'Chan id');
30
- strictEqual(chanBackup.transaction_vout, channel.transaction_vout, 'Vout');
31
-
32
- await kill({});
33
-
34
- return;
35
- });
36
-
37
- return;
38
- });
@@ -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
- });