ln-service 56.7.1 → 56.8.1
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 +4 -0
- package/README.md +4 -1
- package/package.json +12 -12
- 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 +11 -8
- 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
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ through npm.
|
|
|
9
9
|
|
|
10
10
|
Supported LND versions:
|
|
11
11
|
|
|
12
|
-
- v0.16.0-beta to v0.16.
|
|
12
|
+
- v0.16.0-beta to v0.16.4-beta
|
|
13
13
|
- v0.15.2-beta to v0.15.5-beta
|
|
14
14
|
- v0.14.4-beta to v0.14.5-beta
|
|
15
15
|
|
|
@@ -2885,6 +2885,8 @@ Requires `offchain:read` permission
|
|
|
2885
2885
|
|
|
2886
2886
|
`description` is not supported in LND 0.16.4 or before
|
|
2887
2887
|
|
|
2888
|
+
`blocks_until_expiry` is not supported in LND 0.16.4 or before
|
|
2889
|
+
|
|
2888
2890
|
{
|
|
2889
2891
|
lnd: <Authenticated LND API Object>
|
|
2890
2892
|
}
|
|
@@ -2892,6 +2894,7 @@ Requires `offchain:read` permission
|
|
|
2892
2894
|
@returns via cbk or Promise
|
|
2893
2895
|
{
|
|
2894
2896
|
pending_channels: [{
|
|
2897
|
+
[blocks_until_expiry]: <Blocks Until Open Channel Expires Number>
|
|
2895
2898
|
capacity: <Channel Capacity Tokens Number>
|
|
2896
2899
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
2897
2900
|
[description]: <Channel Description String>
|
package/package.json
CHANGED
|
@@ -7,35 +7,34 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/ln-service/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"bolt07": "1.8.
|
|
10
|
+
"bolt07": "1.8.4",
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.18.2",
|
|
13
|
-
"invoices": "
|
|
14
|
-
"lightning": "9.
|
|
13
|
+
"invoices": "3.0.0",
|
|
14
|
+
"lightning": "9.8.1",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.13.0"
|
|
18
18
|
},
|
|
19
19
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@alexbosworth/blockchain": "1.
|
|
22
|
-
"@alexbosworth/tap": "15.0.12",
|
|
21
|
+
"@alexbosworth/blockchain": "1.5.0",
|
|
23
22
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
24
23
|
"async": "3.2.4",
|
|
25
|
-
"asyncjs-util": "1.2.
|
|
24
|
+
"asyncjs-util": "1.2.12",
|
|
26
25
|
"bip32": "4.0.0",
|
|
27
26
|
"bip66": "1.1.5",
|
|
28
27
|
"bitcoinjs-lib": "6.1.3",
|
|
29
28
|
"bn.js": "5.2.1",
|
|
30
29
|
"bs58check": "3.0.1",
|
|
31
30
|
"ecpair": "2.1.0",
|
|
32
|
-
"ln-docker-daemons": "5.
|
|
33
|
-
"p2tr": "
|
|
31
|
+
"ln-docker-daemons": "5.1.1",
|
|
32
|
+
"p2tr": "2.0.0",
|
|
34
33
|
"portfinder": "1.0.32",
|
|
35
|
-
"psbt": "
|
|
34
|
+
"psbt": "3.0.0",
|
|
36
35
|
"rimraf": "5.0.1",
|
|
37
36
|
"secp256k1": "5.0.0",
|
|
38
|
-
"tiny-secp256k1": "2.2.
|
|
37
|
+
"tiny-secp256k1": "2.2.3",
|
|
39
38
|
"uuid": "9.0.0",
|
|
40
39
|
"varuint-bitcoin": "1.1.2"
|
|
41
40
|
},
|
|
@@ -57,6 +56,7 @@
|
|
|
57
56
|
"url": "https://github.com/alexbosworth/ln-service.git"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
59
|
+
"integration-test-0.16.4": "DOCKER_LND_VERSION=v0.16.4-beta npm run test",
|
|
60
60
|
"integration-test-0.16.3": "DOCKER_LND_VERSION=v0.16.3-beta npm run test",
|
|
61
61
|
"integration-test-0.16.2": "DOCKER_LND_VERSION=v0.16.2-beta npm run test",
|
|
62
62
|
"integration-test-0.16.1": "DOCKER_LND_VERSION=v0.16.1-beta npm run test",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"integration-test-0.15.2": "DOCKER_LND_VERSION=v0.15.2-beta npm run test",
|
|
68
68
|
"integration-test-0.14.5": "DOCKER_LND_VERSION=v0.14.5-beta npm run test",
|
|
69
69
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
70
|
-
"test": "echo $DOCKER_LND_VERSION &&
|
|
70
|
+
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
71
71
|
},
|
|
72
|
-
"version": "56.
|
|
72
|
+
"version": "56.8.1"
|
|
73
73
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
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 {addPeer} = require('./../../');
|
|
5
|
-
const {delay} = require('./../macros');
|
|
6
8
|
const {getAutopilot} = require('./../../');
|
|
7
9
|
const {setAutopilot} = require('./../../');
|
|
8
|
-
const {setupChannel} = require('./../macros');
|
|
9
10
|
|
|
10
11
|
const avg = array => array.reduce((a, b) => a + b) / array.length;
|
|
11
12
|
const confirmationCount = 6;
|
|
13
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
12
14
|
const maxScore = 1e8;
|
|
13
15
|
const score = 50000000;
|
|
14
16
|
const size = 2;
|
|
15
17
|
|
|
16
18
|
// Adjusting autopilot should result in changed autopilot status
|
|
17
|
-
test(`Autopilot`, async (
|
|
19
|
+
test(`Autopilot`, async () => {
|
|
18
20
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
19
21
|
|
|
20
22
|
const [control, target] = nodes;
|
|
@@ -25,7 +27,11 @@ test(`Autopilot`, async ({end, equal}) => {
|
|
|
25
27
|
|
|
26
28
|
await setupChannel({lnd, generate: control.generate, to: cluster.target});
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
strictEqual(
|
|
31
|
+
(await getAutopilot({lnd})).is_enabled,
|
|
32
|
+
false,
|
|
33
|
+
'Autopilot starts off'
|
|
34
|
+
);
|
|
29
35
|
|
|
30
36
|
await Promise.all([
|
|
31
37
|
cluster.control.generate({count: confirmationCount}),
|
|
@@ -39,11 +45,19 @@ test(`Autopilot`, async ({end, equal}) => {
|
|
|
39
45
|
socket: cluster.target.socket,
|
|
40
46
|
});
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
strictEqual(
|
|
49
|
+
(await getAutopilot({lnd})).is_enabled,
|
|
50
|
+
true,
|
|
51
|
+
'Autopilot turned on'
|
|
52
|
+
);
|
|
43
53
|
|
|
44
54
|
await setAutopilot({lnd, is_enabled: false});
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
strictEqual(
|
|
57
|
+
(await getAutopilot({lnd})).is_enabled,
|
|
58
|
+
false,
|
|
59
|
+
'Autopilot turned off'
|
|
60
|
+
);
|
|
47
61
|
|
|
48
62
|
const pubKey = cluster.control.id;
|
|
49
63
|
|
|
@@ -55,19 +69,19 @@ test(`Autopilot`, async ({end, equal}) => {
|
|
|
55
69
|
|
|
56
70
|
const autopilot = await getAutopilot({lnd, node_scores: [pubKey]});
|
|
57
71
|
|
|
58
|
-
|
|
72
|
+
strictEqual(autopilot.is_enabled, true, 'Autopilot was enable');
|
|
59
73
|
|
|
60
74
|
const [node] = autopilot.nodes;
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
strictEqual(node.local_preferential_score, maxScore, 'Local score');
|
|
77
|
+
strictEqual(node.local_score, score, 'Local score is represented');
|
|
78
|
+
strictEqual(node.preferential_score, maxScore, 'Global preferential score');
|
|
79
|
+
strictEqual(node.public_key, pubKey, 'Candidate node public key');
|
|
80
|
+
strictEqual(node.score, score, 'External score is represented');
|
|
81
|
+
strictEqual(node.weighted_local_score, avg([maxScore, score]), 'Weight avg');
|
|
82
|
+
strictEqual(node.weighted_score, avg([maxScore, score]), 'Norm Weight avg');
|
|
69
83
|
|
|
70
84
|
await kill({});
|
|
71
85
|
|
|
72
|
-
return
|
|
86
|
+
return;
|
|
73
87
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const {idForBlock} = require('@alexbosworth/blockchain');
|
|
2
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
3
|
-
const {test} = require('@alexbosworth/tap');
|
|
4
6
|
|
|
5
7
|
const {getBlock} = require('./../../');
|
|
6
8
|
const {getHeight} = require('./../../');
|
|
7
9
|
|
|
8
10
|
// Get height should return height
|
|
9
|
-
test(`Get height`, async (
|
|
11
|
+
test(`Get height`, async () => {
|
|
10
12
|
const {nodes} = await spawnLightningCluster({});
|
|
11
13
|
|
|
12
14
|
const [{chain, generate, kill, lnd}] = nodes;
|
|
@@ -20,36 +22,37 @@ test(`Get height`, async ({end, equal, fail}) => {
|
|
|
20
22
|
try {
|
|
21
23
|
const {block} = await getBlock({lnd, id: blockchain.current_block_hash});
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
strictEqual(idForBlock({block}).id, hash, 'Got block');
|
|
24
26
|
} catch (err) {
|
|
25
27
|
const [code, message] = err;
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
strictEqual(code, 501, 'Got expected code');
|
|
30
|
+
strictEqual(message, 'GetBlockMethodNotSupported', 'Got expected message');
|
|
29
31
|
|
|
30
32
|
await kill({});
|
|
31
33
|
|
|
32
|
-
return
|
|
34
|
+
return;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
// Try getting a block by the height
|
|
36
38
|
try {
|
|
37
39
|
const {block} = await getBlock({height, lnd});
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
strictEqual(idForBlock({block}).id, hash, 'Got block for height');
|
|
39
42
|
} catch (err) {
|
|
40
|
-
|
|
43
|
+
strictEqual(err, null, 'Expected no error');
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// Try getting the chain tip block
|
|
44
47
|
try {
|
|
45
48
|
const {block} = await getBlock({lnd});
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
strictEqual(idForBlock({block}).id, hash, 'Got chain tip block');
|
|
48
51
|
} catch (err) {
|
|
49
|
-
|
|
52
|
+
strictEqual(err, null, 'Expected no error');
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
await kill({});
|
|
53
56
|
|
|
54
|
-
return
|
|
57
|
+
return;
|
|
55
58
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
3
|
-
const {test} = require('@alexbosworth/tap');
|
|
4
6
|
|
|
5
7
|
const {getHeight} = require('./../../');
|
|
6
8
|
|
|
@@ -8,7 +10,7 @@ const confirmationCount = 6;
|
|
|
8
10
|
const times = 100;
|
|
9
11
|
|
|
10
12
|
// Get height should return height
|
|
11
|
-
test(`Get height`, async (
|
|
13
|
+
test(`Get height`, async () => {
|
|
12
14
|
const {nodes} = await spawnLightningCluster({});
|
|
13
15
|
|
|
14
16
|
const [{chain, generate, kill, lnd}] = nodes;
|
|
@@ -24,12 +26,16 @@ test(`Get height`, async ({end, equal, fail}) => {
|
|
|
24
26
|
throw new Error('ExpectedHeightIncreaseReflected');
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
strictEqual(
|
|
30
|
+
endHeight - startHeight >= confirmationCount,
|
|
31
|
+
true,
|
|
32
|
+
'Got height'
|
|
33
|
+
);
|
|
28
34
|
|
|
29
35
|
return;
|
|
30
36
|
});
|
|
31
37
|
|
|
32
38
|
await kill({});
|
|
33
39
|
|
|
34
|
-
return
|
|
40
|
+
return;
|
|
35
41
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const EventEmitter = require('events');
|
|
2
|
-
const {once} = require('events');
|
|
1
|
+
const EventEmitter = require('node:events');
|
|
2
|
+
const {once} = require('node:events');
|
|
3
|
+
const {strictEqual} = require('node:assert').strict;
|
|
4
|
+
const test = require('node:test');
|
|
3
5
|
|
|
4
6
|
const asyncRetry = require('async/retry');
|
|
5
7
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
6
|
-
const {test} = require('@alexbosworth/tap');
|
|
7
8
|
|
|
8
9
|
const {createChainAddress} = require('./../../');
|
|
9
10
|
const {delay} = require('./../macros');
|
|
@@ -19,7 +20,7 @@ const race = promises => Promise.race(promises);
|
|
|
19
20
|
const times = 4000;
|
|
20
21
|
|
|
21
22
|
// Subscribers to blocks should receive block notifications
|
|
22
|
-
test(`Subscribe to blocks`, async (
|
|
23
|
+
test(`Subscribe to blocks`, async () => {
|
|
23
24
|
const blocks = [];
|
|
24
25
|
const {kill, nodes} = await spawnLightningCluster({});
|
|
25
26
|
|
|
@@ -40,7 +41,7 @@ test(`Subscribe to blocks`, async ({end, equal, fail}) => {
|
|
|
40
41
|
return !!event.height;
|
|
41
42
|
});
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
strictEqual(gotHeight, true, 'Got the block height');
|
|
44
45
|
|
|
45
46
|
try {
|
|
46
47
|
// Wait for chainrpc to be active
|
|
@@ -73,15 +74,15 @@ test(`Subscribe to blocks`, async ({end, equal, fail}) => {
|
|
|
73
74
|
});
|
|
74
75
|
|
|
75
76
|
blocks.forEach(({height, id}) => {
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
strictEqual(!!height, true, 'Got expected block height');
|
|
78
|
+
strictEqual(id.length, 64, 'Got expected block hash length');
|
|
78
79
|
return;
|
|
79
80
|
});
|
|
80
81
|
} catch (err) {
|
|
81
|
-
|
|
82
|
+
strictEqual(err, null, 'Expected no error');
|
|
82
83
|
} finally {
|
|
83
84
|
await kill({});
|
|
84
85
|
|
|
85
|
-
return
|
|
86
|
+
return;
|
|
86
87
|
}
|
|
87
88
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
3
|
-
const {test} = require('@alexbosworth/tap');
|
|
4
6
|
|
|
5
7
|
const {chainSendTransaction} = require('./../macros');
|
|
6
8
|
const {createChainAddress} = require('./../../');
|
|
@@ -23,7 +25,7 @@ const times = 1500;
|
|
|
23
25
|
const tokens = 1e8;
|
|
24
26
|
|
|
25
27
|
// Subscribing to chain transaction confirmations should trigger events
|
|
26
|
-
test(`Subscribe to chain transactions`, async (
|
|
28
|
+
test(`Subscribe to chain transactions`, async () => {
|
|
27
29
|
const {kill, nodes} = await spawnLightningCluster({});
|
|
28
30
|
|
|
29
31
|
const [{chain, generate, lnd}] = nodes;
|
|
@@ -77,9 +79,9 @@ test(`Subscribe to chain transactions`, async ({end, equal, fail}) => {
|
|
|
77
79
|
throw new Error('ExpectedSubscribeToChainAddressSeesConf');
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
strictEqual(firstConf.block.length, 64, 'Confirmation hash returned');
|
|
83
|
+
strictEqual(firstConf.height >= 102, true, 'Got confirmation height');
|
|
84
|
+
strictEqual(firstConf.transaction, transaction, 'Confirmation raw tx');
|
|
83
85
|
|
|
84
86
|
return;
|
|
85
87
|
});
|
|
@@ -105,9 +107,9 @@ test(`Subscribe to chain transactions`, async ({end, equal, fail}) => {
|
|
|
105
107
|
throw new Error('ExpectedSubscribeToChainAddressSeesConfirmation');
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
strictEqual(secondConf.block.length, 64, 'Confirmation hash returned');
|
|
111
|
+
strictEqual(secondConf.height >= 102, true, 'Confirmation block height');
|
|
112
|
+
strictEqual(secondConf.transaction, transaction, '2nd conf tx returned');
|
|
111
113
|
|
|
112
114
|
return;
|
|
113
115
|
});
|
|
@@ -117,5 +119,5 @@ test(`Subscribe to chain transactions`, async ({end, equal, fail}) => {
|
|
|
117
119
|
|
|
118
120
|
await kill({});
|
|
119
121
|
|
|
120
|
-
return
|
|
122
|
+
return;
|
|
121
123
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const {once} = require('events');
|
|
1
|
+
const {once} = require('node:events');
|
|
2
|
+
const {strictEqual} = require('node:assert').strict;
|
|
3
|
+
const test = require('node:test');
|
|
2
4
|
|
|
3
5
|
const asyncRetry = require('async/retry');
|
|
4
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
5
|
-
const {test} = require('@alexbosworth/tap');
|
|
6
7
|
|
|
7
8
|
const {createChainAddress} = require('./../../');
|
|
8
9
|
const {getChainBalance} = require('./../../');
|
|
@@ -22,7 +23,7 @@ const times = 1000;
|
|
|
22
23
|
const tokens = 1e6;
|
|
23
24
|
|
|
24
25
|
// Subscribing to chain spend should push events on spend confirmations
|
|
25
|
-
test(`Subscribe to chain spend`, async (
|
|
26
|
+
test(`Subscribe to chain spend`, async () => {
|
|
26
27
|
let gotAddressConf = false;
|
|
27
28
|
|
|
28
29
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
@@ -77,9 +78,9 @@ test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
|
77
78
|
sub.on('error', err => {});
|
|
78
79
|
|
|
79
80
|
sub.once('confirmation', ({height, transaction, vin}) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
strictEqual(!!height, true, 'Height of the confirmation is returned');
|
|
82
|
+
strictEqual(!!transaction, true, 'Raw transaction is returned');
|
|
83
|
+
strictEqual(vin !== undefined, true, 'Transaction input index returned');
|
|
83
84
|
|
|
84
85
|
return gotAddressConf = true;
|
|
85
86
|
});
|
|
@@ -109,7 +110,7 @@ test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
|
109
110
|
|
|
110
111
|
await kill({});
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
strictEqual(gotAddressConf, true, 'Subscribe to address sees confirmation');
|
|
113
114
|
|
|
114
|
-
return
|
|
115
|
+
return;
|
|
115
116
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
3
|
-
const {test} = require('@alexbosworth/tap');
|
|
4
6
|
|
|
5
7
|
const {addPeer} = require('./../../');
|
|
6
8
|
const {createCluster} = require('./../macros');
|
|
@@ -12,7 +14,7 @@ const times = 4000;
|
|
|
12
14
|
const timeout = 100;
|
|
13
15
|
|
|
14
16
|
// Adding peers should result in a connected peer
|
|
15
|
-
test(`Add a peer`, async (
|
|
17
|
+
test(`Add a peer`, async () => {
|
|
16
18
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
17
19
|
|
|
18
20
|
const [{lnd}, target] = nodes;
|
|
@@ -20,7 +22,11 @@ test(`Add a peer`, async ({end, equal}) => {
|
|
|
20
22
|
try {
|
|
21
23
|
const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
strictEqual(
|
|
26
|
+
connectedKeys.find(n => n === target.id),
|
|
27
|
+
undefined,
|
|
28
|
+
'No peer'
|
|
29
|
+
);
|
|
24
30
|
|
|
25
31
|
await asyncRetry({interval, times}, async () => {
|
|
26
32
|
await addPeer({
|
|
@@ -40,13 +46,13 @@ test(`Add a peer`, async ({end, equal}) => {
|
|
|
40
46
|
throw new Error('ExpectedConnectionToTarget');
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
strictEqual(connected.public_key, target.id, 'Connected to remote node');
|
|
44
50
|
});
|
|
45
51
|
} catch (err) {
|
|
46
|
-
|
|
52
|
+
strictEqual(err, null, 'Expected no error');
|
|
47
53
|
} finally {
|
|
48
54
|
await kill({});
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
return
|
|
57
|
+
return;
|
|
52
58
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
|
|
1
3
|
const asyncEach = require('async/each');
|
|
2
4
|
const asyncRetry = require('async/retry');
|
|
3
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
4
|
-
const {test} = require('@alexbosworth/tap');
|
|
5
6
|
|
|
6
7
|
const {addPeer} = require('./../../');
|
|
7
8
|
const {cancelPendingChannel} = require('./../../');
|
|
8
|
-
const {createCluster} = require('./../macros');
|
|
9
|
-
const {delay} = require('./../macros');
|
|
10
|
-
const {getChainBalance} = require('./../../');
|
|
11
9
|
const {openChannels} = require('./../../');
|
|
12
10
|
|
|
13
11
|
const capacity = 1e6;
|
|
14
12
|
const count = 100;
|
|
13
|
+
const delay = n => new Promise(resolve => setTimeout(resolve, n));
|
|
15
14
|
const interval = 100;
|
|
16
15
|
const race = promises => Promise.race(promises);
|
|
17
16
|
const size = 2;
|
|
@@ -19,20 +18,18 @@ const timeout = 1000 * 5;
|
|
|
19
18
|
const times = 200;
|
|
20
19
|
|
|
21
20
|
// Cancel a channel should result in no pending channels
|
|
22
|
-
test(`Cancel pending channel`, async (
|
|
21
|
+
test(`Cancel pending channel`, async () => {
|
|
23
22
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
24
23
|
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
const {lnd} = control;
|
|
24
|
+
const [{generate, lnd}, target] = nodes;
|
|
28
25
|
|
|
29
|
-
await
|
|
30
|
-
|
|
31
|
-
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
26
|
+
await generate({count});
|
|
32
27
|
|
|
33
28
|
const channels = [{capacity, partner_public_key: target.id}];
|
|
34
29
|
|
|
35
30
|
await asyncRetry({interval, times}, async () => {
|
|
31
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
32
|
+
|
|
36
33
|
const toCancel = await race([
|
|
37
34
|
delay(timeout),
|
|
38
35
|
openChannels({channels, lnd}),
|
|
@@ -45,5 +42,5 @@ test(`Cancel pending channel`, async ({end, equal}) => {
|
|
|
45
42
|
|
|
46
43
|
await kill({});
|
|
47
44
|
|
|
48
|
-
return
|
|
45
|
+
return;
|
|
49
46
|
});
|
|
@@ -1,14 +1,15 @@
|
|
|
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 {closeChannel} = require('./../../');
|
|
5
|
-
const {createCluster} = require('./../macros');
|
|
6
|
-
const {setupChannel} = require('./../macros');
|
|
7
8
|
|
|
8
9
|
const size = 2;
|
|
9
10
|
|
|
10
11
|
// Closing a channel should close the channel
|
|
11
|
-
test(`Close channel`, async (
|
|
12
|
+
test(`Close channel`, async () => {
|
|
12
13
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
13
14
|
|
|
14
15
|
const [control, target] = nodes;
|
|
@@ -28,10 +29,10 @@ test(`Close channel`, async ({end, equal}) => {
|
|
|
28
29
|
transaction_vout: channelOpen.transaction_vout,
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
strictEqual(channelClose.transaction_id.length, 64, 'Got force close id');
|
|
33
|
+
strictEqual(channelClose.transaction_vout, 0, 'Force close vout returned');
|
|
33
34
|
} catch (err) {
|
|
34
|
-
|
|
35
|
+
strictEqual(err, null, 'Expected no error force closing');
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// Coop close channel using the channel id
|
|
@@ -47,13 +48,13 @@ test(`Close channel`, async ({end, equal}) => {
|
|
|
47
48
|
lnd: control.lnd,
|
|
48
49
|
});
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
strictEqual(channelClose.transaction_id.length, 64, 'Got coop close id');
|
|
52
|
+
strictEqual(channelClose.transaction_vout, 0, 'Got coop close tx vout');
|
|
52
53
|
} catch (err) {
|
|
53
|
-
|
|
54
|
+
strictEqual(err, null, 'Expected no error coop closing');
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
await kill({});
|
|
57
58
|
|
|
58
|
-
return
|
|
59
|
+
return;
|
|
59
60
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const {equal} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const {address} = require('bitcoinjs-lib');
|
|
2
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
3
|
-
const {test} = require('@alexbosworth/tap');
|
|
4
6
|
|
|
5
7
|
const {createChainAddress} = require('./../../');
|
|
6
8
|
|
|
@@ -11,7 +13,7 @@ const prefixForV1 = 'bcrt1p';
|
|
|
11
13
|
const regtestBech32AddressHrp = 'bcrt';
|
|
12
14
|
|
|
13
15
|
// Creating addresses should result in addresses
|
|
14
|
-
test(`Create address results in address creation`, async (
|
|
16
|
+
test(`Create address results in address creation`, async () => {
|
|
15
17
|
const [{kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
16
18
|
|
|
17
19
|
const createNewChainAddresses = formats
|
|
@@ -48,5 +50,5 @@ test(`Create address results in address creation`, async ({end, equal}) => {
|
|
|
48
50
|
|
|
49
51
|
await kill({});
|
|
50
52
|
|
|
51
|
-
return
|
|
53
|
+
return;
|
|
52
54
|
});
|