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,3 +1,7 @@
|
|
|
1
|
+
const {ok} = 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');
|
|
2
6
|
const {createPsbt} = require('psbt');
|
|
3
7
|
const {combinePsbts} = require('psbt');
|
|
@@ -7,9 +11,7 @@ const {finalizePsbt} = require('psbt');
|
|
|
7
11
|
const {networks} = require('bitcoinjs-lib');
|
|
8
12
|
const {payments} = require('bitcoinjs-lib');
|
|
9
13
|
const {script} = require('bitcoinjs-lib');
|
|
10
|
-
const signPsbtWithKey = require('psbt').signPsbt;
|
|
11
14
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
12
|
-
const {test} = require('@alexbosworth/tap');
|
|
13
15
|
const tinysecp = require('tiny-secp256k1');
|
|
14
16
|
const {Transaction} = require('bitcoinjs-lib');
|
|
15
17
|
const {updatePsbt} = require('psbt');
|
|
@@ -23,13 +25,11 @@ const {getChannels} = require('./../../');
|
|
|
23
25
|
const {getPendingChannels} = require('./../../');
|
|
24
26
|
const {getPublicKey} = require('./../../');
|
|
25
27
|
const {getWalletInfo} = require('./../../');
|
|
26
|
-
const {getWalletVersion} = require('./../../');
|
|
27
28
|
const {prepareForChannelProposal} = require('./../../');
|
|
28
29
|
const {proposeChannel} = require('./../../');
|
|
29
30
|
const {signPsbt} = require('./../../');
|
|
30
31
|
const {signTransaction} = require('./../../');
|
|
31
32
|
|
|
32
|
-
const anchorFeatureBit = 23;
|
|
33
33
|
const capacity = 1e6;
|
|
34
34
|
const {ceil} = Math;
|
|
35
35
|
const cooperativeCloseDelay = 2016;
|
|
@@ -49,7 +49,7 @@ const temporaryFamily = 805;
|
|
|
49
49
|
const times = 300;
|
|
50
50
|
|
|
51
51
|
// Proposing a cooperative delay channel should open a cooperative delay chan
|
|
52
|
-
test(`Propose a channel with a coop delay`, async (
|
|
52
|
+
test(`Propose a channel with a coop delay`, async () => {
|
|
53
53
|
const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
|
|
54
54
|
|
|
55
55
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
@@ -59,20 +59,6 @@ test(`Propose a channel with a coop delay`, async ({end, equal, ok}) => {
|
|
|
59
59
|
const {lnd, generate} = control;
|
|
60
60
|
|
|
61
61
|
try {
|
|
62
|
-
const {version} = await getWalletVersion({lnd});
|
|
63
|
-
|
|
64
|
-
switch (version) {
|
|
65
|
-
case '0.11.0-beta':
|
|
66
|
-
case '0.11.1-beta':
|
|
67
|
-
// Exit early when funding PSBTs is not supported
|
|
68
|
-
await kill({});
|
|
69
|
-
|
|
70
|
-
return end();
|
|
71
|
-
|
|
72
|
-
default:
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
62
|
// Generate some funds for LND
|
|
77
63
|
await asyncRetry({times}, async () => {
|
|
78
64
|
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
@@ -99,8 +85,6 @@ test(`Propose a channel with a coop delay`, async ({end, equal, ok}) => {
|
|
|
99
85
|
|
|
100
86
|
const {features} = await getWalletInfo({lnd});
|
|
101
87
|
|
|
102
|
-
const isAnchors = !!features.find(n => n.bit === anchorFeatureBit);
|
|
103
|
-
|
|
104
88
|
// Derive a temporary key for control to pay into
|
|
105
89
|
const controlDerivedKey = await getPublicKey({
|
|
106
90
|
lnd,
|
|
@@ -358,35 +342,28 @@ test(`Propose a channel with a coop delay`, async ({end, equal, ok}) => {
|
|
|
358
342
|
|
|
359
343
|
const [incoming] = pendingTarget.pending_channels;
|
|
360
344
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
equal(incoming.received, 0, 'Nothing received');
|
|
384
|
-
equal(incoming.recovered_tokens, undefined, 'No recovery');
|
|
385
|
-
equal(incoming.remote_reserve, capacity * reserveRatio, 'Got reserve');
|
|
386
|
-
equal(incoming.sent, 0, 'Nothing sent');
|
|
387
|
-
equal(incoming.timelock_expiration, undefined, 'No timelock');
|
|
388
|
-
equal(incoming.transaction_id, fundingTxId, 'Funding tx id is correct');
|
|
389
|
-
equal(incoming.transaction_vout, fundingTxVout, 'Funding vout is correct');
|
|
345
|
+
strictEqual(incoming.remote_balance, 496530, 'Remote balance amount');
|
|
346
|
+
strictEqual(incoming.transaction_fee, 2810, 'Commit tx fee');
|
|
347
|
+
strictEqual(incoming.transaction_weight, 1116, 'Funding tx weight');
|
|
348
|
+
|
|
349
|
+
strictEqual(incoming.capacity, 1000000, 'Incoming capacity is defined');
|
|
350
|
+
strictEqual(incoming.close_transaction_id, undefined, 'Not a closing tx');
|
|
351
|
+
strictEqual(incoming.is_active, false, 'Not active yet');
|
|
352
|
+
strictEqual(incoming.is_closing, false, 'Channel is not closing');
|
|
353
|
+
strictEqual(incoming.is_opening, true, 'Channel is opening');
|
|
354
|
+
strictEqual(incoming.is_partner_initiated, true, 'Peer initiated channel');
|
|
355
|
+
strictEqual(incoming.local_balance, giveTokens, 'The incoming is split');
|
|
356
|
+
strictEqual(incoming.local_reserve, capacity * reserveRatio, 'Reserve');
|
|
357
|
+
strictEqual(incoming.partner_public_key, control.id, 'Peer key');
|
|
358
|
+
strictEqual(incoming.pending_balance, undefined, 'No tokens pending');
|
|
359
|
+
strictEqual(incoming.pending_payments, undefined, 'No HTLCs active');
|
|
360
|
+
strictEqual(incoming.received, 0, 'Nothing received');
|
|
361
|
+
strictEqual(incoming.recovered_tokens, undefined, 'No recovery');
|
|
362
|
+
strictEqual(incoming.remote_reserve, capacity * reserveRatio, 'Reserve');
|
|
363
|
+
strictEqual(incoming.sent, 0, 'Nothing sent');
|
|
364
|
+
strictEqual(incoming.timelock_expiration, undefined, 'No timelock');
|
|
365
|
+
strictEqual(incoming.transaction_id, fundingTxId, 'Funding tx id correct');
|
|
366
|
+
strictEqual(incoming.transaction_vout, fundingTxVout, 'Funding vout');
|
|
390
367
|
|
|
391
368
|
// Setup the combined signed PSBTs that fund the channel
|
|
392
369
|
const combinedTempPsbt = combinePsbts({
|
|
@@ -406,7 +383,7 @@ test(`Propose a channel with a coop delay`, async ({end, equal, ok}) => {
|
|
|
406
383
|
// Calculate the size of the tx
|
|
407
384
|
const txSize = fromHex(finalTempTx.transaction).virtualSize();
|
|
408
385
|
|
|
409
|
-
|
|
386
|
+
strictEqual(txSize <= fundingFee, true, 'Transaction size is not large');
|
|
410
387
|
|
|
411
388
|
// Broadcast the transaction to fund the control side
|
|
412
389
|
await broadcastChainTransaction({
|
|
@@ -445,68 +422,56 @@ test(`Propose a channel with a coop delay`, async ({end, equal, ok}) => {
|
|
|
445
422
|
|
|
446
423
|
const closeAddr = coopCloseAddress.address;
|
|
447
424
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
equal(controlChannel.is_closing, false, 'Channel is not closing');
|
|
463
|
-
equal(controlChannel.is_opening, false, 'Channel is already opened');
|
|
464
|
-
equal(controlChannel.is_partner_initiated, false, 'Control opened');
|
|
465
|
-
equal(controlChannel.is_private, true, 'Channel is private');
|
|
466
|
-
equal(controlChannel.local_balance, incoming.remote_balance, 'Control');
|
|
467
|
-
equal(controlChannel.local_csv, 144, 'Channel CSV');
|
|
425
|
+
strictEqual(controlChannel.commit_transaction_fee, 2810, 'Regular tx fee');
|
|
426
|
+
strictEqual(controlChannel.commit_transaction_weight, 1116, 'Regular tx');
|
|
427
|
+
|
|
428
|
+
strictEqual(controlChannel.capacity, capacity, 'Channel with capacity');
|
|
429
|
+
strictEqual(controlChannel.cooperative_close_address, closeAddr, 'Addr');
|
|
430
|
+
strictEqual(!!controlChannel.cooperative_close_delay_height, true, 'Thaw');
|
|
431
|
+
strictEqual(!!controlChannel.id, true, 'Got channel id');
|
|
432
|
+
strictEqual(controlChannel.is_active, true, 'Channel is active and ready');
|
|
433
|
+
strictEqual(controlChannel.is_closing, false, 'Channel is not closing');
|
|
434
|
+
strictEqual(controlChannel.is_opening, false, 'Channel is already opened');
|
|
435
|
+
strictEqual(controlChannel.is_partner_initiated, false, 'Control opened');
|
|
436
|
+
strictEqual(controlChannel.is_private, true, 'Channel is private');
|
|
437
|
+
strictEqual(controlChannel.local_balance, incoming.remote_balance, 'Toks');
|
|
438
|
+
strictEqual(controlChannel.local_csv, 144, 'Channel CSV');
|
|
468
439
|
ok(controlChannel.local_dust >= 354, 'Channel dust');
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
440
|
+
strictEqual(controlChannel.local_given, giveTokens, 'Gave Channel tokens');
|
|
441
|
+
strictEqual(controlChannel.local_max_htlcs, 483, 'Channel HTLCs max set');
|
|
442
|
+
strictEqual(controlChannel.partner_public_key, target.id, 'R-key');
|
|
443
|
+
strictEqual(controlChannel.transaction_id, fundingTxId, 'Funding tx id');
|
|
444
|
+
strictEqual(controlChannel.transaction_vout, fundingTxVout, 'Tx vout');
|
|
474
445
|
|
|
475
446
|
const targetChannels = await getChannels({lnd: target.lnd});
|
|
476
447
|
|
|
477
448
|
const [targetChannel] = targetChannels.channels;
|
|
478
449
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
equal(targetChannel.is_closing, false, 'Channel is not closing');
|
|
494
|
-
equal(targetChannel.is_opening, false, 'Channel is already opened');
|
|
495
|
-
equal(targetChannel.is_partner_initiated, true, 'Control opened');
|
|
496
|
-
equal(targetChannel.is_private, true, 'Channel is private');
|
|
497
|
-
equal(targetChannel.local_balance, giveTokens, 'Target tokens');
|
|
498
|
-
equal(targetChannel.local_csv, 144, 'Channel CSV');
|
|
450
|
+
strictEqual(targetChannel.commit_transaction_fee, 2810, 'Regular tx fee');
|
|
451
|
+
strictEqual(targetChannel.commit_transaction_weight, 1116, 'Regular size');
|
|
452
|
+
|
|
453
|
+
strictEqual(targetChannel.capacity, capacity, 'Channel with capacity');
|
|
454
|
+
strictEqual(targetChannel.cooperative_close_address, undefined, 'No addr');
|
|
455
|
+
strictEqual(!!targetChannel.cooperative_close_delay_height, true, 'Thaw');
|
|
456
|
+
strictEqual(!!targetChannel.id, true, 'Got channel id');
|
|
457
|
+
strictEqual(targetChannel.is_active, true, 'Channel is active and ready');
|
|
458
|
+
strictEqual(targetChannel.is_closing, false, 'Channel is not closing');
|
|
459
|
+
strictEqual(targetChannel.is_opening, false, 'Channel is already opened');
|
|
460
|
+
strictEqual(targetChannel.is_partner_initiated, true, 'Control opened');
|
|
461
|
+
strictEqual(targetChannel.is_private, true, 'Channel is private');
|
|
462
|
+
strictEqual(targetChannel.local_balance, giveTokens, 'Target tokens');
|
|
463
|
+
strictEqual(targetChannel.local_csv, 144, 'Channel CSV');
|
|
499
464
|
ok(targetChannel.local_dust >= 354, 'Channel dust');
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
465
|
+
strictEqual(targetChannel.local_given, 0, 'No tokens given');
|
|
466
|
+
strictEqual(targetChannel.local_max_htlcs, 483, 'Channel HTLCs max set');
|
|
467
|
+
strictEqual(targetChannel.partner_public_key, control.id, 'R-key');
|
|
468
|
+
strictEqual(targetChannel.transaction_id, fundingTxId, 'Funding tx id');
|
|
469
|
+
strictEqual(targetChannel.transaction_vout, fundingTxVout, 'Tx vout');
|
|
505
470
|
} catch (err) {
|
|
506
|
-
|
|
507
|
-
} finally {
|
|
508
|
-
await kill({});
|
|
471
|
+
strictEqual(err, null, 'Expected no error');
|
|
509
472
|
}
|
|
510
473
|
|
|
511
|
-
|
|
474
|
+
await kill({});
|
|
475
|
+
|
|
476
|
+
return;
|
|
512
477
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
|
-
const {
|
|
5
|
+
const {setupChannel} = require('ln-docker-daemons');
|
|
3
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
4
|
-
const {test} = require('@alexbosworth/tap');
|
|
5
7
|
|
|
6
|
-
const {createCluster} = require('./../macros');
|
|
7
8
|
const {createInvoice} = require('./../../');
|
|
8
9
|
const {getChannel} = require('./../../');
|
|
9
10
|
const {getChannelBalance} = require('./../../');
|
|
10
11
|
const {getChannels} = require('./../../');
|
|
11
12
|
const {getHeight} = require('./../../');
|
|
12
|
-
const {getPendingChannels} = require('./../../');
|
|
13
|
-
const {getWalletInfo} = require('./../../');
|
|
14
13
|
const {pay} = require('./../../');
|
|
15
14
|
const {routeFromChannels} = require('./../../');
|
|
16
|
-
const {setupChannel} = require('./../macros');
|
|
17
15
|
|
|
18
16
|
const channelCapacityTokens = 1e6;
|
|
19
17
|
const {floor} = Math;
|
|
@@ -25,7 +23,7 @@ const times = 100;
|
|
|
25
23
|
const tokens = 1e3;
|
|
26
24
|
|
|
27
25
|
// Pushing funds via a fee bump should result in the destination getting funds
|
|
28
|
-
test('Push funds', async (
|
|
26
|
+
test('Push funds', async () => {
|
|
29
27
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
30
28
|
|
|
31
29
|
const [control, target] = nodes;
|
|
@@ -35,7 +33,7 @@ test('Push funds', async ({end, equal}) => {
|
|
|
35
33
|
await setupChannel({
|
|
36
34
|
lnd,
|
|
37
35
|
generate: control.generate,
|
|
38
|
-
|
|
36
|
+
give_tokens: floor(channelCapacityTokens * reserveRatio),
|
|
39
37
|
to: target,
|
|
40
38
|
});
|
|
41
39
|
|
|
@@ -75,10 +73,10 @@ test('Push funds', async ({end, equal}) => {
|
|
|
75
73
|
throw new Error('ExpectedBalanceToBeAdjustedAsExpected');
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
strictEqual(initialBalance - finalBalance, tokens, 'Funds pushed to peer');
|
|
79
77
|
});
|
|
80
78
|
|
|
81
79
|
await kill({});
|
|
82
80
|
|
|
83
|
-
return
|
|
81
|
+
return;
|
|
84
82
|
});
|
|
@@ -1,58 +1,70 @@
|
|
|
1
|
+
const {equal} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
5
|
+
const {setupChannel} = require('ln-docker-daemons');
|
|
1
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
|
-
const {test} = require('@alexbosworth/tap');
|
|
3
7
|
|
|
4
|
-
const {createCluster} = require('./../macros');
|
|
5
8
|
const {createInvoice} = require('./../../');
|
|
6
|
-
const {
|
|
9
|
+
const {deleteForwardingReputations} = require('./../../');
|
|
7
10
|
const {getChannels} = require('./../../');
|
|
8
11
|
const {getRouteToDestination} = require('./../../');
|
|
9
|
-
const {openChannel} = require('./../../');
|
|
10
12
|
const {pay} = require('./../../');
|
|
11
|
-
const {setupChannel} = require('./../macros');
|
|
12
|
-
const {waitForChannel} = require('./../macros');
|
|
13
|
-
const {waitForPendingChannel} = require('./../macros');
|
|
14
13
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const defaultFee = 1e3;
|
|
14
|
+
const give = 1e5;
|
|
15
|
+
const interval = 10;
|
|
18
16
|
const size = 2;
|
|
19
|
-
const
|
|
17
|
+
const times = 2000;
|
|
18
|
+
const tokens = 100;
|
|
20
19
|
|
|
21
20
|
// Rebalancing channels should result in balanced channels
|
|
22
|
-
test('Rebalance', async (
|
|
21
|
+
test('Rebalance', async () => {
|
|
23
22
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
24
23
|
|
|
25
24
|
const [control, target] = nodes;
|
|
26
25
|
|
|
27
26
|
const {generate, lnd} = control;
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
try {
|
|
29
|
+
await setupChannel({generate, lnd, give_tokens: give, to: target});
|
|
30
|
+
|
|
31
|
+
await setupChannel({
|
|
32
|
+
generate: target.generate,
|
|
33
|
+
give_tokens: give,
|
|
34
|
+
lnd: target.lnd,
|
|
35
|
+
to: control,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const invoice = await createInvoice({lnd, tokens});
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
give: 1e5,
|
|
34
|
-
lnd: target.lnd,
|
|
35
|
-
to: control,
|
|
36
|
-
});
|
|
40
|
+
await asyncRetry({interval, times}, async () => {
|
|
41
|
+
const [inChanId] = (await getChannels({lnd})).channels.map(({id}) => id);
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
await generate({});
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
await deleteForwardingReputations({lnd});
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const {route} = await getRouteToDestination({
|
|
48
|
+
lnd,
|
|
49
|
+
tokens,
|
|
50
|
+
destination: control.id,
|
|
51
|
+
outgoing_channel: inChanId,
|
|
52
|
+
payment: invoice.payment,
|
|
53
|
+
total_mtokens: !!invoice.payment ? invoice.mtokens : undefined,
|
|
54
|
+
});
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
const selfPay = await pay({
|
|
57
|
+
lnd,
|
|
58
|
+
path: {id: invoice.id, routes: [route]},
|
|
59
|
+
});
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
equal(selfPay.secret, invoice.secret, 'Payment made to self');
|
|
62
|
+
});
|
|
63
|
+
} catch (err) {
|
|
64
|
+
equal(err, null, 'Expected no error')
|
|
65
|
+
}
|
|
54
66
|
|
|
55
67
|
await kill({});
|
|
56
68
|
|
|
57
|
-
return
|
|
69
|
+
return;
|
|
58
70
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
5
|
const {getPortPromise: getPort} = require('portfinder');
|
|
3
6
|
const {setupChannel} = require('ln-docker-daemons');
|
|
4
7
|
const {spawnLightningDocker} = require('ln-docker-daemons');
|
|
5
|
-
const {test} = require('@alexbosworth/tap');
|
|
6
8
|
|
|
7
9
|
const {addPeer} = require('./../../');
|
|
8
10
|
const {authenticatedLndGrpc} = require('./../../');
|
|
@@ -23,7 +25,7 @@ const seed = 'about rabbit ozone hope jaguar quit scare twenty punch crisp consi
|
|
|
23
25
|
const times = 3000;
|
|
24
26
|
|
|
25
27
|
// Using a channel backup should recover funds
|
|
26
|
-
test(`Recover funds from channel`, async (
|
|
28
|
+
test(`Recover funds from channel`, async () => {
|
|
27
29
|
const control = await asyncRetry({interval, times}, async () => {
|
|
28
30
|
return await spawnLightningDocker({
|
|
29
31
|
seed,
|
|
@@ -187,19 +189,19 @@ test(`Recover funds from channel`, async ({end, equal}) => {
|
|
|
187
189
|
|
|
188
190
|
const [chan] = (await getPendingChannels({lnd})).pending_channels;
|
|
189
191
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
strictEqual(!!chan.close_transaction_id, true, 'Close transaction id');
|
|
193
|
+
strictEqual(chan.is_active, false, 'Chan no longer active');
|
|
194
|
+
strictEqual(chan.is_closing, true, 'Channel is closing');
|
|
195
|
+
strictEqual(chan.is_opening, false, 'Channel closing');
|
|
196
|
+
strictEqual(chan.local_balance, giftTokens, 'Funds are being restored');
|
|
197
|
+
strictEqual(chan.partner_public_key, targetId, 'Peer key');
|
|
198
|
+
strictEqual(chan.transaction_id, channelOpen.transaction_id, 'Tx id');
|
|
199
|
+
strictEqual(chan.transaction_vout, channelOpen.transaction_vout, 'Vout');
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
await clone.kill({});
|
|
201
203
|
|
|
202
204
|
await target.kill({});
|
|
203
205
|
|
|
204
|
-
return
|
|
206
|
+
return;
|
|
205
207
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
const {strictEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
1
4
|
const asyncRetry = require('async/retry');
|
|
2
5
|
const {getPortPromise: getPort} = require('portfinder');
|
|
3
6
|
const {setupChannel} = require('ln-docker-daemons');
|
|
4
7
|
const {spawnLightningDocker} = require('ln-docker-daemons');
|
|
5
|
-
const {test} = require('@alexbosworth/tap');
|
|
6
8
|
|
|
7
9
|
const {addPeer} = require('./../../');
|
|
8
10
|
const {authenticatedLndGrpc} = require('./../../');
|
|
@@ -23,7 +25,7 @@ const seed = 'about rabbit ozone hope jaguar quit scare twenty punch crisp consi
|
|
|
23
25
|
const times = 3000;
|
|
24
26
|
|
|
25
27
|
// Using a channels backup should recover funds
|
|
26
|
-
test(`Recover funds from channels`, async (
|
|
28
|
+
test(`Recover funds from channels`, async () => {
|
|
27
29
|
const control = await asyncRetry({interval, times}, async () => {
|
|
28
30
|
return await spawnLightningDocker({
|
|
29
31
|
seed,
|
|
@@ -183,19 +185,19 @@ test(`Recover funds from channels`, async ({end, equal}) => {
|
|
|
183
185
|
|
|
184
186
|
const [chan] = (await getPendingChannels({lnd})).pending_channels;
|
|
185
187
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
strictEqual(!!chan.close_transaction_id, true, 'Close transaction id');
|
|
189
|
+
strictEqual(chan.is_active, false, 'Chan no longer active');
|
|
190
|
+
strictEqual(chan.is_closing, true, 'Channel is closing');
|
|
191
|
+
strictEqual(chan.is_opening, false, 'Channel closing');
|
|
192
|
+
strictEqual(chan.local_balance, giftTokens, 'Funds are being restored');
|
|
193
|
+
strictEqual(chan.partner_public_key, targetId, 'Peer key');
|
|
194
|
+
strictEqual(chan.transaction_id, channelOpen.transaction_id, 'Chan tx id');
|
|
195
|
+
strictEqual(chan.transaction_vout, channelOpen.transaction_vout, 'Vout');
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
await clone.kill({});
|
|
197
199
|
|
|
198
200
|
await target.kill({});
|
|
199
201
|
|
|
200
|
-
return
|
|
202
|
+
return;
|
|
201
203
|
});
|
|
@@ -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 {getPeers} = require('./../../');
|
|
@@ -11,7 +13,7 @@ const size = 2;
|
|
|
11
13
|
const times = 2000;
|
|
12
14
|
|
|
13
15
|
// Removing peers should result in a removed peer
|
|
14
|
-
test(`Remove a peer`, async (
|
|
16
|
+
test(`Remove a peer`, async () => {
|
|
15
17
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
16
18
|
|
|
17
19
|
const [{id, lnd}, target] = nodes;
|
|
@@ -25,7 +27,7 @@ test(`Remove a peer`, async ({end, equal}) => {
|
|
|
25
27
|
|
|
26
28
|
const [targetPeer] = peers;
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
strictEqual(targetPeer.public_key, target.id, 'Peer is added');
|
|
29
31
|
|
|
30
32
|
await removePeer({lnd, public_key: targetPeer.public_key});
|
|
31
33
|
|
|
@@ -36,13 +38,13 @@ test(`Remove a peer`, async ({end, equal}) => {
|
|
|
36
38
|
throw new Error('ExpectedPeerRemoved');
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
strictEqual(postRemovalPeers.peers.length, [].length, 'Peer is removed');
|
|
40
42
|
});
|
|
41
43
|
} catch (err) {
|
|
42
|
-
|
|
44
|
+
strictEqual(err, null, 'Expected no error');
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
await kill({});
|
|
46
48
|
|
|
47
|
-
return
|
|
49
|
+
return;
|
|
48
50
|
});
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
const {rejects} = require('node:assert').strict;
|
|
2
|
+
const {strictEqual} = require('node:assert').strict;
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
|
|
1
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
|
-
const {test} = require('@alexbosworth/tap');
|
|
3
6
|
|
|
4
7
|
const {createChainAddress} = require('./../../');
|
|
5
|
-
const {delay} = require('./../macros');
|
|
6
8
|
const {grantAccess} = require('./../../');
|
|
7
9
|
const {restrictMacaroon} = require('./../../');
|
|
8
10
|
|
|
11
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
9
12
|
const format = 'p2wpkh';
|
|
10
13
|
const ip = '127.0.0.1';
|
|
11
14
|
const methods = ['createChainAddress'];
|
|
12
15
|
const wrongIp = '203.0.113.0';
|
|
13
16
|
|
|
14
17
|
// Restricting the macaroon credentials should result in access limitation
|
|
15
|
-
test(`Restricted macaroons restrict access`, async (
|
|
18
|
+
test(`Restricted macaroons restrict access`, async () => {
|
|
16
19
|
const [{lnd, kill, rpc}] = (await spawnLightningCluster({})).nodes;
|
|
17
20
|
|
|
18
21
|
try {
|
|
@@ -84,10 +87,10 @@ test(`Restricted macaroons restrict access`, async ({end, equal, rejects}) => {
|
|
|
84
87
|
);
|
|
85
88
|
}
|
|
86
89
|
} catch (err) {
|
|
87
|
-
|
|
90
|
+
strictEqual(err, null, 'Expected no error restricting macaroon');
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
await kill({});
|
|
91
94
|
|
|
92
|
-
return
|
|
95
|
+
return;
|
|
93
96
|
});
|