ln-service 56.7.0 → 56.8.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 (144) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -0
  3. package/package.json +10 -11
  4. package/test/autopilotrpc-integration/test_autopilot.js +30 -16
  5. package/test/chainrpc-integration/test_get_block.js +14 -11
  6. package/test/chainrpc-integration/test_get_height.js +10 -4
  7. package/test/chainrpc-integration/test_subscribe_to_blocks.js +10 -9
  8. package/test/chainrpc-integration/test_subscribe_to_chain_address.js +11 -9
  9. package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +9 -8
  10. package/test/integration/test_add_peer.js +12 -6
  11. package/test/integration/test_cancel_pending_channel.js +9 -12
  12. package/test/integration/test_close_channel.js +12 -11
  13. package/test/integration/test_create_chain_address.js +5 -3
  14. package/test/integration/test_create_invoice.js +19 -15
  15. package/test/integration/test_decode_payment_request.js +19 -16
  16. package/test/integration/test_delete_payment.js +11 -30
  17. package/test/integration/test_delete_payments.js +8 -8
  18. package/test/integration/test_delete_pending_channel.js +13 -27
  19. package/test/integration/test_get_access_ids.js +7 -15
  20. package/test/integration/test_get_backup.js +12 -14
  21. package/test/integration/test_get_backups.js +11 -9
  22. package/test/integration/test_get_chain_balance.js +8 -8
  23. package/test/integration/test_get_chain_fee_estimate.js +8 -6
  24. package/test/integration/test_get_chain_transactions.js +22 -21
  25. package/test/integration/test_get_channel.js +19 -17
  26. package/test/integration/test_get_channel_balance.js +6 -4
  27. package/test/integration/test_get_channels.js +42 -39
  28. package/test/integration/test_get_closed_channels.js +95 -114
  29. package/test/integration/test_get_failed_payments.js +43 -42
  30. package/test/integration/test_get_fee_rates.js +13 -11
  31. package/test/integration/test_get_forwards.js +27 -24
  32. package/test/integration/test_get_invoice.js +31 -24
  33. package/test/integration/test_get_invoices.js +18 -15
  34. package/test/integration/test_get_methods.js +13 -16
  35. package/test/integration/test_get_network_centrality.js +15 -13
  36. package/test/integration/test_get_network_graph.js +36 -23
  37. package/test/integration/test_get_network_info.js +13 -11
  38. package/test/integration/test_get_node.js +27 -21
  39. package/test/integration/test_get_payments.js +20 -18
  40. package/test/integration/test_get_peers.js +16 -14
  41. package/test/integration/test_get_pending_coop.js +49 -39
  42. package/test/integration/test_get_pending_force.js +67 -90
  43. package/test/integration/test_get_pending_payments.js +23 -24
  44. package/test/integration/test_get_route_to_destination.js +15 -15
  45. package/test/integration/test_get_settlement_status.js +13 -9
  46. package/test/integration/test_get_utxos.js +13 -11
  47. package/test/integration/test_get_wallet_info.js +20 -16
  48. package/test/integration/test_grant_access.js +20 -23
  49. package/test/integration/test_open_channel.js +10 -8
  50. package/test/integration/test_open_channels.js +11 -10
  51. package/test/integration/test_pay.js +18 -27
  52. package/test/integration/test_pay_private_invoice.js +11 -24
  53. package/test/integration/test_payment_errors.js +10 -11
  54. package/test/integration/test_propose_channel.js +70 -105
  55. package/test/integration/test_push_funds.js +8 -10
  56. package/test/integration/test_rebalance.js +44 -32
  57. package/test/integration/test_recover_funds_from_channel.js +13 -11
  58. package/test/integration/test_recover_funds_from_channels.js +13 -11
  59. package/test/integration/test_remove_peer.js +8 -6
  60. package/test/integration/test_restrict_macaroon.js +8 -5
  61. package/test/integration/test_revoke_access.js +19 -24
  62. package/test/integration/test_send_message_to_peer.js +11 -6
  63. package/test/integration/test_send_to_chain_address.js +13 -12
  64. package/test/integration/test_send_to_chain_addresses.js +10 -8
  65. package/test/integration/test_sign_message.js +6 -4
  66. package/test/integration/test_stop_daemon.js +7 -4
  67. package/test/integration/test_subscribe_to_backups.js +7 -5
  68. package/test/integration/test_subscribe_to_channels.js +10 -21
  69. package/test/integration/test_subscribe_to_graph.js +17 -9
  70. package/test/integration/test_subscribe_to_invoices.js +10 -8
  71. package/test/integration/test_subscribe_to_open_requests.js +13 -12
  72. package/test/integration/test_subscribe_to_peer_messages.js +8 -5
  73. package/test/integration/test_subscribe_to_peers.js +7 -6
  74. package/test/integration/test_subscribe_to_rpc_requests.js +202 -191
  75. package/test/integration/test_subscribe_to_transactions.js +6 -4
  76. package/test/integration/test_trusted_funding.js +17 -11
  77. package/test/integration/test_update_routing_fees.js +8 -5
  78. package/test/integration/test_verify_access.js +8 -6
  79. package/test/integration/test_verify_backup.js +6 -6
  80. package/test/integration/test_verify_backups.js +6 -6
  81. package/test/integration/test_verify_message.js +5 -3
  82. package/test/invoicesrpc-integration/test_cancel_invoice.js +6 -5
  83. package/test/invoicesrpc-integration/test_get_sweep_transactions.js +6 -7
  84. package/test/invoicesrpc-integration/test_push_payment.js +7 -6
  85. package/test/invoicesrpc-integration/test_settle_invoice.js +10 -6
  86. package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +8 -7
  87. package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +8 -7
  88. package/test/peersrpc-integration/test_add_external_socket.js +7 -5
  89. package/test/peersrpc-integration/test_remove_external_socket.js +7 -5
  90. package/test/peersrpc-integration/test_update_alias.js +8 -6
  91. package/test/peersrpc-integration/test_update_color.js +8 -6
  92. package/test/routerrpc-integration/test_delete_forwarding_reputations.js +8 -6
  93. package/test/routerrpc-integration/test_disable_channel.js +6 -4
  94. package/test/routerrpc-integration/test_get_forwarding_confidence.js +7 -5
  95. package/test/routerrpc-integration/test_get_forwarding_reputations.js +12 -7
  96. package/test/routerrpc-integration/test_get_pathfinding_settings.js +7 -5
  97. package/test/routerrpc-integration/test_get_payment.js +10 -6
  98. package/test/routerrpc-integration/test_get_route_confidence.js +6 -4
  99. package/test/routerrpc-integration/test_get_route_through_hops.js +8 -7
  100. package/test/routerrpc-integration/test_is_destination_payable.js +48 -0
  101. package/test/routerrpc-integration/test_multipath_payment.js +8 -5
  102. package/test/routerrpc-integration/test_pay_via_payment_details.js +11 -9
  103. package/test/routerrpc-integration/test_pay_via_payment_request.js +11 -7
  104. package/test/routerrpc-integration/test_pay_via_routes.js +8 -11
  105. package/test/routerrpc-integration/test_probe_for_route.js +10 -7
  106. package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +10 -7
  107. package/test/routerrpc-integration/test_subscribe_to_forwards.js +23 -19
  108. package/test/routerrpc-integration/test_subscribe_to_past_payments.js +8 -6
  109. package/test/routerrpc-integration/test_subscribe_to_payments.js +18 -17
  110. package/test/routerrpc-integration/test_update_pathfinding_settings.js +8 -6
  111. package/test/runner.js +30 -0
  112. package/test/signerrpc-integration/test_begin_group_signing_session.js +8 -5
  113. package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +7 -4
  114. package/test/signerrpc-integration/test_sign_bytes.js +5 -3
  115. package/test/signerrpc-integration/test_sign_taproot.js +6 -4
  116. package/test/signerrpc-integration/test_sign_transaction.js +5 -3
  117. package/test/signerrpc-integration/test_verify_bytes_signature.js +5 -4
  118. package/test/tower_clientrpc-integration/test_connect_watchtower.js +7 -4
  119. package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +7 -4
  120. package/test/tower_serverrpc-integration/test_get_tower_server_info.js +6 -3
  121. package/test/versionrpc-integration/test_get_wallet_version.js +16 -12
  122. package/test/walletrpc-integration/test_broadcast_chain_transaction.js +5 -3
  123. package/test/walletrpc-integration/test_fund_psbt.js +5 -10
  124. package/test/walletrpc-integration/test_get_chain_addresses.js +9 -7
  125. package/test/walletrpc-integration/test_get_chain_fee_rate.js +5 -3
  126. package/test/walletrpc-integration/test_get_locked_utxos.js +8 -20
  127. package/test/walletrpc-integration/test_get_master_public_keys.js +9 -6
  128. package/test/walletrpc-integration/test_get_public_key.js +5 -3
  129. package/test/walletrpc-integration/test_lock_utxo.js +9 -5
  130. package/test/walletrpc-integration/test_partially_sign_psbt.js +7 -4
  131. package/test/walletrpc-integration/test_request_chain_fee_increase.js +8 -4
  132. package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +7 -4
  133. package/test/walletrpc-integration/test_sign_chain_address_message.js +6 -6
  134. package/test/walletrpc-integration/test_sign_psbt.js +6 -4
  135. package/test/walletrpc-integration/test_unlock_utxo.js +8 -4
  136. package/test/walletrpc-integration/test_update_chain_transaction.js +5 -3
  137. package/test/walletrpc-integration/test_verify_chain_address_message.js +6 -4
  138. package/test/extra-integration/test_change_password.js +0 -15
  139. package/test/extra-integration/test_get_wallet_status.js +0 -45
  140. package/test/extra-integration/test_no_macaroon.js +0 -20
  141. package/test/extra-integration/tower_clientrpc-integration/test_disconnect_watchtower.js +0 -51
  142. package/test/extra-integration/tower_clientrpc-integration/test_update_connected_watchtower.js +0 -76
  143. package/test/grpc-integration/test_authenticated_lnd_grpc.js +0 -40
  144. package/test/routers-integration/test_gateway_router.js +0 -87
@@ -1,21 +1,23 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
5
 
4
6
  const {getChannelBalance} = require('./../../');
5
7
 
6
8
  const emptyBalance = 0;
7
9
 
8
10
  // Getting channel balance should result in a channel balance
9
- test(`Get the channel balance`, async ({end, equal}) => {
11
+ test(`Get the channel balance`, async () => {
10
12
  const {kill, nodes} = await spawnLightningCluster({});
11
13
 
12
14
  const [{lnd}] = nodes;
13
15
 
14
16
  const result = await getChannelBalance({lnd});
15
17
 
16
- equal(result.channel_balance, emptyBalance, 'Valid channel balance');
18
+ strictEqual(result.channel_balance, emptyBalance, 'Valid channel balance');
17
19
 
18
20
  await kill({});
19
21
 
20
- return end();
22
+ return;
21
23
  });
@@ -1,9 +1,12 @@
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');
1
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
7
 
4
8
  const {getChannels} = require('./../../');
5
9
  const {getWalletInfo} = require('./../../');
6
- const {setupChannel} = require('./../macros');
7
10
 
8
11
  const anchorFeatureBit = 23;
9
12
  const giveTokens = 1e5;
@@ -11,7 +14,7 @@ const remoteCsv = 40;
11
14
  const size = 2;
12
15
 
13
16
  // Getting channels should return the list of channels
14
- test(`Get channels`, async ({end, equal, ok}) => {
17
+ test(`Get channels`, async () => {
15
18
  const {kill, nodes} = await spawnLightningCluster({size});
16
19
 
17
20
  const [{generate, lnd}, target] = nodes;
@@ -19,7 +22,7 @@ test(`Get channels`, async ({end, equal, ok}) => {
19
22
  const chan = await setupChannel({
20
23
  generate,
21
24
  lnd,
22
- give: giveTokens,
25
+ give_tokens: giveTokens,
23
26
  partner_csv_delay: remoteCsv,
24
27
  to: target,
25
28
  });
@@ -28,54 +31,54 @@ test(`Get channels`, async ({end, equal, ok}) => {
28
31
  const {features} = await getWalletInfo({lnd});
29
32
  const [targetChan] = (await getChannels({lnd: target.lnd})).channels;
30
33
 
31
- equal(targetChan.is_partner_initiated, true, 'Self-init channel');
34
+ strictEqual(targetChan.is_partner_initiated, true, 'Self-init channel');
32
35
 
33
36
  if (!!channel.local_given) {
34
- equal(channel.local_given, giveTokens, 'Push tokens are reflected');
35
- equal(channel.remote_given, Number(), 'Push tokens are reflected');
37
+ strictEqual(channel.local_given, giveTokens, 'Push tokens are reflected');
38
+ strictEqual(channel.remote_given, Number(), 'Push tokens are reflected');
36
39
  }
37
40
 
38
41
  if (!!channel.remote_given) {
39
- equal(channel.local_given, Number(), 'Push tokens are reflected');
40
- equal(channel.remote_given, giveTokens, 'Push tokens are reflected');
42
+ strictEqual(channel.local_given, Number(), 'Push tokens are reflected');
43
+ strictEqual(channel.remote_given, giveTokens, 'Push tokens are reflected');
41
44
  }
42
45
 
43
46
  if (channel.remote_csv === remoteCsv) {
44
- equal(channel.local_csv, 144, 'Local CSV is returned');
47
+ strictEqual(channel.local_csv, 144, 'Local CSV is returned');
45
48
  ok(channel.local_dust >= 354, 'Local dust limit is returned');
46
- equal(channel.local_max_htlcs, 483, 'Local max htlcs are returned');
47
- equal(channel.local_max_pending_mtokens, '990000000', 'Local max pending');
48
- equal(channel.local_min_htlc_mtokens, '1000', 'Local min HTLC mtokens');
49
- equal(channel.remote_csv, remoteCsv, 'Remote CSV 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');
50
53
  ok(channel.remote_dust >= 354, 'Remote dust limit is returned');
51
- equal(channel.remote_max_htlcs, 483, 'Remote max htlcs are returned');
52
- equal(channel.remote_max_pending_mtokens, '990000000', 'Remote pending');
53
- equal(channel.remote_min_htlc_mtokens, '1', 'Remote min HTLC mtokens');
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');
54
57
  }
55
58
 
56
- equal(channel.capacity, 1000000, 'Channel capacity');
57
- equal(channel.commit_transaction_fee, 2810, 'Commit fee');
58
- equal(channel.commit_transaction_weight, 1116, 'Commit weight');
59
- equal(channel.id, chan.id, 'Channel id returned');
60
- equal(channel.is_active, true, 'Channel active');
61
- equal(channel.is_closing, false, 'Channel not closing');
62
- equal(channel.is_opening, false, 'Channel not opening');
63
- equal(channel.is_partner_initiated, false, 'Partner initiated channel');
64
- equal(channel.is_private, false, 'Channel not private');
65
- equal(channel.local_balance, 896530, 'Local balance');
66
- equal(channel.local_reserve, 10000, 'Local reserve');
67
- equal(channel.partner_public_key, target.id, 'Pubkey');
68
- equal(channel.pending_payments.length, 0, 'No pending payments');
69
- equal(channel.received, 0, 'Channel received');
70
- equal(channel.remote_balance, 100000, 'Channel remote balance');
71
- equal(channel.remote_reserve, 10000, 'Remote reserve amount');
72
- equal(channel.sent, 0, 'Channel sent');
73
- equal(channel.transaction_id, chan.transaction_id, 'Chan funding tx id');
74
- equal(channel.transaction_vout, 0, 'Channel transactin vout');
75
- equal(channel.type, 'anchor', 'Channel type is returned');
76
- equal(channel.unsettled_balance, 0, 'Channel unsettled balance');
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');
77
80
 
78
81
  await kill({});
79
82
 
80
- return end();
83
+ return;
81
84
  });
@@ -1,28 +1,18 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const asyncRetry = require('async/retry');
5
+ const {setupChannel} = require('ln-docker-daemons');
2
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
7
 
5
8
  const {closeChannel} = require('./../../');
6
- const {createChainAddress} = require('./../../');
7
- const {createCluster} = require('./../macros');
8
9
  const {createHodlInvoice} = require('./../../');
9
- const {delay} = require('./../macros');
10
- const {payViaPaymentRequest} = require('./../../');
11
- const {getChainTransactions} = require('./../../');
12
10
  const {getClosedChannels} = require('./../../');
13
- const {getLockedUtxos} = require('./../../');
14
- const {getPendingChannels} = require('./../../');
15
- const {getSweepTransactions} = require('./../../');
16
- const {getUtxos} = require('./../../');
17
11
  const {getWalletInfo} = require('./../../');
18
- const {sendToChainAddress} = require('./../../');
19
12
  const {settleHodlInvoice} = require('./../../');
20
- const {setupChannel} = require('./../macros');
21
13
  const {subscribeToInvoice} = require('./../../');
22
14
  const {subscribeToPayViaRequest} = require('./../../');
23
15
 
24
- const all = promise => Promise.all(promise);
25
- const confirmationCount = 6;
26
16
  const defaultFee = 1e3;
27
17
  const interval = 125;
28
18
  const maxChanTokens = Math.pow(2, 24) - 1;
@@ -30,22 +20,13 @@ const size = 2;
30
20
  const times = 1000;
31
21
 
32
22
  // Getting closed channels should return closed channels
33
- test(`Get closed channels`, async ({end, equal}) => {
23
+ test(`Get closed channels`, async () => {
34
24
  const {kill, nodes} = await spawnLightningCluster({size});
35
25
 
36
26
  const [control, target] = nodes;
37
27
 
38
28
  const {generate, lnd} = control;
39
29
 
40
- try {
41
- await getLockedUtxos({lnd});
42
- } catch (err) {
43
- // Skip test on LND 0.12 due to sweep timing
44
- await kill({});
45
-
46
- return end();
47
- }
48
-
49
30
  const channelOpen = await setupChannel({
50
31
  generate,
51
32
  lnd,
@@ -80,39 +61,39 @@ test(`Get closed channels`, async ({end, equal}) => {
80
61
 
81
62
  const [channel] = channels;
82
63
 
83
- equal(channels.length, [channelOpen].length, 'Channel close listed');
64
+ strictEqual(channels.length, [channelOpen].length, 'Channel close listed');
84
65
 
85
66
  const spend = maxChanTokens - channel.final_local_balance;
86
67
 
87
68
  // LND 0.11.1 and below do not use anchors
88
69
  if (isAnchors) {
89
- equal([53345, 28473, 2810].includes(spend), true, 'Final');
70
+ strictEqual([53345, 28473, 2810].includes(spend), true, 'Final');
90
71
  } else {
91
- equal(spend, 9050, 'Final');
72
+ strictEqual(spend, 9050, 'Final');
92
73
  }
93
74
 
94
- equal(channel.capacity, maxChanTokens, 'Channel capacity reflected');
95
- equal(!!channel.close_confirm_height, true, 'Channel close height');
96
- equal(channel.close_transaction_id, closing.transaction_id, 'Close tx id');
97
- equal(channel.final_time_locked_balance, 0, 'Final locked balance');
98
- equal(!!channel.id, true, 'Channel id');
99
- equal(channel.is_breach_close, false, 'Not breach close');
100
- equal(channel.is_cooperative_close, true, 'Is cooperative close');
101
- equal(channel.is_funding_cancel, false, 'Not funding cancel');
102
- equal(channel.is_local_force_close, false, 'Not local force close');
103
- equal(channel.is_partner_closed, false, 'Partner did not close the chan');
104
- equal(channel.is_partner_initiated, false, 'Partner did not open channel');
105
- equal(channel.is_remote_force_close, false, 'Not remote force close');
106
- equal(channel.partner_public_key, target.id, 'Pubkey');
107
- equal(channel.transaction_id, channelOpen.transaction_id, 'Channel tx id');
108
- equal(channel.transaction_vout, channelOpen.transaction_vout, 'Chan vout');
75
+ strictEqual(channel.capacity, maxChanTokens, 'Channel capacity reflected');
76
+ strictEqual(!!channel.close_confirm_height, true, 'Channel close height');
77
+ strictEqual(channel.close_transaction_id, closing.transaction_id, 'Close');
78
+ strictEqual(channel.final_time_locked_balance, 0, 'Final locked balance');
79
+ strictEqual(!!channel.id, true, 'Channel id');
80
+ strictEqual(channel.is_breach_close, false, 'Not breach close');
81
+ strictEqual(channel.is_cooperative_close, true, 'Is cooperative close');
82
+ strictEqual(channel.is_funding_cancel, false, 'Not funding cancel');
83
+ strictEqual(channel.is_local_force_close, false, 'Not local force close');
84
+ strictEqual(channel.is_partner_closed, false, 'Partner did not close');
85
+ strictEqual(channel.is_partner_initiated, false, 'Partner did not open');
86
+ strictEqual(channel.is_remote_force_close, false, 'Not remote force close');
87
+ strictEqual(channel.partner_public_key, target.id, 'Pubkey');
88
+ strictEqual(channel.transaction_id, channelOpen.transaction_id, 'Channel');
89
+ strictEqual(channel.transaction_vout, channelOpen.transaction_vout, 'Vout');
109
90
 
110
91
  // Setup a force close to show force close channel output
111
92
  const toForceClose = await setupChannel({
112
93
  generate,
113
94
  lnd,
114
95
  capacity: 7e5,
115
- give: 3e5,
96
+ give_tokens: 3e5,
116
97
  partner_csv_delay: 20,
117
98
  to: target,
118
99
  });
@@ -187,47 +168,47 @@ test(`Get closed channels`, async ({end, equal}) => {
187
168
 
188
169
  const forced = deadChans.find(n => !!n.is_remote_force_close);
189
170
 
190
- equal(forced.capacity, 7e5, 'Got force close capacity');
191
- equal(!!forced.close_balance_spent_by, true, 'Got a spend id');
192
- equal(forced.close_balance_vout !== undefined, true, 'Got a spend vout');
193
- equal(!!forced.close_confirm_height !== undefined, true, 'Confirm height');
194
- equal(forced.close_payments.length, 2, '2 pending payments');
195
- equal(!!forced.close_transaction_id, true, 'Got closed tx id');
196
- equal(!!forced.final_local_balance, true, 'Got final balance');
197
- equal(forced.final_time_locked_balance, 0, 'Got timelock balance');
198
- equal(forced.id, toForceClose.id, 'Got closed channel id');
199
- equal(forced.is_breach_close, false, 'Not a breach');
200
- equal(forced.is_cooperative_close, false, 'Not a coop close');
201
- equal(forced.is_funding_cancel, false, 'Not a cancel');
202
- equal(forced.is_local_force_close, false, 'Not a local force close');
203
- equal(forced.is_partner_closed, true, 'The remote closed');
204
- equal(forced.is_partner_initiated, false, 'Local initiated');
205
- equal(forced.is_remote_force_close, true, 'Remote force closed');
206
- equal(forced.partner_public_key, target.id, 'Got remote public key');
207
- equal(forced.transaction_id, toForceClose.transaction_id, 'Got txid');
208
- equal(forced.transaction_vout, toForceClose.transaction_vout, 'Got vout');
171
+ strictEqual(forced.capacity, 7e5, 'Got force close capacity');
172
+ strictEqual(!!forced.close_balance_spent_by, true, 'Got a spend id');
173
+ strictEqual(forced.close_balance_vout !== undefined, true, 'Got a vout');
174
+ strictEqual(!!forced.close_confirm_height !== undefined, true, 'Height');
175
+ strictEqual(forced.close_payments.length, 2, '2 pending payments');
176
+ strictEqual(!!forced.close_transaction_id, true, 'Got closed tx id');
177
+ strictEqual(!!forced.final_local_balance, true, 'Got final balance');
178
+ strictEqual(forced.final_time_locked_balance, 0, 'Got timelock balance');
179
+ strictEqual(forced.id, toForceClose.id, 'Got closed channel id');
180
+ strictEqual(forced.is_breach_close, false, 'Not a breach');
181
+ strictEqual(forced.is_cooperative_close, false, 'Not a coop close');
182
+ strictEqual(forced.is_funding_cancel, false, 'Not a cancel');
183
+ strictEqual(forced.is_local_force_close, false, 'Not a local force close');
184
+ strictEqual(forced.is_partner_closed, true, 'The remote closed');
185
+ strictEqual(forced.is_partner_initiated, false, 'Local initiated');
186
+ strictEqual(forced.is_remote_force_close, true, 'Remote force closed');
187
+ strictEqual(forced.partner_public_key, target.id, 'Got remote public key');
188
+ strictEqual(forced.transaction_id, toForceClose.transaction_id, 'Got txid');
189
+ strictEqual(forced.transaction_vout, toForceClose.transaction_vout, 'Vout');
209
190
 
210
191
  const cancelHtlc = forced.close_payments.find(n => !n.is_paid);
211
192
 
212
- equal(cancelHtlc.is_outgoing, false, 'HTLC is incoming');
213
- equal(cancelHtlc.is_paid, false, 'HTLC is not settled');
214
- equal(cancelHtlc.is_pending, false, 'HTLC cannot be settled');
215
- equal(cancelHtlc.is_refunded, false, 'HTLC has not been refunded');
216
- equal(cancelHtlc.spent_by, undefined, 'HTLC has no sweep tx');
217
- equal(cancelHtlc.tokens, 1e5, 'HTLC has invoice value');
218
- equal(!!cancelHtlc.transaction_id, true, 'HTLC has tx id');
219
- equal(cancelHtlc.transaction_vout !== undefined, true, 'HTLC has tx vout');
193
+ strictEqual(cancelHtlc.is_outgoing, false, 'HTLC is incoming');
194
+ strictEqual(cancelHtlc.is_paid, false, 'HTLC is not settled');
195
+ strictEqual(cancelHtlc.is_pending, false, 'HTLC cannot be settled');
196
+ strictEqual(cancelHtlc.is_refunded, false, 'HTLC has not been refunded');
197
+ strictEqual(cancelHtlc.spent_by, undefined, 'HTLC has no sweep tx');
198
+ strictEqual(cancelHtlc.tokens, 1e5, 'HTLC has invoice value');
199
+ strictEqual(!!cancelHtlc.transaction_id, true, 'HTLC has tx id');
200
+ strictEqual(cancelHtlc.transaction_vout !== undefined, true, 'HTLC vout');
220
201
 
221
202
  const settleHtlc = forced.close_payments.find(n => !!n.is_paid);
222
203
 
223
- equal(settleHtlc.is_outgoing, false, 'Settle is incoming');
224
- equal(settleHtlc.is_paid, true, 'Settle is paid');
225
- equal(settleHtlc.is_pending, false, 'Already settled');
226
- equal(settleHtlc.is_refunded, false, 'No refund available');
227
- equal(!!settleHtlc.spent_by, true, 'Swept with preimage tx');
228
- equal(settleHtlc.tokens, 1e5, 'Settled with invoice value');
229
- equal(!!settleHtlc.transaction_id, true, 'Output tx id');
230
- equal(settleHtlc.transaction_vout !== undefined, true, 'Output tx vout');
204
+ strictEqual(settleHtlc.is_outgoing, false, 'Settle is incoming');
205
+ strictEqual(settleHtlc.is_paid, true, 'Settle is paid');
206
+ strictEqual(settleHtlc.is_pending, false, 'Already settled');
207
+ strictEqual(settleHtlc.is_refunded, false, 'No refund available');
208
+ strictEqual(!!settleHtlc.spent_by, true, 'Swept with preimage tx');
209
+ strictEqual(settleHtlc.tokens, 1e5, 'Settled with invoice value');
210
+ strictEqual(!!settleHtlc.transaction_id, true, 'Output tx id');
211
+ strictEqual(settleHtlc.transaction_vout !== undefined, true, 'Output vout');
231
212
 
232
213
  const alsoDead = await asyncRetry({interval: 20, times: 7000}, async () => {
233
214
  const {channels} = await getClosedChannels({lnd: target.lnd});
@@ -243,49 +224,49 @@ test(`Get closed channels`, async ({end, equal}) => {
243
224
 
244
225
  const forceClosed = alsoDead.find(n => !!n.is_local_force_close);
245
226
 
246
- equal(forceClosed.capacity, 7e5, 'Target capacity reflected');
247
- equal(!!forceClosed.close_balance_spent_by, true, 'Target spent by');
248
- equal(forceClosed.close_balance_vout !== undefined, true, 'Has balance out');
249
- equal(!!forceClosed.close_confirm_height, true, 'Has confirm height');
250
- equal(!!forceClosed.close_payments.length, true, 'Has close payments');
251
- equal(!!forceClosed.close_transaction_id, true, 'Has close id');
252
- equal(forceClosed.final_local_balance, 1e5, 'Has local balance');
253
- equal(forceClosed.final_time_locked_balance, 3e5, 'Has timelock balance');
254
- equal(forceClosed.id, toForceClose.id, 'Has channel id');
255
- equal(forceClosed.is_breach_close, false, 'Not breach close');
256
- equal(forceClosed.is_cooperative_close, false, 'Not coop close');
257
- equal(forceClosed.is_funding_cancel, false, 'Not funding cancel');
258
- equal(forceClosed.is_local_force_close, true, 'Locally forced closed');
259
- equal(forceClosed.is_partner_closed, false, 'Not remote closed');
260
- equal(forceClosed.is_partner_initiated, true, 'Remote created channel');
261
- equal(forceClosed.is_remote_force_close, false, 'Remote not force closed');
262
- equal(forceClosed.partner_public_key, control.id, 'Got peer key');
263
- equal(forceClosed.transaction_id, toForceClose.transaction_id, 'Got tx id');
264
- equal(forceClosed.transaction_vout, toForceClose.transaction_vout, 'Vout');
227
+ strictEqual(forceClosed.capacity, 7e5, 'Target capacity reflected');
228
+ strictEqual(!!forceClosed.close_balance_spent_by, true, 'Target spent by');
229
+ strictEqual(forceClosed.close_balance_vout !== undefined, true, 'Balance');
230
+ strictEqual(!!forceClosed.close_confirm_height, true, 'Has confirm height');
231
+ strictEqual(!!forceClosed.close_payments.length, true, 'Has close payments');
232
+ strictEqual(!!forceClosed.close_transaction_id, true, 'Has close id');
233
+ strictEqual(forceClosed.final_local_balance, 1e5, 'Has local balance');
234
+ strictEqual(forceClosed.final_time_locked_balance, 3e5, 'Timelock balance');
235
+ strictEqual(forceClosed.id, toForceClose.id, 'Has channel id');
236
+ strictEqual(forceClosed.is_breach_close, false, 'Not breach close');
237
+ strictEqual(forceClosed.is_cooperative_close, false, 'Not coop close');
238
+ strictEqual(forceClosed.is_funding_cancel, false, 'Not funding cancel');
239
+ strictEqual(forceClosed.is_local_force_close, true, 'Locally forced closed');
240
+ strictEqual(forceClosed.is_partner_closed, false, 'Not remote closed');
241
+ strictEqual(forceClosed.is_partner_initiated, true, 'Remote create channel');
242
+ strictEqual(forceClosed.is_remote_force_close, false, 'Remote not force');
243
+ strictEqual(forceClosed.partner_public_key, control.id, 'Got peer key');
244
+ strictEqual(forceClosed.transaction_id, toForceClose.transaction_id, 'Tx');
245
+ strictEqual(forceClosed.transaction_vout, toForceClose.transaction_vout);
265
246
 
266
247
  const forcePay = forceClosed.close_payments.find(n => !!n.is_paid);
267
248
 
268
- equal(forcePay.is_outgoing, true, 'Payment was outgoing');
269
- equal(forcePay.is_paid, true, 'Payment was sent');
270
- equal(forcePay.is_pending, false, 'Payment is settled');
271
- equal(forcePay.is_refunded, false, 'Payment completed successfully');
272
- equal(!!forcePay.spent_by, true, 'Payment was swept with preimage');
273
- equal(forcePay.tokens, 1e5, 'Payment tokens amount');
274
- equal(!!forcePay.transaction_id, true, 'Got payment transaction id');
275
- equal(forcePay.transaction_vout !== undefined, true, 'Got payment vout');
249
+ strictEqual(forcePay.is_outgoing, true, 'Payment was outgoing');
250
+ strictEqual(forcePay.is_paid, true, 'Payment was sent');
251
+ strictEqual(forcePay.is_pending, false, 'Payment is settled');
252
+ strictEqual(forcePay.is_refunded, false, 'Payment completed successfully');
253
+ strictEqual(!!forcePay.spent_by, true, 'Payment was swept with preimage');
254
+ strictEqual(forcePay.tokens, 1e5, 'Payment tokens amount');
255
+ strictEqual(!!forcePay.transaction_id, true, 'Got payment transaction id');
256
+ strictEqual(forcePay.transaction_vout !== undefined, true, 'Got vout');
276
257
 
277
258
  const refundedHtlc = forceClosed.close_payments.find(n => !!n.is_refunded);
278
259
 
279
- equal(refundedHtlc.is_outgoing, true, 'Payment was outgoing');
280
- equal(refundedHtlc.is_paid, false, 'Payment was not paid');
281
- equal(refundedHtlc.is_pending, false, 'Payment is resolved back');
282
- equal(refundedHtlc.is_refunded, true, 'Payment refunded successfully');
283
- equal(!!refundedHtlc.spent_by, true, 'Payment was swept with preimage');
284
- equal(refundedHtlc.tokens, 1e5, 'Payment refund tokens amount');
285
- equal(!!refundedHtlc.transaction_id, true, 'Got refund transaction id');
286
- equal(refundedHtlc.transaction_vout !== undefined, true, 'Got refund vout');
260
+ strictEqual(refundedHtlc.is_outgoing, true, 'Payment was outgoing');
261
+ strictEqual(refundedHtlc.is_paid, false, 'Payment was not paid');
262
+ strictEqual(refundedHtlc.is_pending, false, 'Payment is resolved back');
263
+ strictEqual(refundedHtlc.is_refunded, true, 'Payment refunded successfully');
264
+ strictEqual(!!refundedHtlc.spent_by, true, 'Payment was swept');
265
+ strictEqual(refundedHtlc.tokens, 1e5, 'Payment refund tokens amount');
266
+ strictEqual(!!refundedHtlc.transaction_id, true, 'Got refund tx id');
267
+ strictEqual(refundedHtlc.transaction_vout !== undefined, true, 'Got vout');
287
268
 
288
269
  await kill({});
289
270
 
290
- return end();
271
+ return;
291
272
  });
@@ -1,19 +1,20 @@
1
+ const {deepStrictEqual} = require('node:assert').strict;
2
+ const {strictEqual} = require('node:assert').strict;
3
+ const test = require('node:test');
4
+
1
5
  const asyncRetry = require('async/retry');
6
+ const {setupChannel} = require('ln-docker-daemons');
2
7
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
8
 
5
9
  const {addPeer} = require('./../../');
6
10
  const {createChainAddress} = require('./../../');
7
- const {createCluster} = require('./../macros');
8
11
  const {createInvoice} = require('./../../');
9
12
  const {deleteForwardingReputations} = require('./../../');
10
- const {getChainBalance} = require('./../../');
11
13
  const {getFailedPayments} = require('./../../');
12
14
  const {getPayment} = require('./../../');
13
15
  const {getPayments} = require('./../../');
14
16
  const {pay} = require('./../../');
15
17
  const {sendToChainAddress} = require('./../../');
16
- const {setupChannel} = require('./../macros');
17
18
 
18
19
  const channelCapacityTokens = 1e6;
19
20
  const confirmationCount = 20;
@@ -23,7 +24,7 @@ const times = 1000;
23
24
  const tokens = 1e6 / 2;
24
25
 
25
26
  // Getting failed payments should return failed payments
26
- test('Get failed payments', async ({end, equal, strictSame}) => {
27
+ test('Get failed payments', async () => {
27
28
  const {kill, nodes} = await spawnLightningCluster({size});
28
29
 
29
30
  const [{generate, lnd}, target, remote] = nodes;
@@ -52,7 +53,7 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
52
53
  lnd: target.lnd,
53
54
  generate: target.generate,
54
55
  generator: target,
55
- give: Math.round(channelCapacityTokens / 2),
56
+ give_tokens: Math.round(channelCapacityTokens / 2),
56
57
  to: remote,
57
58
  });
58
59
 
@@ -90,25 +91,25 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
90
91
 
91
92
  const [payment] = payments.filter(n => n.mtokens === bigInvoice.mtokens);
92
93
 
93
- equal(payment.destination, remote.id, 'Payment to');
94
- equal(payment.confirmed_at, undefined, 'No confirmation date');
95
- equal(!!payment.created_at, true, 'Got payment created date');
96
- equal(payment.fee, undefined, 'No fee when not paid');
97
- equal(payment.fee_mtokens, undefined, 'No fee mtokens when not paid');
98
- equal(!!payment.id, true, 'Got a payment id');
99
- equal(!!payment.index, true, 'Got payment index');
100
- equal(payment.is_confirmed, false, 'Failed payment is not confirmed');
101
- equal(payment.is_outgoing, true, 'Failed payment is outgoing');
102
- equal(payment.mtokens, bigInvoice.mtokens, 'Payment has mtokens');
103
- equal(payment.request, bigInvoice.request, 'Probe has a request');
104
- equal(payment.secret, undefined, 'Failed has no secret');
105
- equal(payment.safe_fee, undefined, 'Failed has no fee');
106
- equal(payment.safe_tokens, bigInvoice.tokens, 'Failed has safe tokens');
107
- equal(payment.tokens, bigInvoice.tokens, 'Failed has tokens');
94
+ strictEqual(payment.destination, remote.id, 'Payment to');
95
+ strictEqual(payment.confirmed_at, undefined, 'No confirmation date');
96
+ strictEqual(!!payment.created_at, true, 'Got payment created date');
97
+ strictEqual(payment.fee, undefined, 'No fee when not paid');
98
+ strictEqual(payment.fee_mtokens, undefined, 'No fee mtokens not paid');
99
+ strictEqual(!!payment.id, true, 'Got a payment id');
100
+ strictEqual(!!payment.index, true, 'Got payment index');
101
+ strictEqual(payment.is_confirmed, false, 'Failed payment not confirmed');
102
+ strictEqual(payment.is_outgoing, true, 'Failed payment is outgoing');
103
+ strictEqual(payment.mtokens, bigInvoice.mtokens, 'Payment has mtokens');
104
+ strictEqual(payment.request, bigInvoice.request, 'Probe has a request');
105
+ strictEqual(payment.secret, undefined, 'Failed has no secret');
106
+ strictEqual(payment.safe_fee, undefined, 'Failed has no fee');
107
+ strictEqual(payment.safe_tokens, bigInvoice.tokens, 'Safe tokens');
108
+ strictEqual(payment.tokens, bigInvoice.tokens, 'Failed has tokens');
108
109
 
109
110
  const gotFailed = await getPayment({lnd, id: payment.id});
110
111
 
111
- strictSame(
112
+ deepStrictEqual(
112
113
  gotFailed,
113
114
  {
114
115
  failed: {
@@ -133,28 +134,28 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
133
134
 
134
135
  const [payment] = payments;
135
136
 
136
- equal(payment.destination, remote.id, 'Paid to');
137
- equal(!!payment.confirmed_at, true, 'Got confirmation date');
138
- equal(!!payment.created_at, true, 'Got payment start date');
139
- equal(payment.fee, 1, 'Got fee paid');
140
- equal(payment.fee_mtokens, '1500', 'Got fee mtokens paid');
141
- strictSame(payment.hops, [target.id], 'Got hops');
142
- equal(!!payment.id, true, 'Got a payment id');
143
- equal(!!payment.index, true, 'Got payment index');
144
- equal(payment.is_confirmed, true, 'Failed payment is not confirmed');
145
- equal(payment.is_outgoing, true, 'Failed payment is outgoing');
146
- equal(payment.mtokens, invoice.mtokens, 'Payment has mtokens');
147
- equal(payment.request, invoice.request, 'Payment has a request');
148
- equal(!!payment.secret, true, 'Failed has no secret');
149
- equal(payment.safe_fee, 2, 'Failed has no fee');
150
- equal(payment.safe_tokens, invoice.tokens, 'Failed has safe tokens');
151
- equal(payment.tokens, invoice.tokens, 'Failed has tokens');
137
+ deepStrictEqual(payment.destination, remote.id, 'Paid to');
138
+ deepStrictEqual(!!payment.confirmed_at, true, 'Got confirmation date');
139
+ deepStrictEqual(!!payment.created_at, true, 'Got payment start date');
140
+ deepStrictEqual(payment.fee, 1, 'Got fee paid');
141
+ deepStrictEqual(payment.fee_mtokens, '1500', 'Got fee mtokens paid');
142
+ deepStrictEqual(payment.hops, [target.id], 'Got hops');
143
+ deepStrictEqual(!!payment.id, true, 'Got a payment id');
144
+ deepStrictEqual(!!payment.index, true, 'Got payment index');
145
+ deepStrictEqual(payment.is_confirmed, true, 'Failed not confirmed');
146
+ deepStrictEqual(payment.is_outgoing, true, 'Failed payment is outgoing');
147
+ deepStrictEqual(payment.mtokens, invoice.mtokens, 'Payment has mtokens');
148
+ deepStrictEqual(payment.request, invoice.request, 'Payment has request');
149
+ deepStrictEqual(!!payment.secret, true, 'Failed has no secret');
150
+ deepStrictEqual(payment.safe_fee, 2, 'Failed has no fee');
151
+ deepStrictEqual(payment.safe_tokens, invoice.tokens, 'Safe tokens');
152
+ deepStrictEqual(payment.tokens, invoice.tokens, 'Failed has tokens');
152
153
  }
153
154
  } catch (err) {
154
- strictSame(err, null, 'Expected no error');
155
- } finally {
156
- await kill({});
155
+ strictEqual(err, null, 'Expected no error');
157
156
  }
158
157
 
159
- return end();
158
+ await kill({});
159
+
160
+ return;
160
161
  });
@@ -1,15 +1,17 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const {setupChannel} = require('ln-docker-daemons');
1
5
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
6
 
4
7
  const {getFeeRates} = require('./../../');
5
- const {setupChannel} = require('./../macros');
6
8
 
7
9
  const defaultBaseFee = 1;
8
10
  const defaultFeeRate = 1;
9
11
  const size = 2;
10
12
 
11
13
  // Getting fee rates should return the fee rates of nodes in the channel graph
12
- test(`Get fee rates`, async ({end, equal}) => {
14
+ test(`Get fee rates`, async () => {
13
15
  const {kill, nodes} = await spawnLightningCluster({size});
14
16
 
15
17
  const [{generate, lnd}, to] = nodes;
@@ -18,21 +20,21 @@ test(`Get fee rates`, async ({end, equal}) => {
18
20
 
19
21
  const {channels} = await getFeeRates({lnd});
20
22
 
21
- equal(channels.length, [channelOpen].length, 'Channel was opened');
23
+ strictEqual(channels.length, [channelOpen].length, 'Channel was opened');
22
24
 
23
25
  const [channel] = channels || [{}];
24
26
 
25
27
  if (!!channel.id) {
26
- equal(channel.id, channelOpen.id, 'Channel id is represented');
28
+ strictEqual(channel.id, channelOpen.id, 'Channel id is represented');
27
29
  }
28
30
 
29
- equal(channel.base_fee, defaultFeeRate, 'Channel base fee');
30
- equal(channel.base_fee_mtokens, (defaultFeeRate * 1000)+'', 'Base fee mtok');
31
- equal(channel.fee_rate, defaultBaseFee, 'Channel fee rate');
32
- equal(channel.transaction_id, channelOpen.transaction_id, 'Channel tx id');
33
- equal(channel.transaction_vout, channelOpen.transaction_vout, 'Tx vout');
31
+ strictEqual(channel.base_fee, defaultFeeRate, 'Channel base fee');
32
+ strictEqual(channel.base_fee_mtokens, (defaultFeeRate * 1000)+'', 'Base');
33
+ strictEqual(channel.fee_rate, defaultBaseFee, 'Channel fee rate');
34
+ strictEqual(channel.transaction_id, channelOpen.transaction_id, 'Tx id');
35
+ strictEqual(channel.transaction_vout, channelOpen.transaction_vout, 'Vout');
34
36
 
35
37
  await kill({});
36
38
 
37
- return end();
39
+ return;
38
40
  });