ln-service 52.14.4 → 53.0.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 +21 -0
- package/README.md +163 -11
- package/package.json +7 -14
- package/test/autopilotrpc-integration/test_autopilot.js +9 -15
- package/test/chainrpc-integration/test_get_height.js +7 -10
- package/test/chainrpc-integration/test_subscribe_to_blocks.js +52 -31
- package/test/chainrpc-integration/test_subscribe_to_chain_address.js +72 -66
- package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +47 -16
- package/test/{integration → extra-integration}/test_recover_funds_from_channel.js +0 -0
- package/test/{integration → extra-integration}/test_recover_funds_from_channels.js +0 -0
- package/test/{integration → extra-integration}/test_restrict_macaroon.js +0 -0
- package/test/{integration → extra-integration}/test_revoke_access.js +0 -0
- package/test/{integration → extra-integration}/test_subscribe_to_rpc_requests.js +1 -1
- package/test/integration/test_add_peer.js +16 -12
- package/test/integration/test_cancel_pending_channel.js +20 -6
- package/test/integration/test_close_channel.js +15 -10
- package/test/integration/test_create_chain_address.js +3 -6
- package/test/integration/test_create_invoice.js +27 -23
- package/test/integration/test_decode_payment_request.js +30 -29
- package/test/integration/test_delete_payment.js +11 -8
- package/test/integration/test_delete_payments.js +13 -16
- package/test/integration/test_get_access_ids.js +4 -7
- package/test/integration/test_get_backup.js +12 -8
- package/test/integration/test_get_backups.js +8 -10
- package/test/integration/test_get_chain_balance.js +9 -53
- package/test/integration/test_get_chain_fee_estimate.js +21 -10
- package/test/integration/test_get_chain_transactions.js +30 -52
- package/test/integration/test_get_channel.js +7 -7
- package/test/integration/test_get_channel_balance.js +5 -6
- package/test/integration/test_get_channels.js +11 -10
- package/test/integration/test_get_closed_channels.js +169 -139
- package/test/integration/test_get_failed_payments.js +37 -39
- package/test/integration/test_get_fee_rates.js +6 -9
- package/test/integration/test_get_forwards.js +34 -35
- package/test/integration/test_get_invoice.js +7 -11
- package/test/integration/test_get_invoices.js +33 -30
- package/test/integration/test_get_methods.js +4 -7
- package/test/integration/test_get_network_centrality.js +14 -17
- package/test/integration/test_get_network_graph.js +12 -15
- package/test/integration/test_get_network_info.js +5 -6
- package/test/integration/test_get_node.js +15 -31
- package/test/integration/test_get_payments.js +10 -10
- package/test/integration/test_get_peers.js +10 -13
- package/test/integration/test_get_pending_coop.js +13 -18
- package/test/integration/test_get_pending_force.js +29 -21
- package/test/integration/test_get_route_to_destination.js +47 -40
- package/test/integration/test_get_utxos.js +17 -42
- package/test/integration/test_get_wallet_info.js +5 -12
- package/test/integration/test_open_channel.js +16 -9
- package/test/integration/test_open_channels.js +66 -66
- package/test/integration/test_pay.js +39 -36
- package/test/integration/test_pay_private_invoice.js +78 -72
- package/test/integration/test_payment_errors.js +13 -11
- package/test/integration/test_propose_channel.js +74 -53
- package/test/integration/test_push_funds.js +11 -15
- package/test/integration/test_rebalance.js +11 -22
- package/test/integration/test_remove_peer.js +13 -48
- package/test/integration/test_send_message_to_peer.js +25 -17
- package/test/integration/test_send_to_chain_address.js +60 -51
- package/test/integration/test_send_to_chain_addresses.js +30 -18
- package/test/integration/test_sign_message.js +3 -6
- package/test/integration/test_stop_daemon.js +3 -9
- package/test/integration/test_subscribe_to_backups.js +19 -11
- package/test/integration/test_subscribe_to_channels.js +28 -20
- package/test/integration/test_subscribe_to_graph.js +43 -22
- package/test/integration/test_subscribe_to_invoices.js +89 -103
- package/test/integration/test_subscribe_to_open_requests.js +47 -31
- package/test/integration/test_subscribe_to_peer_messages.js +51 -21
- package/test/integration/test_subscribe_to_peers.js +11 -16
- package/test/integration/test_subscribe_to_transactions.js +49 -45
- package/test/integration/test_update_routing_fees.js +12 -16
- package/test/integration/test_verify_access.js +5 -10
- package/test/integration/test_verify_backup.js +10 -8
- package/test/integration/test_verify_backups.js +11 -16
- package/test/integration/test_verify_message.js +6 -9
- package/test/invoicesrpc-integration/test_cancel_invoice.js +15 -22
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +15 -11
- package/test/invoicesrpc-integration/test_push_payment.js +53 -55
- package/test/invoicesrpc-integration/test_settle_invoice.js +25 -19
- package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +13 -11
- package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +20 -15
- package/test/macros/btcsuite_type_daemon.js +1 -1
- package/test/macros/chain_send_transaction.js +1 -1
- package/test/macros/change_password.js +15 -13
- package/test/macros/generate_blocks.js +24 -29
- package/test/macros/rpc.js +1 -0
- package/test/macros/setup_channel.js +23 -9
- package/test/macros/spawn_lnd.js +3 -1
- package/test/macros/wait_for_channel.js +8 -3
- package/test/macros/wait_for_route.js +2 -2
- package/test/routerrpc-integration/test_delete_forwarding_reputations.js +15 -22
- package/test/routerrpc-integration/test_disable_channel.js +8 -12
- package/test/routerrpc-integration/test_get_forwarding_confidence.js +17 -37
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +26 -25
- package/test/routerrpc-integration/test_get_pathfinding_settings.js +6 -12
- package/test/routerrpc-integration/test_get_payment.js +19 -26
- package/test/routerrpc-integration/test_get_route_confidence.js +15 -21
- package/test/routerrpc-integration/test_get_route_through_hops.js +29 -32
- package/test/routerrpc-integration/test_multipath_payment.js +18 -20
- package/test/routerrpc-integration/test_pay_via_payment_details.js +19 -34
- package/test/routerrpc-integration/test_pay_via_payment_request.js +17 -27
- package/test/routerrpc-integration/test_pay_via_routes.js +37 -37
- package/test/routerrpc-integration/test_probe_for_route.js +27 -33
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +138 -32
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +83 -77
- package/test/routerrpc-integration/test_subscribe_to_past_payments.js +34 -28
- package/test/routerrpc-integration/test_update_pathfinding_settings.js +7 -10
- package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +15 -14
- package/test/signerrpc-integration/test_sign_bytes.js +11 -15
- package/test/signerrpc-integration/test_sign_transaction.js +6 -7
- package/test/signerrpc-integration/test_verify_bytes_signature.js +11 -12
- package/test/versionrpc-integration/test_get_wallet_version.js +6 -7
- package/test/walletrpc-integration/test_fund_psbt.js +13 -12
- package/test/walletrpc-integration/test_get_chain_fee_rate.js +4 -8
- package/test/walletrpc-integration/test_get_locked_utxos.js +11 -27
- package/test/walletrpc-integration/test_get_public_key.js +5 -13
- package/test/walletrpc-integration/test_lock_utxo.js +16 -23
- package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +25 -6
- package/test/walletrpc-integration/test_sign_psbt.js +28 -19
- package/test/walletrpc-integration/test_unlock_utxo.js +16 -27
- package/test/walletrpc-integration/test_update_chain_transaction.js +6 -31
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
const asyncTimesSeries = require('async/timesSeries');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
|
-
const {createCluster} = require('./../macros');
|
|
5
5
|
const {createInvoice} = require('./../../');
|
|
6
|
-
const {delay} = require('./../macros');
|
|
7
6
|
const {getPayments} = require('./../../');
|
|
8
7
|
const {pay} = require('./../../');
|
|
9
8
|
const {setupChannel} = require('./../macros');
|
|
10
9
|
|
|
11
10
|
const start = new Date().toISOString();
|
|
11
|
+
const size = 2;
|
|
12
12
|
const tokens = 100;
|
|
13
13
|
|
|
14
14
|
// Getting payments should return the list of payments
|
|
15
15
|
test('Get payments', async ({end, equal}) => {
|
|
16
|
-
const
|
|
16
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
17
17
|
|
|
18
|
-
const {lnd} =
|
|
18
|
+
const [{generate, lnd}, target] = nodes;
|
|
19
19
|
|
|
20
|
-
await setupChannel({
|
|
20
|
+
await setupChannel({generate, lnd, to: target});
|
|
21
21
|
|
|
22
|
-
const invoice = await createInvoice({tokens, lnd:
|
|
22
|
+
const invoice = await createInvoice({tokens, lnd: target.lnd});
|
|
23
23
|
|
|
24
24
|
const paid = await pay({lnd, request: invoice.request});
|
|
25
25
|
|
|
26
26
|
const [payment] = (await getPayments({lnd})).payments;
|
|
27
27
|
|
|
28
|
-
equal(payment.destination,
|
|
28
|
+
equal(payment.destination, target.id, 'Destination');
|
|
29
29
|
equal(payment.confirmed_at > start, true, 'Got confirmed date');
|
|
30
30
|
equal(payment.created_at.length, 24, 'Created at time');
|
|
31
31
|
equal(payment.fee, 0, 'Fee paid');
|
|
32
|
-
equal(payment.hops.length,
|
|
32
|
+
equal(payment.hops.length, [].length, 'Hops');
|
|
33
33
|
equal(payment.id, invoice.id, 'Id');
|
|
34
34
|
equal(payment.is_confirmed, true, 'Confirmed');
|
|
35
35
|
equal(payment.is_outgoing, true, 'Outgoing');
|
|
@@ -42,7 +42,7 @@ test('Get payments', async ({end, equal}) => {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
await asyncTimesSeries(4, async () => {
|
|
45
|
-
const {request} = await createInvoice({tokens, lnd:
|
|
45
|
+
const {request} = await createInvoice({tokens, lnd: target.lnd});
|
|
46
46
|
|
|
47
47
|
const paid = await pay({lnd, request});
|
|
48
48
|
});
|
|
@@ -61,7 +61,7 @@ test('Get payments', async ({end, equal}) => {
|
|
|
61
61
|
|
|
62
62
|
equal(!!page3.next, false, 'There is no page 4');
|
|
63
63
|
|
|
64
|
-
await
|
|
64
|
+
await kill({});
|
|
65
65
|
|
|
66
66
|
return end();
|
|
67
67
|
});
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
5
|
const {addPeer} = require('./../../');
|
|
5
|
-
const {createCluster} = require('./../macros');
|
|
6
6
|
const {getPeers} = require('./../../');
|
|
7
7
|
|
|
8
|
-
const interval =
|
|
9
|
-
const
|
|
8
|
+
const interval = 10
|
|
9
|
+
const size = 2;
|
|
10
|
+
const times = 1000;
|
|
10
11
|
|
|
11
12
|
// Getting peers should return the list of peers
|
|
12
13
|
test('Get peers', async ({end, equal}) => {
|
|
13
|
-
const
|
|
14
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
14
15
|
|
|
15
|
-
const {lnd} =
|
|
16
|
-
|
|
17
|
-
await addPeer({
|
|
18
|
-
lnd,
|
|
19
|
-
public_key: cluster.remote.public_key,
|
|
20
|
-
socket: cluster.remote.socket,
|
|
21
|
-
});
|
|
16
|
+
const [{lnd}, target] = nodes;
|
|
22
17
|
|
|
23
18
|
await asyncRetry({interval, times}, async () => {
|
|
19
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
20
|
+
|
|
24
21
|
const [peer] = (await getPeers({lnd})).peers;
|
|
25
22
|
|
|
26
23
|
if (!peer || !peer.is_sync_peer) {
|
|
@@ -32,7 +29,7 @@ test('Get peers', async ({end, equal}) => {
|
|
|
32
29
|
equal(peer.is_inbound, false, 'Is inbound peer');
|
|
33
30
|
equal(peer.is_sync_peer, true, 'Is sync peer');
|
|
34
31
|
equal(peer.ping_time, 0, 'Ping time');
|
|
35
|
-
equal(
|
|
32
|
+
equal(peer.public_key, target.id, 'Public key');
|
|
36
33
|
equal(!!peer.socket, true, 'Socket');
|
|
37
34
|
equal(peer.tokens_received, 0, 'Tokens received');
|
|
38
35
|
equal(peer.tokens_sent, 0, 'Tokens sent');
|
|
@@ -40,7 +37,7 @@ test('Get peers', async ({end, equal}) => {
|
|
|
40
37
|
return;
|
|
41
38
|
});
|
|
42
39
|
|
|
43
|
-
await
|
|
40
|
+
await kill({});
|
|
44
41
|
|
|
45
42
|
return end();
|
|
46
43
|
});
|
|
@@ -1,37 +1,32 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {closeChannel} = require('./../../');
|
|
4
|
-
const {createCluster} = require('./../macros');
|
|
5
5
|
const {getWalletInfo} = require('./../../');
|
|
6
6
|
const {setupChannel} = require('./../macros');
|
|
7
7
|
const {waitForPendingChannel} = require('./../macros');
|
|
8
8
|
|
|
9
|
+
const anchorsFeatureBit = 23;
|
|
9
10
|
const defaultFee = 1e3;
|
|
10
|
-
const
|
|
11
|
+
const give = 1e4;
|
|
12
|
+
const size = 2;
|
|
11
13
|
|
|
12
14
|
// Getting pending channels should show pending channels
|
|
13
15
|
test(`Get pending channels`, async ({end, equal}) => {
|
|
14
|
-
const
|
|
16
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
15
17
|
|
|
16
|
-
const {lnd} =
|
|
18
|
+
const [{generate, lnd}, target] = nodes;
|
|
17
19
|
|
|
18
20
|
const {features} = await getWalletInfo({lnd});
|
|
19
21
|
|
|
20
|
-
const isAnchors = !!features.find(n => n.bit ===
|
|
22
|
+
const isAnchors = !!features.find(n => n.bit === anchorsFeatureBit);
|
|
21
23
|
|
|
22
24
|
// Target starts a channel with control
|
|
23
|
-
const coopChan = await setupChannel({
|
|
24
|
-
lnd,
|
|
25
|
-
generate: cluster.generate,
|
|
26
|
-
give: giftTokens,
|
|
27
|
-
to: cluster.target,
|
|
28
|
-
});
|
|
25
|
+
const coopChan = await setupChannel({generate, give, lnd, to: target});
|
|
29
26
|
|
|
30
27
|
// Target closes the channel
|
|
31
28
|
const niceClose = await closeChannel({
|
|
32
|
-
lnd:
|
|
33
|
-
public_key: cluster.target.public_key,
|
|
34
|
-
socket: cluster.target.socket,
|
|
29
|
+
lnd: target.lnd,
|
|
35
30
|
tokens_per_vbyte: defaultFee,
|
|
36
31
|
transaction_id: coopChan.transaction_id,
|
|
37
32
|
transaction_vout: coopChan.transaction_vout,
|
|
@@ -39,7 +34,7 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
39
34
|
|
|
40
35
|
// Control views their pending channels
|
|
41
36
|
const {channel} = await waitForPendingChannel({
|
|
42
|
-
lnd
|
|
37
|
+
lnd,
|
|
43
38
|
id: coopChan.transaction_id,
|
|
44
39
|
});
|
|
45
40
|
|
|
@@ -61,7 +56,7 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
61
56
|
equal(channel.is_closing, true, 'Closing');
|
|
62
57
|
equal(channel.is_opening, false, 'Not Opening');
|
|
63
58
|
equal(channel.local_reserve, 10000, 'Local reserve');
|
|
64
|
-
equal(channel.partner_public_key,
|
|
59
|
+
equal(channel.partner_public_key, target.id, 'Target public key');
|
|
65
60
|
equal(channel.pending_payments, undefined, 'No pending payments');
|
|
66
61
|
equal(channel.received, 0, 'Never received');
|
|
67
62
|
equal(channel.recovered_tokens, undefined, 'Nothing to recover in sweep');
|
|
@@ -74,10 +69,10 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
74
69
|
equal(channel.transaction_weight, null, 'No funding tx weight data');
|
|
75
70
|
|
|
76
71
|
if (!!channel.remote_balance) {
|
|
77
|
-
equal(channel.remote_balance,
|
|
72
|
+
equal(channel.remote_balance, give, 'Opposing channel balance');
|
|
78
73
|
}
|
|
79
74
|
|
|
80
|
-
await
|
|
75
|
+
await kill({});
|
|
81
76
|
|
|
82
77
|
return end();
|
|
83
78
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
5
|
+
const {addPeer} = require('./../../');
|
|
4
6
|
const {closeChannel} = require('./../../');
|
|
5
|
-
const {
|
|
6
|
-
const {delay} = require('./../macros');
|
|
7
|
+
const {getChainBalance} = require('./../../');
|
|
7
8
|
const {getChannels} = require('./../../');
|
|
8
9
|
const {getHeight} = require('./../../');
|
|
9
10
|
const {getPeers} = require('./../../');
|
|
@@ -14,35 +15,42 @@ const {waitChannel} = require('./../macros');
|
|
|
14
15
|
const {waitPendingChannel} = require('./../macros');
|
|
15
16
|
const {waitForUtxo} = require('./../macros');
|
|
16
17
|
|
|
18
|
+
const anchorFeatureBit = 23;
|
|
17
19
|
const channelCapacityTokens = 1e6;
|
|
18
20
|
const confirmationCount = 20;
|
|
21
|
+
const count = 100;
|
|
19
22
|
const defaultFee = 1e3;
|
|
20
23
|
const defaultVout = 0;
|
|
21
24
|
const giftTokens = 1e4;
|
|
22
|
-
const interval =
|
|
25
|
+
const interval = 10;
|
|
26
|
+
const size = 2;
|
|
23
27
|
const spendableRatio = 0.99;
|
|
24
|
-
const times =
|
|
28
|
+
const times = 2000;
|
|
25
29
|
|
|
26
30
|
// Getting pending channels should show pending channels
|
|
27
31
|
test(`Get pending channels`, async ({end, equal}) => {
|
|
28
|
-
const
|
|
32
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
29
33
|
|
|
30
|
-
const {lnd} =
|
|
34
|
+
const [{generate, lnd}, target] = nodes;
|
|
31
35
|
|
|
32
36
|
const {features} = await getWalletInfo({lnd});
|
|
33
37
|
|
|
34
|
-
const isAnchors = !!features.find(n => n.bit ===
|
|
35
|
-
const startHeight = (await getHeight({lnd})).current_block_height
|
|
38
|
+
const isAnchors = !!features.find(n => n.bit === anchorFeatureBit);
|
|
39
|
+
const startHeight = (await getHeight({lnd})).current_block_height;
|
|
40
|
+
|
|
41
|
+
await generate({count});
|
|
36
42
|
|
|
37
43
|
const channelOpen = await asyncRetry({interval, times}, async () => {
|
|
44
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
45
|
+
|
|
38
46
|
return await openChannel({
|
|
39
47
|
lnd,
|
|
40
48
|
chain_fee_tokens_per_vbyte: defaultFee,
|
|
41
49
|
give_tokens: giftTokens,
|
|
42
50
|
local_tokens: channelCapacityTokens,
|
|
43
51
|
partner_csv_delay: 10,
|
|
44
|
-
partner_public_key:
|
|
45
|
-
socket:
|
|
52
|
+
partner_public_key: target.id,
|
|
53
|
+
socket: target.socket,
|
|
46
54
|
});
|
|
47
55
|
});
|
|
48
56
|
|
|
@@ -65,7 +73,7 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
65
73
|
equal(pendingOpen.is_closing, false, 'Not closing yet');
|
|
66
74
|
equal(pendingOpen.is_opening, true, 'Channel is opening');
|
|
67
75
|
equal(pendingOpen.local_reserve, 10000, 'Local reserve amount');
|
|
68
|
-
equal(pendingOpen.partner_public_key,
|
|
76
|
+
equal(pendingOpen.partner_public_key, target.id, 'Key');
|
|
69
77
|
equal(pendingOpen.pending_balance, undefined, 'No pending chain balance');
|
|
70
78
|
equal(pendingOpen.pending_payments, undefined, 'No pending payments');
|
|
71
79
|
equal(pendingOpen.received, 0, 'Nothing received');
|
|
@@ -75,9 +83,9 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
75
83
|
equal(pendingOpen.sent, 0, 'Nothing sent');
|
|
76
84
|
equal(pendingOpen.timelock_expiration, undefined, 'Not timelocked');
|
|
77
85
|
equal(pendingOpen.transaction_id, channelOpen.transaction_id, 'Open tx id');
|
|
78
|
-
equal(pendingOpen.transaction_vout, channelOpen.transaction_vout, 'Tx
|
|
86
|
+
equal(pendingOpen.transaction_vout, channelOpen.transaction_vout, 'Tx out');
|
|
79
87
|
|
|
80
|
-
await
|
|
88
|
+
await generate({count: confirmationCount});
|
|
81
89
|
|
|
82
90
|
await getChannels({lnd, id: channelOpen.transaction_id});
|
|
83
91
|
|
|
@@ -108,7 +116,7 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
108
116
|
equal(waitClose.is_closing, true, 'Channel is closing');
|
|
109
117
|
equal(waitClose.is_opening, false, 'Not opening channel');
|
|
110
118
|
equal(waitClose.local_reserve, 10000, 'Local reserve of closing channel');
|
|
111
|
-
equal(waitClose.partner_public_key,
|
|
119
|
+
equal(waitClose.partner_public_key, target.id, 'Pkey');
|
|
112
120
|
equal(waitClose.pending_payments, undefined, 'No pending payments data');
|
|
113
121
|
equal(waitClose.received, 0, 'Nothing received');
|
|
114
122
|
equal(waitClose.recovered_tokens, undefined, 'Funds not recovered yet');
|
|
@@ -116,7 +124,7 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
116
124
|
equal(waitClose.sent, 0, 'No sent tokens');
|
|
117
125
|
equal(waitClose.timelock_expiration, undefined, 'No timelock data');
|
|
118
126
|
equal(waitClose.transaction_fee, null, 'No tx fee data');
|
|
119
|
-
equal(waitClose.transaction_id, channelOpen.transaction_id, 'Funding
|
|
127
|
+
equal(waitClose.transaction_id, channelOpen.transaction_id, 'Funding txid');
|
|
120
128
|
equal(waitClose.transaction_vout, channelOpen.transaction_vout, 'Tx vout');
|
|
121
129
|
equal(waitClose.transaction_weight, null, 'No funding tx weight data');
|
|
122
130
|
|
|
@@ -127,12 +135,12 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
127
135
|
equal(waitClose.sent, 0, 'Channel never sent funds');
|
|
128
136
|
equal(waitClose.timelock_expiration, undefined, 'Not timelocked yet');
|
|
129
137
|
equal(waitClose.transaction_id, channelOpen.transaction_id, 'Chan txid');
|
|
130
|
-
equal(waitClose.transaction_vout, channelOpen.transaction_vout, 'Chan
|
|
138
|
+
equal(waitClose.transaction_vout, channelOpen.transaction_vout, 'Chan out');
|
|
131
139
|
|
|
132
140
|
// Wait for generation to be over
|
|
133
141
|
await asyncRetry({interval, times}, async () => {
|
|
134
142
|
// Generate to confirm the tx
|
|
135
|
-
await
|
|
143
|
+
await generate({});
|
|
136
144
|
|
|
137
145
|
const [forceClose] = (await getPendingChannels({lnd})).pending_channels;
|
|
138
146
|
|
|
@@ -163,17 +171,17 @@ test(`Get pending channels`, async ({end, equal}) => {
|
|
|
163
171
|
equal(forceClose.is_closing, true, 'Channel is force closing');
|
|
164
172
|
equal(forceClose.is_timelocked, true, 'Force close funds are timelocked')
|
|
165
173
|
equal(forceClose.is_opening, false, 'Channel is not opening');
|
|
166
|
-
equal(forceClose.partner_public_key,
|
|
174
|
+
equal(forceClose.partner_public_key, target.id, 'pk');
|
|
167
175
|
equal(forceClose.received, 0, 'No receive amount');
|
|
168
176
|
equal(forceClose.recovered_tokens, undefined, 'No recovered amount');
|
|
169
177
|
equal(forceClose.remote_balance, 0, 'No remote balance');
|
|
170
178
|
equal(forceClose.sent, 0, 'No sent amount');
|
|
171
179
|
equal(!!forceClose.timelock_blocks, true, 'Timelock blocks set');
|
|
172
|
-
equal(forceClose.timelock_expiration, startHeight +
|
|
180
|
+
equal(forceClose.timelock_expiration, startHeight + 265, 'Funds timelock');
|
|
173
181
|
equal(forceClose.transaction_id, channelOpen.transaction_id, 'Chan-Txid');
|
|
174
|
-
equal(forceClose.transaction_vout, channelOpen.transaction_vout, '
|
|
182
|
+
equal(forceClose.transaction_vout, channelOpen.transaction_vout, 'ChanOut');
|
|
175
183
|
|
|
176
|
-
await
|
|
184
|
+
await kill({});
|
|
177
185
|
|
|
178
186
|
return end();
|
|
179
187
|
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
5
|
const {addPeer} = require('./../../');
|
|
6
|
+
const {cancelHodlInvoice} = require('./../../');
|
|
5
7
|
const {createCluster} = require('./../macros');
|
|
6
8
|
const {createInvoice} = require('./../../');
|
|
7
9
|
const {decodePaymentRequest} = require('./../../');
|
|
10
|
+
const {delay} = require('./../macros');
|
|
8
11
|
const {getInvoice} = require('./../../');
|
|
9
12
|
const {getRouteToDestination} = require('./../../');
|
|
10
13
|
const {parsePaymentRequest} = require('./../../');
|
|
@@ -12,48 +15,52 @@ const {payViaRoutes} = require('./../../');
|
|
|
12
15
|
const {setupChannel} = require('./../macros');
|
|
13
16
|
|
|
14
17
|
const all = promise => Promise.all(promise);
|
|
15
|
-
const interval =
|
|
18
|
+
const interval = 10;
|
|
16
19
|
const {isArray} = Array;
|
|
17
20
|
const message = {type: '85805', value: '01'};
|
|
18
|
-
const
|
|
19
|
-
const
|
|
21
|
+
const size = 3;
|
|
22
|
+
const times = 3000;
|
|
23
|
+
const tokens = 1000;
|
|
20
24
|
|
|
21
25
|
// Getting a route to a destination should return a route to the destination
|
|
22
26
|
test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
23
|
-
const
|
|
27
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
const {lnd} = cluster.target;
|
|
29
|
+
const [control, target, remote] = nodes;
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Exit test early if features are not supported
|
|
31
|
-
if (!(await decodePaymentRequest({lnd, request})).features.length) {
|
|
32
|
-
await cluster.kill({});
|
|
33
|
-
|
|
34
|
-
return end();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
31
|
+
await control.generate({count: 500});
|
|
37
32
|
|
|
38
33
|
await setupChannel({
|
|
39
|
-
generate:
|
|
40
|
-
lnd:
|
|
41
|
-
to:
|
|
34
|
+
generate: control.generate,
|
|
35
|
+
lnd: control.lnd,
|
|
36
|
+
to: target,
|
|
42
37
|
});
|
|
43
38
|
|
|
44
39
|
await setupChannel({
|
|
45
|
-
generate:
|
|
46
|
-
generator: cluster.target,
|
|
40
|
+
generate: target.generate,
|
|
47
41
|
give: 1e5,
|
|
48
42
|
hidden: true,
|
|
49
|
-
lnd:
|
|
50
|
-
to:
|
|
43
|
+
lnd: target.lnd,
|
|
44
|
+
to: remote,
|
|
51
45
|
});
|
|
52
46
|
|
|
53
|
-
const invoice = await
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const invoice = await asyncRetry({interval, times}, async () => {
|
|
48
|
+
const invoice = await createInvoice({
|
|
49
|
+
tokens,
|
|
50
|
+
is_including_private_channels: true,
|
|
51
|
+
lnd: remote.lnd,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const {routes} = parsePaymentRequest({request: invoice.request});
|
|
55
|
+
|
|
56
|
+
// Wait for private routes to get picked up
|
|
57
|
+
if (!routes) {
|
|
58
|
+
await cancelHodlInvoice({id: invoice.id, lnd: remote.lnd});
|
|
59
|
+
|
|
60
|
+
throw new Error('ExpectedRouteForInvoice');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return invoice;
|
|
57
64
|
});
|
|
58
65
|
|
|
59
66
|
const parsed = parsePaymentRequest({request: invoice.request});
|
|
@@ -62,7 +69,7 @@ test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
|
62
69
|
const {route} = await getRouteToDestination({
|
|
63
70
|
destination: parsed.destination,
|
|
64
71
|
features: parsed.features,
|
|
65
|
-
lnd:
|
|
72
|
+
lnd: control.lnd,
|
|
66
73
|
payment: parsed.payment,
|
|
67
74
|
routes: parsed.routes,
|
|
68
75
|
mtokens: parsed.mtokens,
|
|
@@ -71,37 +78,37 @@ test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
|
71
78
|
|
|
72
79
|
const paid = await payViaRoutes({
|
|
73
80
|
id: parsed.id,
|
|
74
|
-
lnd:
|
|
81
|
+
lnd: control.lnd,
|
|
75
82
|
routes: [route],
|
|
76
83
|
});
|
|
77
84
|
|
|
78
85
|
equal(invoice.secret, paid.secret, 'Paid multi-hop private route');
|
|
79
86
|
});
|
|
80
87
|
|
|
81
|
-
const inv = await createInvoice({tokens, lnd:
|
|
88
|
+
const inv = await createInvoice({tokens, lnd: target.lnd});
|
|
82
89
|
|
|
83
90
|
const invDetails = await decodePaymentRequest({
|
|
84
|
-
lnd:
|
|
91
|
+
lnd: control.lnd,
|
|
85
92
|
request: inv.request,
|
|
86
93
|
});
|
|
87
94
|
|
|
88
95
|
const controlToTarget = await getRouteToDestination({
|
|
89
|
-
destination:
|
|
96
|
+
destination: target.id,
|
|
90
97
|
features: invDetails.features,
|
|
91
|
-
lnd:
|
|
98
|
+
lnd: control.lnd,
|
|
92
99
|
messages: [message],
|
|
93
100
|
payment: invDetails.payment,
|
|
94
|
-
tokens: invDetails.tokens / [
|
|
101
|
+
tokens: invDetails.tokens / [control, remote].length,
|
|
95
102
|
total_mtokens: invDetails.mtokens,
|
|
96
103
|
});
|
|
97
104
|
|
|
98
105
|
const remoteToTarget = await getRouteToDestination({
|
|
99
|
-
destination:
|
|
106
|
+
destination: target.id,
|
|
100
107
|
features: invDetails.features,
|
|
101
|
-
lnd:
|
|
108
|
+
lnd: remote.lnd,
|
|
102
109
|
messages: [message],
|
|
103
110
|
payment: invDetails.payment,
|
|
104
|
-
tokens: invDetails.tokens / [
|
|
111
|
+
tokens: invDetails.tokens / [control, remote].length,
|
|
105
112
|
total_mtokens: invDetails.mtokens,
|
|
106
113
|
});
|
|
107
114
|
|
|
@@ -109,12 +116,12 @@ test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
|
109
116
|
const [controlPay, remotePay] = await all([
|
|
110
117
|
payViaRoutes({
|
|
111
118
|
id: invDetails.id,
|
|
112
|
-
lnd:
|
|
119
|
+
lnd: control.lnd,
|
|
113
120
|
routes: [controlToTarget.route],
|
|
114
121
|
}),
|
|
115
122
|
payViaRoutes({
|
|
116
123
|
id: invDetails.id,
|
|
117
|
-
lnd:
|
|
124
|
+
lnd: remote.lnd,
|
|
118
125
|
routes: [remoteToTarget.route],
|
|
119
126
|
}),
|
|
120
127
|
]);
|
|
@@ -124,7 +131,7 @@ test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
|
124
131
|
|
|
125
132
|
const {payments} = await getInvoice({
|
|
126
133
|
id: invDetails.id,
|
|
127
|
-
lnd:
|
|
134
|
+
lnd: target.lnd,
|
|
128
135
|
});
|
|
129
136
|
|
|
130
137
|
const [payment1, payment2] = payments;
|
|
@@ -138,7 +145,7 @@ test(`Get a route to a destination`, async ({end, equal, strictSame}) => {
|
|
|
138
145
|
equal(err, null, 'Unexpected error paying invoice');
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
await
|
|
148
|
+
await kill({});
|
|
142
149
|
|
|
143
150
|
return end();
|
|
144
151
|
});
|
|
@@ -1,72 +1,47 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
|
-
const {chainSendTransaction} = require('./../macros');
|
|
5
5
|
const {createChainAddress} = require('./../../');
|
|
6
|
-
const {
|
|
6
|
+
const {getChainBalance} = require('./../../');
|
|
7
7
|
const {getUtxos} = require('./../../');
|
|
8
|
-
const {mineTransaction} = require('./../macros');
|
|
9
|
-
const {spawnLnd} = require('./../macros');
|
|
10
|
-
const {waitForTermination} = require('./../macros');
|
|
11
|
-
const {waitForUtxo} = require('./../macros');
|
|
12
8
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const defaultVout = 0;
|
|
16
|
-
const format = 'np2wpkh';
|
|
9
|
+
const format = 'p2wpkh';
|
|
10
|
+
const times = 300;
|
|
17
11
|
const tokens = 1e8;
|
|
18
12
|
|
|
19
13
|
// Getting utxos should list out the utxos
|
|
20
14
|
test(`Get utxos`, async ({end, equal, fail, strictSame}) => {
|
|
21
|
-
const
|
|
15
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
22
16
|
|
|
23
|
-
const
|
|
24
|
-
const host = node.listen_ip;
|
|
25
|
-
const {kill} = node;
|
|
26
|
-
const pass = node.chain_rpc_pass;
|
|
27
|
-
const port = node.chain_rpc_port;
|
|
28
|
-
const {lnd} = node;
|
|
29
|
-
const user = node.chain_rpc_user;
|
|
30
|
-
|
|
31
|
-
const {address} = await createChainAddress({format, lnd});
|
|
17
|
+
const [{generate, lnd}] = nodes;
|
|
32
18
|
|
|
33
19
|
// Generate some funds for LND
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const [block] = blocks;
|
|
20
|
+
await asyncRetry({times}, async () => {
|
|
21
|
+
await generate({});
|
|
37
22
|
|
|
38
|
-
|
|
23
|
+
const wallet = await getChainBalance({lnd});
|
|
39
24
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fee: defaultFee,
|
|
44
|
-
private_key: node.mining_key,
|
|
45
|
-
spend_transaction_id: coinbaseTransaction,
|
|
46
|
-
spend_vout: defaultVout,
|
|
25
|
+
if (!wallet.chain_balance) {
|
|
26
|
+
throw new Error('ExpectedChainBalanceForNode');
|
|
27
|
+
}
|
|
47
28
|
});
|
|
48
29
|
|
|
49
|
-
await mineTransaction({cert, host, pass, port, transaction, user});
|
|
50
|
-
|
|
51
|
-
await waitForUtxo({confirmations: 6, lnd, transaction});
|
|
52
|
-
|
|
53
30
|
const {utxos} = await getUtxos({lnd});
|
|
54
31
|
|
|
55
|
-
equal(utxos.length,
|
|
32
|
+
equal(!!utxos.length, true, 'Unspent output returned');
|
|
56
33
|
|
|
57
34
|
const [utxo] = utxos;
|
|
58
35
|
|
|
59
|
-
equal(utxo.address,
|
|
36
|
+
equal(!!utxo.address, true, 'UTXO address returned');
|
|
60
37
|
equal(utxo.address_format, format, 'UTXO address format returned');
|
|
61
|
-
equal(utxo.confirmation_count,
|
|
38
|
+
equal(utxo.confirmation_count, 100, 'Confirmation count returned');
|
|
62
39
|
equal(!!utxo.output_script, true, 'Output script returned');
|
|
63
|
-
equal(utxo.tokens,
|
|
40
|
+
equal(!!utxo.tokens, true, 'UTXO amount returned');
|
|
64
41
|
equal(!!utxo.transaction_id, true, 'UTXO transaction id returned');
|
|
65
42
|
equal(utxo.transaction_vout !== undefined, true, 'UTXO vout returned');
|
|
66
43
|
|
|
67
|
-
kill();
|
|
68
|
-
|
|
69
|
-
await waitForTermination({lnd});
|
|
44
|
+
await kill({});
|
|
70
45
|
|
|
71
46
|
return end();
|
|
72
47
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {getWalletInfo} = require('./../../');
|
|
4
|
-
const {spawnLnd} = require('./../macros');
|
|
5
|
-
const {waitForTermination} = require('./../macros');
|
|
6
5
|
|
|
7
6
|
const initHeight = 1;
|
|
8
7
|
const pubKeyHexLength = Buffer.alloc(33).toString('hex').length;
|
|
@@ -11,31 +10,25 @@ const walletInfoType = 'wallet';
|
|
|
11
10
|
|
|
12
11
|
// Getting the wallet info should return info about the wallet
|
|
13
12
|
test(`Get wallet info`, async ({end, equal, strictSame}) => {
|
|
14
|
-
const
|
|
13
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
15
14
|
|
|
16
|
-
const {lnd} =
|
|
17
|
-
const pubKey = spawned.public_key;
|
|
15
|
+
const [{lnd}] = nodes;
|
|
18
16
|
|
|
19
17
|
const result = await getWalletInfo({lnd});
|
|
20
18
|
|
|
21
|
-
const expectedUri = `${pubKey}@127.0.0.1:${spawned.listen_port}`;
|
|
22
|
-
|
|
23
19
|
equal(result.active_channels_count, 0, 'Expected channels count');
|
|
24
20
|
equal(!!result.alias, true, 'Expected alias');
|
|
25
21
|
strictSame(result.chains, [regtestChainId], 'Got chains');
|
|
26
22
|
equal(!!result.current_block_hash, true, 'Expected best block hash');
|
|
27
23
|
equal(result.current_block_height, initHeight, 'Expected best block height');
|
|
28
|
-
equal(result.is_synced_to_chain, true, 'Expected synced to chain status');
|
|
29
24
|
equal(!!result.latest_block_at, true, 'Last block time');
|
|
30
25
|
equal(result.peers_count, 0, 'Expected wallet peers count');
|
|
31
26
|
equal(result.pending_channels_count, 0, 'Expected pending channels count');
|
|
32
27
|
equal(result.public_key.length, pubKeyHexLength, 'Expected public key');
|
|
33
|
-
strictSame(result.uris,
|
|
28
|
+
strictSame(result.uris.length, 1, 'Expected node URI');
|
|
34
29
|
equal(!!result.version, true, 'Expected version');
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await waitForTermination({lnd});
|
|
31
|
+
await kill({});
|
|
39
32
|
|
|
40
33
|
return end();
|
|
41
34
|
});
|