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.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -0
- package/package.json +10 -11
- package/test/autopilotrpc-integration/test_autopilot.js +30 -16
- package/test/chainrpc-integration/test_get_block.js +14 -11
- package/test/chainrpc-integration/test_get_height.js +10 -4
- package/test/chainrpc-integration/test_subscribe_to_blocks.js +10 -9
- package/test/chainrpc-integration/test_subscribe_to_chain_address.js +11 -9
- package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +9 -8
- package/test/integration/test_add_peer.js +12 -6
- package/test/integration/test_cancel_pending_channel.js +9 -12
- package/test/integration/test_close_channel.js +12 -11
- package/test/integration/test_create_chain_address.js +5 -3
- package/test/integration/test_create_invoice.js +19 -15
- package/test/integration/test_decode_payment_request.js +19 -16
- package/test/integration/test_delete_payment.js +11 -30
- package/test/integration/test_delete_payments.js +8 -8
- package/test/integration/test_delete_pending_channel.js +13 -27
- package/test/integration/test_get_access_ids.js +7 -15
- package/test/integration/test_get_backup.js +12 -14
- package/test/integration/test_get_backups.js +11 -9
- package/test/integration/test_get_chain_balance.js +8 -8
- package/test/integration/test_get_chain_fee_estimate.js +8 -6
- package/test/integration/test_get_chain_transactions.js +22 -21
- package/test/integration/test_get_channel.js +19 -17
- package/test/integration/test_get_channel_balance.js +6 -4
- package/test/integration/test_get_channels.js +42 -39
- package/test/integration/test_get_closed_channels.js +95 -114
- package/test/integration/test_get_failed_payments.js +43 -42
- package/test/integration/test_get_fee_rates.js +13 -11
- package/test/integration/test_get_forwards.js +27 -24
- package/test/integration/test_get_invoice.js +31 -24
- package/test/integration/test_get_invoices.js +18 -15
- package/test/integration/test_get_methods.js +13 -16
- package/test/integration/test_get_network_centrality.js +15 -13
- package/test/integration/test_get_network_graph.js +36 -23
- package/test/integration/test_get_network_info.js +13 -11
- package/test/integration/test_get_node.js +27 -21
- package/test/integration/test_get_payments.js +20 -18
- package/test/integration/test_get_peers.js +16 -14
- package/test/integration/test_get_pending_coop.js +49 -39
- package/test/integration/test_get_pending_force.js +67 -90
- package/test/integration/test_get_pending_payments.js +23 -24
- package/test/integration/test_get_route_to_destination.js +15 -15
- package/test/integration/test_get_settlement_status.js +13 -9
- package/test/integration/test_get_utxos.js +13 -11
- package/test/integration/test_get_wallet_info.js +20 -16
- package/test/integration/test_grant_access.js +20 -23
- package/test/integration/test_open_channel.js +10 -8
- package/test/integration/test_open_channels.js +11 -10
- package/test/integration/test_pay.js +18 -27
- package/test/integration/test_pay_private_invoice.js +11 -24
- package/test/integration/test_payment_errors.js +10 -11
- package/test/integration/test_propose_channel.js +70 -105
- package/test/integration/test_push_funds.js +8 -10
- package/test/integration/test_rebalance.js +44 -32
- package/test/integration/test_recover_funds_from_channel.js +13 -11
- package/test/integration/test_recover_funds_from_channels.js +13 -11
- package/test/integration/test_remove_peer.js +8 -6
- package/test/integration/test_restrict_macaroon.js +8 -5
- package/test/integration/test_revoke_access.js +19 -24
- package/test/integration/test_send_message_to_peer.js +11 -6
- package/test/integration/test_send_to_chain_address.js +13 -12
- package/test/integration/test_send_to_chain_addresses.js +10 -8
- package/test/integration/test_sign_message.js +6 -4
- package/test/integration/test_stop_daemon.js +7 -4
- package/test/integration/test_subscribe_to_backups.js +7 -5
- package/test/integration/test_subscribe_to_channels.js +10 -21
- package/test/integration/test_subscribe_to_graph.js +17 -9
- package/test/integration/test_subscribe_to_invoices.js +10 -8
- package/test/integration/test_subscribe_to_open_requests.js +13 -12
- package/test/integration/test_subscribe_to_peer_messages.js +8 -5
- package/test/integration/test_subscribe_to_peers.js +7 -6
- package/test/integration/test_subscribe_to_rpc_requests.js +202 -191
- package/test/integration/test_subscribe_to_transactions.js +6 -4
- package/test/integration/test_trusted_funding.js +17 -11
- package/test/integration/test_update_routing_fees.js +8 -5
- package/test/integration/test_verify_access.js +8 -6
- package/test/integration/test_verify_backup.js +6 -6
- package/test/integration/test_verify_backups.js +6 -6
- package/test/integration/test_verify_message.js +5 -3
- package/test/invoicesrpc-integration/test_cancel_invoice.js +6 -5
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +6 -7
- package/test/invoicesrpc-integration/test_push_payment.js +7 -6
- package/test/invoicesrpc-integration/test_settle_invoice.js +10 -6
- package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +8 -7
- package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +8 -7
- package/test/peersrpc-integration/test_add_external_socket.js +7 -5
- package/test/peersrpc-integration/test_remove_external_socket.js +7 -5
- package/test/peersrpc-integration/test_update_alias.js +8 -6
- package/test/peersrpc-integration/test_update_color.js +8 -6
- package/test/routerrpc-integration/test_delete_forwarding_reputations.js +8 -6
- package/test/routerrpc-integration/test_disable_channel.js +6 -4
- package/test/routerrpc-integration/test_get_forwarding_confidence.js +7 -5
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +12 -7
- package/test/routerrpc-integration/test_get_pathfinding_settings.js +7 -5
- package/test/routerrpc-integration/test_get_payment.js +10 -6
- package/test/routerrpc-integration/test_get_route_confidence.js +6 -4
- package/test/routerrpc-integration/test_get_route_through_hops.js +8 -7
- package/test/routerrpc-integration/test_is_destination_payable.js +48 -0
- package/test/routerrpc-integration/test_multipath_payment.js +8 -5
- package/test/routerrpc-integration/test_pay_via_payment_details.js +11 -9
- package/test/routerrpc-integration/test_pay_via_payment_request.js +11 -7
- package/test/routerrpc-integration/test_pay_via_routes.js +8 -11
- package/test/routerrpc-integration/test_probe_for_route.js +10 -7
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +10 -7
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +23 -19
- package/test/routerrpc-integration/test_subscribe_to_past_payments.js +8 -6
- package/test/routerrpc-integration/test_subscribe_to_payments.js +18 -17
- package/test/routerrpc-integration/test_update_pathfinding_settings.js +8 -6
- package/test/runner.js +30 -0
- package/test/signerrpc-integration/test_begin_group_signing_session.js +8 -5
- package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +7 -4
- package/test/signerrpc-integration/test_sign_bytes.js +5 -3
- package/test/signerrpc-integration/test_sign_taproot.js +6 -4
- package/test/signerrpc-integration/test_sign_transaction.js +5 -3
- package/test/signerrpc-integration/test_verify_bytes_signature.js +5 -4
- package/test/tower_clientrpc-integration/test_connect_watchtower.js +7 -4
- package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +7 -4
- package/test/tower_serverrpc-integration/test_get_tower_server_info.js +6 -3
- package/test/versionrpc-integration/test_get_wallet_version.js +16 -12
- package/test/walletrpc-integration/test_broadcast_chain_transaction.js +5 -3
- package/test/walletrpc-integration/test_fund_psbt.js +5 -10
- package/test/walletrpc-integration/test_get_chain_addresses.js +9 -7
- package/test/walletrpc-integration/test_get_chain_fee_rate.js +5 -3
- package/test/walletrpc-integration/test_get_locked_utxos.js +8 -20
- package/test/walletrpc-integration/test_get_master_public_keys.js +9 -6
- package/test/walletrpc-integration/test_get_public_key.js +5 -3
- package/test/walletrpc-integration/test_lock_utxo.js +9 -5
- package/test/walletrpc-integration/test_partially_sign_psbt.js +7 -4
- package/test/walletrpc-integration/test_request_chain_fee_increase.js +8 -4
- package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +7 -4
- package/test/walletrpc-integration/test_sign_chain_address_message.js +6 -6
- package/test/walletrpc-integration/test_sign_psbt.js +6 -4
- package/test/walletrpc-integration/test_unlock_utxo.js +8 -4
- package/test/walletrpc-integration/test_update_chain_transaction.js +5 -3
- package/test/walletrpc-integration/test_verify_chain_address_message.js +6 -4
- package/test/extra-integration/test_change_password.js +0 -15
- package/test/extra-integration/test_get_wallet_status.js +0 -45
- package/test/extra-integration/test_no_macaroon.js +0 -20
- package/test/extra-integration/tower_clientrpc-integration/test_disconnect_watchtower.js +0 -51
- package/test/extra-integration/tower_clientrpc-integration/test_update_connected_watchtower.js +0 -76
- package/test/grpc-integration/test_authenticated_lnd_grpc.js +0 -40
- 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 (
|
|
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
|
-
|
|
18
|
+
strictEqual(result.channel_balance, emptyBalance, 'Valid channel balance');
|
|
17
19
|
|
|
18
20
|
await kill({});
|
|
19
21
|
|
|
20
|
-
return
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
34
|
+
strictEqual(targetChan.is_partner_initiated, true, 'Self-init channel');
|
|
32
35
|
|
|
33
36
|
if (!!channel.local_given) {
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
47
|
+
strictEqual(channel.local_csv, 144, 'Local CSV is returned');
|
|
45
48
|
ok(channel.local_dust >= 354, 'Local dust limit is returned');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
70
|
+
strictEqual([53345, 28473, 2810].includes(spend), true, 'Final');
|
|
90
71
|
} else {
|
|
91
|
-
|
|
72
|
+
strictEqual(spend, 9050, 'Final');
|
|
92
73
|
}
|
|
93
74
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
155
|
-
} finally {
|
|
156
|
-
await kill({});
|
|
155
|
+
strictEqual(err, null, 'Expected no error');
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
|
|
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 (
|
|
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
|
-
|
|
23
|
+
strictEqual(channels.length, [channelOpen].length, 'Channel was opened');
|
|
22
24
|
|
|
23
25
|
const [channel] = channels || [{}];
|
|
24
26
|
|
|
25
27
|
if (!!channel.id) {
|
|
26
|
-
|
|
28
|
+
strictEqual(channel.id, channelOpen.id, 'Channel id is represented');
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
39
|
+
return;
|
|
38
40
|
});
|