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,153 +0,0 @@
1
- const {deepStrictEqual} = 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 {setupChannel} = require('ln-docker-daemons');
7
- const {spawnLightningCluster} = require('ln-docker-daemons');
8
-
9
- const {cancelHodlInvoice} = require('./../../');
10
- const {createInvoice} = require('./../../');
11
- const {decodePaymentRequest} = require('./../../');
12
- const {getInvoice} = require('./../../');
13
- const {getRouteToDestination} = require('./../../');
14
- const {parsePaymentRequest} = require('./../../');
15
- const {payViaRoutes} = require('./../../');
16
-
17
- const all = promise => Promise.all(promise);
18
- const interval = 10;
19
- const {isArray} = Array;
20
- const message = {type: '85805', value: '01'};
21
- const size = 3;
22
- const times = 3000;
23
- const tokens = 1000;
24
-
25
- // Getting a route to a destination should return a route to the destination
26
- test(`Get a route to a destination`, async () => {
27
- await asyncRetry({}, async () => {
28
- const {kill, nodes} = await spawnLightningCluster({size});
29
-
30
- const [control, target, remote] = nodes;
31
-
32
- await control.generate({count: 200});
33
-
34
- await setupChannel({
35
- generate: control.generate,
36
- lnd: control.lnd,
37
- to: target,
38
- });
39
-
40
- await setupChannel({
41
- generate: target.generate,
42
- give_tokens: 1e5,
43
- is_private: true,
44
- lnd: target.lnd,
45
- to: remote,
46
- });
47
-
48
- const invoice = await asyncRetry({interval, times}, async () => {
49
- const invoice = await createInvoice({
50
- tokens,
51
- is_including_private_channels: true,
52
- lnd: remote.lnd,
53
- });
54
-
55
- const {routes} = parsePaymentRequest({request: invoice.request});
56
-
57
- // Wait for private routes to get picked up
58
- if (!routes) {
59
- await cancelHodlInvoice({id: invoice.id, lnd: remote.lnd});
60
-
61
- throw new Error('ExpectedRouteForInvoice');
62
- }
63
-
64
- return invoice;
65
- });
66
-
67
- const parsed = parsePaymentRequest({request: invoice.request});
68
-
69
- await asyncRetry({interval, times}, async () => {
70
- const {route} = await getRouteToDestination({
71
- destination: parsed.destination,
72
- features: parsed.features,
73
- lnd: control.lnd,
74
- payment: parsed.payment,
75
- routes: parsed.routes,
76
- mtokens: parsed.mtokens,
77
- total_mtokens: parsed.mtokens,
78
- });
79
-
80
- const paid = await payViaRoutes({
81
- id: parsed.id,
82
- lnd: control.lnd,
83
- routes: [route],
84
- });
85
-
86
- strictEqual(invoice.secret, paid.secret, 'Paid multi-hop private route');
87
- });
88
-
89
- const inv = await createInvoice({tokens, lnd: target.lnd});
90
-
91
- const invDetails = await decodePaymentRequest({
92
- lnd: control.lnd,
93
- request: inv.request,
94
- });
95
-
96
- const controlToTarget = await getRouteToDestination({
97
- destination: target.id,
98
- features: invDetails.features,
99
- lnd: control.lnd,
100
- messages: [message],
101
- payment: invDetails.payment,
102
- tokens: invDetails.tokens / [control, remote].length,
103
- total_mtokens: invDetails.mtokens,
104
- });
105
-
106
- const remoteToTarget = await getRouteToDestination({
107
- destination: target.id,
108
- features: invDetails.features,
109
- lnd: remote.lnd,
110
- messages: [message],
111
- payment: invDetails.payment,
112
- tokens: invDetails.tokens / [control, remote].length,
113
- total_mtokens: invDetails.mtokens,
114
- });
115
-
116
- try {
117
- const [controlPay, remotePay] = await all([
118
- payViaRoutes({
119
- id: invDetails.id,
120
- lnd: control.lnd,
121
- routes: [controlToTarget.route],
122
- }),
123
- payViaRoutes({
124
- id: invDetails.id,
125
- lnd: remote.lnd,
126
- routes: [remoteToTarget.route],
127
- }),
128
- ]);
129
-
130
- strictEqual(controlPay.secret, inv.secret, 'Control paid for secret');
131
- strictEqual(remotePay.secret, inv.secret, 'Remote paid for secret');
132
-
133
- const {payments} = await getInvoice({
134
- id: invDetails.id,
135
- lnd: target.lnd,
136
- });
137
-
138
- const [payment1, payment2] = payments;
139
-
140
- const [message1] = payment1.messages;
141
- const [message2] = payment2.messages;
142
-
143
- deepStrictEqual(message1, message, 'Target received message');
144
- deepStrictEqual(message2, message, 'Target received both messages');
145
- } catch (err) {
146
- strictEqual(err, null, 'Unexpected error paying invoice');
147
- }
148
-
149
- await kill({});
150
- });
151
-
152
- return;
153
- });
@@ -1,78 +0,0 @@
1
- const {deepStrictEqual} = 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 {getSettlementStatus} = require('./../../');
10
- const {pay} = require('./../../');
11
-
12
- const fakeChannelId = '1x1x1';
13
- const interval = 100;
14
- const size = 2;
15
- const times = 2000;
16
- const tokens = 100;
17
-
18
- // Get the settlement status of an HTLC
19
- test(`Get settlement status`, async () => {
20
- // LND 0.15.5 and below do not support settlement status lookups
21
- {
22
- const {kill, nodes} = await spawnLightningCluster({});
23
-
24
- const [{lnd}] = nodes;
25
-
26
- try {
27
- await getSettlementStatus({
28
- lnd,
29
- channel: fakeChannelId,
30
- payment: Number(),
31
- });
32
-
33
- await kill({});
34
- } catch (err) {
35
- const [code, message] = err;
36
-
37
- if (code !== 404) {
38
- equal(code, 501, 'Method unsupported');
39
- equal(message, 'LookupHtlcResolutionMethodUnsupported', 'Unsupported');
40
-
41
- await kill({});
42
-
43
- return;
44
- }
45
- }
46
- }
47
-
48
- const {kill, nodes} = await spawnLightningCluster({
49
- size,
50
- lnd_configuration: ['--store-final-htlc-resolutions'],
51
- });
52
-
53
- const [{generate, lnd}, target] = nodes;
54
-
55
- try {
56
- const channel = await setupChannel({generate, lnd, to: target});
57
-
58
- const {request} = await createInvoice({tokens, lnd: target.lnd});
59
-
60
- const payment = await pay({lnd, request});
61
-
62
- const settlement = await asyncRetry({interval, times}, async () => {
63
- return await getSettlementStatus({
64
- lnd: target.lnd,
65
- channel: channel.id,
66
- payment: Number(),
67
- });
68
- });
69
-
70
- deepStrictEqual(settlement, {is_onchain: false, is_settled: true}, 'Stat');
71
- } catch (err) {
72
- deepStrictEqual(err, null, 'Expected no error');
73
- }
74
-
75
- await kill({});
76
-
77
- return;
78
- });
@@ -1,49 +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 {getUtxos} = require('./../../');
10
-
11
- const format = 'p2wpkh';
12
- const times = 300;
13
- const tokens = 1e8;
14
-
15
- // Getting utxos should list out the utxos
16
- test(`Get utxos`, async () => {
17
- const {kill, nodes} = await spawnLightningCluster({});
18
-
19
- const [{generate, lnd}] = nodes;
20
-
21
- // Generate some funds for LND
22
- await asyncRetry({times}, async () => {
23
- await generate({});
24
-
25
- const wallet = await getChainBalance({lnd});
26
-
27
- if (!wallet.chain_balance) {
28
- throw new Error('ExpectedChainBalanceForNode');
29
- }
30
- });
31
-
32
- const {utxos} = await getUtxos({lnd});
33
-
34
- strictEqual(!!utxos.length, true, 'Unspent output returned');
35
-
36
- const [utxo] = utxos;
37
-
38
- strictEqual(!!utxo.address, true, 'UTXO address returned');
39
- strictEqual(utxo.address_format, format, 'UTXO address format returned');
40
- strictEqual(utxo.confirmation_count, 100, 'Confirmation count returned');
41
- strictEqual(!!utxo.output_script, true, 'Output script returned');
42
- strictEqual(!!utxo.tokens, true, 'UTXO amount returned');
43
- strictEqual(!!utxo.transaction_id, true, 'UTXO transaction id returned');
44
- strictEqual(utxo.transaction_vout !== undefined, true, 'UTXO vout returned');
45
-
46
- await kill({});
47
-
48
- return;
49
- });
@@ -1,55 +0,0 @@
1
- const {deepStrictEqual} = require('node:assert').strict;
2
- const {ok} = require('node:assert').strict;
3
- const {strictEqual} = 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 {getWalletInfo} = require('./../../');
10
-
11
- const initHeight = 1;
12
- const interval = 10;
13
- const pubKeyHexLength = Buffer.alloc(33).toString('hex').length;
14
- const regtestChainId = '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f';
15
- const times = 1000;
16
- const walletInfoType = 'wallet';
17
-
18
- // Getting the wallet info should return info about the wallet
19
- test(`Get wallet info`, async () => {
20
- const {kill, nodes} = await spawnLightningCluster({});
21
-
22
- const [{generate, lnd}] = nodes;
23
-
24
- try {
25
- const result = await asyncRetry({interval, times}, async () => {
26
- await generate({});
27
-
28
- const result = await getWalletInfo({lnd});
29
-
30
- if (result.current_block_height >= initHeight) {
31
- return result;
32
- }
33
-
34
- throw new Error('ExpectedBlockHeightAtInitHeight');
35
- });
36
-
37
- strictEqual(result.active_channels_count, 0, 'Expected channels count');
38
- strictEqual(!!result.alias, true, 'Expected alias');
39
- deepStrictEqual(result.chains, [regtestChainId], 'Got chains');
40
- strictEqual(!!result.current_block_hash, true, 'Expected best block hash');
41
- ok(result.current_block_height >= initHeight, 'Expected block height');
42
- strictEqual(!!result.latest_block_at, true, 'Last block time');
43
- strictEqual(result.peers_count, 0, 'Expected wallet peers count');
44
- strictEqual(result.pending_channels_count, 0, 'Expected pending channels');
45
- strictEqual(result.public_key.length, pubKeyHexLength, 'Expected key');
46
- deepStrictEqual(result.uris.length, 1, 'Expected node URI');
47
- strictEqual(!!result.version, true, 'Expected version');
48
- } catch (err) {
49
- strictEqual(err, null, 'Expected no error');
50
- }
51
-
52
- await kill({});
53
-
54
- return;
55
- });
@@ -1,69 +0,0 @@
1
- const {deepStrictEqual} = require('node:assert').strict;
2
- const {rejects} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const {spawnLightningCluster} = require('ln-docker-daemons');
6
-
7
- const {createChainAddress} = require('./../../');
8
- const {grantAccess} = require('./../../');
9
-
10
- const format = 'np2wpkh';
11
-
12
- // Granting access should result in access granted
13
- test(`Get access credentials`, async () => {
14
- const [{lnd, kill, rpc}] = (await spawnLightningCluster({})).nodes;
15
-
16
- await grantAccess({lnd, is_ok_to_create_chain_addresses: true});
17
-
18
- const makeChainAddresses = await grantAccess({
19
- lnd,
20
- is_ok_to_create_chain_addresses: true,
21
- permissions: ['address:read'],
22
- });
23
-
24
- const permissions = ['address:write', 'address:read'];
25
-
26
- deepStrictEqual(makeChainAddresses.permissions, permissions, 'Permissions');
27
-
28
- const canPay = rpc({
29
- macaroon: (await grantAccess({lnd, is_ok_to_pay: true})).macaroon,
30
- });
31
-
32
- const makeAddress = rpc({macaroon: makeChainAddresses.macaroon});
33
-
34
- await rejects(
35
- grantAccess({lnd: makeAddress.lnd, is_ok_to_create_chain_addresses: true}),
36
- [403, 'PermissionDeniedToBakeMacaroon'],
37
- 'Cannot grant access using a non-generate macaroon'
38
- );
39
-
40
- await rejects(
41
- createChainAddress({format, lnd: canPay.lnd}),
42
- [503, 'UnexpectedErrorCreatingAddress'],
43
- 'Cannot create a chain address using an offchain pay macaroon'
44
- );
45
-
46
- const {address} = await createChainAddress({format, lnd: makeAddress.lnd});
47
-
48
- deepStrictEqual(!!address, true, 'Can make address with proper credential');
49
-
50
- const createChainAddressCredential = await grantAccess({
51
- lnd,
52
- methods: ['createChainAddress'],
53
- });
54
-
55
- const authenticatedToCreateAddress = rpc({
56
- macaroon: createChainAddressCredential.macaroon,
57
- });
58
-
59
- const created = await createChainAddress({
60
- format,
61
- lnd: authenticatedToCreateAddress.lnd,
62
- });
63
-
64
- deepStrictEqual(!!created, true, 'Can make address with URI credential');
65
-
66
- await kill({});
67
-
68
- return;
69
- });
@@ -1,93 +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 {createChainAddress} = require('./../../');
9
- const {getChainBalance} = require('./../../');
10
- const {getChannel} = require('./../../');
11
- const {getChannels} = require('./../../');
12
- const {openChannel} = require('./../../');
13
-
14
- const baseFee = '1337';
15
- const channelCapacityTokens = 1e6;
16
- const count = 100;
17
- const defaultBaseFee = '1000';
18
- const defaultFee = 1e3;
19
- const defaultVout = 0;
20
- const description = 'description';
21
- const feeRate = 420;
22
- const giftTokens = 1000;
23
- const interval = 250;
24
- const size = 2;
25
- const times = 1000;
26
- const txIdHexLength = 32 * 2;
27
-
28
- // Opening a channel should open a channel
29
- test(`Open channel`, async () => {
30
- const {kill, nodes} = await spawnLightningCluster({size});
31
-
32
- const [{generate, id, lnd}, target] = nodes;
33
-
34
- const {address} = await createChainAddress({lnd});
35
-
36
- await generate({count});
37
-
38
- const channelOpen = await asyncRetry({interval, times}, async () => {
39
- await addPeer({lnd, public_key: target.id, socket: target.socket});
40
-
41
- return await openChannel({
42
- description,
43
- lnd,
44
- base_fee_mtokens: baseFee,
45
- chain_fee_tokens_per_vbyte: defaultFee,
46
- cooperative_close_address: address,
47
- fee_rate: feeRate,
48
- give_tokens: giftTokens,
49
- local_tokens: channelCapacityTokens,
50
- partner_public_key: target.id,
51
- socket: target.socket,
52
- });
53
- });
54
-
55
- strictEqual(channelOpen.transaction_id.length, txIdHexLength, 'Channel id');
56
- strictEqual(channelOpen.transaction_vout, defaultVout, 'Channel tx output');
57
-
58
- await asyncRetry({interval, times}, async () => {
59
- await generate({});
60
-
61
- const {channels} = await getChannels({lnd});
62
-
63
- const [channel] = channels;
64
-
65
- if (!channel) {
66
- throw new Error('ExpectedChannelOpened');
67
- }
68
-
69
- if (!!channel.description) {
70
- strictEqual(channel.description, description, 'Description set');
71
- }
72
-
73
- const {policies} = await getChannel({lnd, id: channel.id});
74
-
75
- const policy = policies.find(n => n.public_key === id);
76
-
77
- if (!policy.base_fee_mtokens) {
78
- throw new Error('ExpectedKnownPolicyBaseFeeMtokens');
79
- }
80
-
81
- // LND 0.15.5 and below do not support setting fees on open
82
- if (policy.base_fee_mtokens === defaultBaseFee) {
83
- return;
84
- }
85
-
86
- strictEqual(policy.base_fee_mtokens, baseFee, 'Base fee is set');
87
- strictEqual(policy.fee_rate, feeRate, 'Fee rate is set');
88
- });
89
-
90
- await kill({});
91
-
92
- return;
93
- });
@@ -1,92 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const asyncRetry = require('async/retry');
5
- const {componentsOfTransaction} = require('@alexbosworth/blockchain');
6
- const {spawnLightningCluster} = require('ln-docker-daemons');
7
-
8
- const {addPeer} = require('./../../');
9
- const {getChainTransactions} = require('./../../');
10
- const {getChannels} = require('./../../');
11
- const {getUtxos} = require('./../../');
12
- const {openChannel} = require('./../../');
13
-
14
- const count = 101;
15
- const description = 'description';
16
- const interval = 250;
17
- const size = 2;
18
- const times = 1000;
19
-
20
- // Opening a channel with max funds should open a channel using all funds
21
- test(`Open channel max`, async () => {
22
- const {kill, nodes} = await spawnLightningCluster({size});
23
-
24
- const [{generate, id, lnd}, target] = nodes;
25
-
26
- await generate({count});
27
-
28
- // Find the second UTXO, it would not normally be chosen by coin selection
29
- const utxo = await asyncRetry({interval, times}, async () => {
30
- const {utxos} = await getUtxos({lnd});
31
-
32
- const [, outpoint] = utxos;
33
-
34
- if (!outpoint) {
35
- throw new Error('ExpectedMultipleUtxos');
36
- }
37
-
38
- return {
39
- transaction_id: outpoint.transaction_id,
40
- transaction_vout: outpoint.transaction_vout,
41
- };
42
- });
43
-
44
- // Open the channel using coin selection
45
- const channelOpen = await asyncRetry({interval, times}, async () => {
46
- await addPeer({lnd, public_key: target.id, socket: target.socket});
47
-
48
- return await openChannel({
49
- description,
50
- lnd,
51
- inputs: [utxo],
52
- is_max_funding: true,
53
- partner_public_key: target.id,
54
- socket: target.socket,
55
- });
56
- });
57
-
58
- const {transactions} = await getChainTransactions({lnd});
59
-
60
- const tx = transactions.find(n => n.id === channelOpen.transaction_id);
61
-
62
- const components = componentsOfTransaction({transaction: tx.transaction});
63
-
64
- const [input] = components.inputs;
65
-
66
- // Wait for the channel to activate
67
- await asyncRetry({interval, times}, async () => {
68
- await generate({});
69
-
70
- const {channels} = await getChannels({lnd});
71
-
72
- const [channel] = channels;
73
-
74
- if (!channel) {
75
- throw new Error('ExpectedMaxChannelOpened');
76
- }
77
-
78
- // LND 0.16.4 and below do not support max funding for channel opens
79
- if (channel.description !== description) {
80
- return;
81
- }
82
-
83
- // Make sure the channel spent the correct transaction output
84
- equal(input.id, utxo.transaction_id, 'Channel open spent down right UTXO');
85
-
86
- return;
87
- });
88
-
89
- await kill({});
90
-
91
- return;
92
- });