ln-service 52.15.0 → 53.0.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 +17 -0
- package/README.md +112 -10
- 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 +36 -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 -71
- 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 +96 -38
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 53.0.1
|
|
4
|
+
|
|
5
|
+
- Removed support for determining the type of channel to support LND 0.14.0.
|
|
6
|
+
|
|
7
|
+
- `createChainAddress`: Make address format optional and add p2wpkh as default
|
|
8
|
+
- `sendToChainOutputScripts`: Fix specification of `fee_tokens_per_vbyte`
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
|
|
12
|
+
- `getChannels`, `getPendingChannels`, `subscribeToChannels`: Remove
|
|
13
|
+
attributes `is_anchor`, `is_static_remote_key`, `is_variable_remote_key`.
|
|
14
|
+
|
|
15
|
+
## 52.16.1
|
|
16
|
+
|
|
17
|
+
- `subscribeToPayViaDetails`, `subscribeToPayViaRequest`: Add `paying`, and
|
|
18
|
+
`routing_failure` events to follow in-flight attempts and encountered routing failures
|
|
19
|
+
|
|
3
20
|
## 52.15.0
|
|
4
21
|
|
|
5
22
|
- `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ through npm.
|
|
|
9
9
|
|
|
10
10
|
Supported LND versions:
|
|
11
11
|
|
|
12
|
+
- v0.14.0-beta
|
|
12
13
|
- v0.13.0-beta to v0.13.4-beta
|
|
13
14
|
- v0.12.0-beta to v0.12.1-beta
|
|
14
15
|
- v0.11.0-beta to v0.11.1-beta
|
|
@@ -490,7 +491,7 @@ Create a new receive address.
|
|
|
490
491
|
Requires `address:write` permission
|
|
491
492
|
|
|
492
493
|
{
|
|
493
|
-
format: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
|
|
494
|
+
[format]: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
|
|
494
495
|
[is_unused]: <Get As-Yet Unused Address Bool>
|
|
495
496
|
lnd: <Authenticated LND API Object>
|
|
496
497
|
}
|
|
@@ -1452,13 +1453,10 @@ Requires `offchain:read` permission
|
|
|
1452
1453
|
[cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
|
|
1453
1454
|
id: <Standard Format Channel Id String>
|
|
1454
1455
|
is_active: <Channel Active Bool>
|
|
1455
|
-
is_anchor: <Channel Supports Anchor Outputs Bool>
|
|
1456
1456
|
is_closing: <Channel Is Closing Bool>
|
|
1457
1457
|
is_opening: <Channel Is Opening Bool>
|
|
1458
1458
|
is_partner_initiated: <Channel Partner Opened Channel Bool>
|
|
1459
1459
|
is_private: <Channel Is Private Bool>
|
|
1460
|
-
is_static_remote_key: <Remote Key Is Static Bool>
|
|
1461
|
-
is_variable_remote_key: <Remote Key Is Variable Bool>
|
|
1462
1460
|
local_balance: <Local Balance Tokens Number>
|
|
1463
1461
|
[local_csv]: <Local CSV Blocks Delay Number>
|
|
1464
1462
|
[local_dust]: <Remote Non-Enforceable Amount Tokens Number>
|
|
@@ -2535,7 +2533,6 @@ Requires `offchain:read` permission
|
|
|
2535
2533
|
pending_channels: [{
|
|
2536
2534
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
2537
2535
|
is_active: <Channel Is Active Bool>
|
|
2538
|
-
is_anchor: <Channel Is Anchor Channel Type Bool>
|
|
2539
2536
|
is_closing: <Channel Is Closing Bool>
|
|
2540
2537
|
is_opening: <Channel Is Opening Bool>
|
|
2541
2538
|
[is_partner_initiated]: <Channel Partner Initiated Channel Bool>
|
|
@@ -4656,13 +4653,10 @@ Requires `offchain:read` permission
|
|
|
4656
4653
|
[cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
|
|
4657
4654
|
id: <Standard Format Channel Id String>
|
|
4658
4655
|
is_active: <Channel Active Bool>
|
|
4659
|
-
is_anchor: <Channel Supports Anchor Outputs Bool>
|
|
4660
4656
|
is_closing: <Channel Is Closing Bool>
|
|
4661
4657
|
is_opening: <Channel Is Opening Bool>
|
|
4662
4658
|
is_partner_initiated: <Channel Partner Opened Channel Bool>
|
|
4663
4659
|
is_private: <Channel Is Private Bool>
|
|
4664
|
-
is_static_remote_key: <Remote Key Is Static Bool>
|
|
4665
|
-
is_variable_remote_key: <Remote Key Is Variable Bool>
|
|
4666
4660
|
local_balance: <Local Balance Tokens Number>
|
|
4667
4661
|
[local_given]: <Local Initially Pushed Tokens Number>
|
|
4668
4662
|
local_reserve: <Local Reserved Tokens Number>
|
|
@@ -5360,7 +5354,61 @@ Requires `offchain:write` permission
|
|
|
5360
5354
|
}
|
|
5361
5355
|
|
|
5362
5356
|
@event 'paying'
|
|
5363
|
-
{
|
|
5357
|
+
{
|
|
5358
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
5359
|
+
destination: <Payment Destination Hex String>
|
|
5360
|
+
id: <Payment Hash Hex String>
|
|
5361
|
+
mtokens: <Total Millitokens Pending String>
|
|
5362
|
+
paths: [{
|
|
5363
|
+
fee: <Total Fee Tokens Pending Number>
|
|
5364
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
5365
|
+
hops: [{
|
|
5366
|
+
channel: <Standard Format Channel Id String>
|
|
5367
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
5368
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
5369
|
+
fee_mtokens: <Fee Millitokens String>
|
|
5370
|
+
forward: <Forward Tokens Number>
|
|
5371
|
+
forward_mtokens: <Forward Millitokens String>
|
|
5372
|
+
public_key: <Public Key Hex String>
|
|
5373
|
+
timeout: <Timeout Block Height Number>
|
|
5374
|
+
}]
|
|
5375
|
+
mtokens: <Total Millitokens Pending String>
|
|
5376
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
5377
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
5378
|
+
timeout: <Expiration Block Height Number>
|
|
5379
|
+
}]
|
|
5380
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
5381
|
+
[timeout]: <Expiration Block Height Number>
|
|
5382
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
5383
|
+
}
|
|
5384
|
+
|
|
5385
|
+
@event 'routing_failure'
|
|
5386
|
+
{
|
|
5387
|
+
[channel]: <Standard Format Channel Id String>
|
|
5388
|
+
index: <Failure Index Number>
|
|
5389
|
+
[mtokens]: <Millitokens String>
|
|
5390
|
+
[public_key]: <Public Key Hex String>
|
|
5391
|
+
reason: <Failure Reason String>
|
|
5392
|
+
route: {
|
|
5393
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
5394
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
5395
|
+
hops: [{
|
|
5396
|
+
channel: <Standard Format Channel Id String>
|
|
5397
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
5398
|
+
fee: <Fee Number>
|
|
5399
|
+
fee_mtokens: <Fee Millitokens String>
|
|
5400
|
+
forward: <Forward Tokens Number>
|
|
5401
|
+
forward_mtokens: <Forward Millitokens String>
|
|
5402
|
+
public_key: <Public Key Hex String>
|
|
5403
|
+
timeout: <Timeout Block Height Number>
|
|
5404
|
+
}]
|
|
5405
|
+
mtokens: <Total Route Millitokens String>
|
|
5406
|
+
[payment]: <Payment Identifier Hex String>
|
|
5407
|
+
timeout: <Expiration Block Height Number>
|
|
5408
|
+
tokens: <Total Route Tokens Number>
|
|
5409
|
+
[total_mtokens]: <Total Millitokens String>
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5364
5412
|
|
|
5365
5413
|
Example:
|
|
5366
5414
|
|
|
@@ -5457,7 +5505,61 @@ Requires `offchain:write` permission
|
|
|
5457
5505
|
}
|
|
5458
5506
|
|
|
5459
5507
|
@event 'paying'
|
|
5460
|
-
{
|
|
5508
|
+
{
|
|
5509
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
5510
|
+
destination: <Payment Destination Hex String>
|
|
5511
|
+
id: <Payment Hash Hex String>
|
|
5512
|
+
mtokens: <Total Millitokens Pending String>
|
|
5513
|
+
paths: [{
|
|
5514
|
+
fee: <Total Fee Tokens Pending Number>
|
|
5515
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
5516
|
+
hops: [{
|
|
5517
|
+
channel: <Standard Format Channel Id String>
|
|
5518
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
5519
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
5520
|
+
fee_mtokens: <Fee Millitokens String>
|
|
5521
|
+
forward: <Forward Tokens Number>
|
|
5522
|
+
forward_mtokens: <Forward Millitokens String>
|
|
5523
|
+
public_key: <Public Key Hex String>
|
|
5524
|
+
timeout: <Timeout Block Height Number>
|
|
5525
|
+
}]
|
|
5526
|
+
mtokens: <Total Millitokens Pending String>
|
|
5527
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
5528
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
5529
|
+
timeout: <Expiration Block Height Number>
|
|
5530
|
+
}]
|
|
5531
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
5532
|
+
[timeout]: <Expiration Block Height Number>
|
|
5533
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
5534
|
+
}
|
|
5535
|
+
|
|
5536
|
+
@event 'routing_failure'
|
|
5537
|
+
{
|
|
5538
|
+
[channel]: <Standard Format Channel Id String>
|
|
5539
|
+
index: <Failure Index Number>
|
|
5540
|
+
[mtokens]: <Millitokens String>
|
|
5541
|
+
[public_key]: <Public Key Hex String>
|
|
5542
|
+
reason: <Failure Reason String>
|
|
5543
|
+
route: {
|
|
5544
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
5545
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
5546
|
+
hops: [{
|
|
5547
|
+
channel: <Standard Format Channel Id String>
|
|
5548
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
5549
|
+
fee: <Fee Number>
|
|
5550
|
+
fee_mtokens: <Fee Millitokens String>
|
|
5551
|
+
forward: <Forward Tokens Number>
|
|
5552
|
+
forward_mtokens: <Forward Millitokens String>
|
|
5553
|
+
public_key: <Public Key Hex String>
|
|
5554
|
+
timeout: <Timeout Block Height Number>
|
|
5555
|
+
}]
|
|
5556
|
+
mtokens: <Total Route Millitokens String>
|
|
5557
|
+
[payment]: <Payment Identifier Hex String>
|
|
5558
|
+
timeout: <Expiration Block Height Number>
|
|
5559
|
+
tokens: <Total Route Tokens Number>
|
|
5560
|
+
[total_mtokens]: <Total Millitokens String>
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5461
5563
|
|
|
5462
5564
|
Example:
|
|
5463
5565
|
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"bolt07": "1.7.4",
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.17.1",
|
|
13
|
-
"invoices": "2.0.
|
|
14
|
-
"lightning": "
|
|
13
|
+
"invoices": "2.0.2",
|
|
14
|
+
"lightning": "5.0.1",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.2.3"
|
|
@@ -23,8 +23,10 @@
|
|
|
23
23
|
"async": "3.2.2",
|
|
24
24
|
"asyncjs-util": "1.2.7",
|
|
25
25
|
"bip66": "1.1.5",
|
|
26
|
-
"bitcoinjs-lib": "
|
|
26
|
+
"bitcoinjs-lib": "6.0.0",
|
|
27
27
|
"bn.js": "5.2.0",
|
|
28
|
+
"ecpair": "1.0.1",
|
|
29
|
+
"ln-docker-daemons": "2.1.0",
|
|
28
30
|
"portfinder": "1.0.28",
|
|
29
31
|
"psbt": "1.1.10",
|
|
30
32
|
"rimraf": "3.0.2",
|
|
@@ -50,16 +52,7 @@
|
|
|
50
52
|
"url": "https://github.com/alexbosworth/ln-service.git"
|
|
51
53
|
},
|
|
52
54
|
"scripts": {
|
|
53
|
-
"
|
|
54
|
-
"chain-integration-tests": "tap --no-coverage -t 90 test/chainrpc-integration/*.js",
|
|
55
|
-
"integration-tests": "tap --no-coverage -t 120 -j 1 test/grpc-integration/*.js test/integration/*.js",
|
|
56
|
-
"invoices-integration-tests": "tap --no-coverage -t 90 test/invoicesrpc-integration/*.js",
|
|
57
|
-
"router-integration-tests": "tap --no-coverage -j 2 -t 90 test/routerrpc-integration/*.js",
|
|
58
|
-
"signer-integration-tests": "tap --no-coverage test/signerrpc-integration/*.js",
|
|
59
|
-
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -j 1 -t 150 test/autopilotrpc-integration/*.js test/chainrpc-integration/*.js test/integration/*.js test/invoicesrpc-integration/*.js test/routerrpc-integration/*.js test/routers-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js",
|
|
60
|
-
"tower_client-integration-tests": "tap --no-coverage test/tower_clientrpc-integration/*.js",
|
|
61
|
-
"tower_server-integration-tests": "tap --no-coverage test/tower_serverrpc-integration/*.js",
|
|
62
|
-
"wallet-integration-tests": "tap --no-coverage test/walletrpc-integration/*.js"
|
|
55
|
+
"test": "echo $DOCKER_LND_VERSION && tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 200 test/autopilotrpc-integration/*.js test/chainrpc-integration/*.js test/integration/*.js test/invoicesrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
|
|
63
56
|
},
|
|
64
|
-
"version": "
|
|
57
|
+
"version": "53.0.1"
|
|
65
58
|
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {addPeer} = require('./../../');
|
|
4
|
-
const {createChainAddress} = require('./../../');
|
|
5
|
-
const {createCluster} = require('./../macros');
|
|
6
5
|
const {delay} = require('./../macros');
|
|
7
|
-
const {generateBlocks} = require('./../macros');
|
|
8
|
-
const {getNetworkGraph} = require('./../../');
|
|
9
6
|
const {getAutopilot} = require('./../../');
|
|
10
|
-
const {openChannel} = require('./../../');
|
|
11
7
|
const {setAutopilot} = require('./../../');
|
|
12
8
|
const {setupChannel} = require('./../macros');
|
|
13
|
-
const {spawnLnd} = require('./../macros');
|
|
14
|
-
const {waitForChannel} = require('./../macros');
|
|
15
|
-
const {waitForPendingChannel} = require('./../macros');
|
|
16
9
|
|
|
17
10
|
const avg = array => array.reduce((a, b) => a + b) / array.length;
|
|
18
|
-
const channelCapacityTokens = 1e6;
|
|
19
11
|
const confirmationCount = 6;
|
|
20
|
-
const defaultFee = 1e3;
|
|
21
12
|
const maxScore = 1e8;
|
|
22
13
|
const score = 50000000;
|
|
14
|
+
const size = 2;
|
|
23
15
|
|
|
24
16
|
// Adjusting autopilot should result in changed autopilot status
|
|
25
17
|
test(`Autopilot`, async ({end, equal}) => {
|
|
26
|
-
const
|
|
18
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
27
19
|
|
|
28
|
-
const
|
|
20
|
+
const [control, target] = nodes;
|
|
21
|
+
|
|
22
|
+
const cluster = {control, target};
|
|
29
23
|
|
|
30
24
|
const {lnd} = cluster.control;
|
|
31
25
|
|
|
32
|
-
await setupChannel({lnd, generate:
|
|
26
|
+
await setupChannel({lnd, generate: control.generate, to: cluster.target});
|
|
33
27
|
|
|
34
28
|
equal((await getAutopilot({lnd})).is_enabled, false, 'Autopilot starts off');
|
|
35
29
|
|
|
@@ -41,7 +35,7 @@ test(`Autopilot`, async ({end, equal}) => {
|
|
|
41
35
|
|
|
42
36
|
await addPeer({
|
|
43
37
|
lnd,
|
|
44
|
-
public_key: cluster.target.
|
|
38
|
+
public_key: cluster.target.id,
|
|
45
39
|
socket: cluster.target.socket,
|
|
46
40
|
});
|
|
47
41
|
|
|
@@ -51,7 +45,7 @@ test(`Autopilot`, async ({end, equal}) => {
|
|
|
51
45
|
|
|
52
46
|
equal((await getAutopilot({lnd})).is_enabled, false, 'Autopilot turned off');
|
|
53
47
|
|
|
54
|
-
const pubKey = cluster.control.
|
|
48
|
+
const pubKey = cluster.control.id;
|
|
55
49
|
|
|
56
50
|
await setAutopilot({
|
|
57
51
|
lnd,
|
|
@@ -1,24 +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
|
-
const {generateBlocks} = require('./../macros');
|
|
5
5
|
const {getHeight} = require('./../../');
|
|
6
|
-
const {spawnLnd} = require('./../macros');
|
|
7
|
-
const {waitForTermination} = require('./../macros');
|
|
8
6
|
|
|
9
7
|
const confirmationCount = 6;
|
|
8
|
+
const times = 100;
|
|
10
9
|
|
|
11
10
|
// Get height should return height
|
|
12
11
|
test(`Get height`, async ({end, equal, fail}) => {
|
|
13
|
-
const
|
|
12
|
+
const {nodes} = await spawnLightningCluster({});
|
|
14
13
|
|
|
15
|
-
const {generate, kill, lnd} =
|
|
14
|
+
const [{chain, generate, kill, lnd}] = nodes;
|
|
16
15
|
|
|
17
16
|
const startHeight = (await getHeight({lnd})).current_block_height;
|
|
18
17
|
|
|
19
|
-
await
|
|
18
|
+
await asyncRetry({times}, async () => {
|
|
19
|
+
await generate({});
|
|
20
20
|
|
|
21
|
-
await asyncRetry({}, async () => {
|
|
22
21
|
const endHeight = (await getHeight({lnd})).current_block_height;
|
|
23
22
|
|
|
24
23
|
if (endHeight - startHeight < confirmationCount) {
|
|
@@ -30,9 +29,7 @@ test(`Get height`, async ({end, equal, fail}) => {
|
|
|
30
29
|
return;
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
kill();
|
|
34
|
-
|
|
35
|
-
await waitForTermination({lnd});
|
|
32
|
+
await kill({});
|
|
36
33
|
|
|
37
34
|
return end();
|
|
38
35
|
});
|
|
@@ -1,63 +1,84 @@
|
|
|
1
1
|
const EventEmitter = require('events');
|
|
2
|
+
const {once} = require('events');
|
|
2
3
|
|
|
3
4
|
const asyncRetry = require('async/retry');
|
|
5
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
4
6
|
const {test} = require('@alexbosworth/tap');
|
|
5
7
|
|
|
8
|
+
const {createChainAddress} = require('./../../');
|
|
6
9
|
const {delay} = require('./../macros');
|
|
7
10
|
const {generateBlocks} = require('./../macros');
|
|
8
11
|
const {getHeight} = require('./../../');
|
|
12
|
+
const {getChainBalance} = require('./../../');
|
|
9
13
|
const {spawnLnd} = require('./../macros');
|
|
10
14
|
const {subscribeToBlocks} = require('./../../');
|
|
11
15
|
const {waitForTermination} = require('./../macros');
|
|
12
16
|
|
|
13
17
|
const confirmationCount = 6;
|
|
14
|
-
const interval =
|
|
15
|
-
const
|
|
18
|
+
const interval = 1;
|
|
19
|
+
const race = promises => Promise.race(promises);
|
|
20
|
+
const times = 4000;
|
|
16
21
|
|
|
17
22
|
// Subscribers to blocks should receive block notifications
|
|
18
23
|
test(`Subscribe to blocks`, async ({end, equal, fail}) => {
|
|
19
|
-
const spawned = await spawnLnd({});
|
|
20
|
-
|
|
21
|
-
const {kill, lnd} = spawned;
|
|
22
|
-
|
|
23
24
|
const blocks = [];
|
|
25
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
26
|
+
|
|
27
|
+
const [{generate, lnd}] = nodes;
|
|
24
28
|
|
|
25
|
-
// Wait for chainrpc to be active
|
|
26
29
|
await asyncRetry({interval, times}, async () => {
|
|
27
|
-
const
|
|
30
|
+
const subBlocks = subscribeToBlocks({lnd});
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
const [event] = await race([
|
|
33
|
+
once(subBlocks, 'block'),
|
|
34
|
+
once(subBlocks, 'error'),
|
|
35
|
+
]);
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
if (!event.height) {
|
|
38
|
+
throw new Error('ExpectedBlockEvent');
|
|
39
|
+
}
|
|
34
40
|
});
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
try {
|
|
43
|
+
// Wait for chainrpc to be active
|
|
44
|
+
await asyncRetry({interval, times}, async () => {
|
|
45
|
+
if (!!(await getChainBalance({lnd})).chain_balance) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
sub.on('error', err => {});
|
|
49
|
+
await generate({});
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
await getHeight({lnd});
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
throw new Error('ExpectedAdditionalBlocks');
|
|
47
|
-
}
|
|
48
|
-
});
|
|
53
|
+
throw new Error('ExpectedChainBalance');
|
|
54
|
+
});
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const sub = subscribeToBlocks({lnd});
|
|
57
|
+
const startHeight = (await getHeight({lnd})).current_block_height;
|
|
58
|
+
|
|
59
|
+
sub.on('block', data => blocks.push(data));
|
|
60
|
+
sub.on('error', err => {});
|
|
61
|
+
|
|
62
|
+
const {address} = await createChainAddress({lnd});
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
await asyncRetry({interval, times}, async () => {
|
|
65
|
+
await generate({});
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
if (blocks.length < confirmationCount) {
|
|
68
|
+
throw new Error('ExpectedAdditionalBlocks');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
blocks.forEach(({height, id}) => {
|
|
73
|
+
equal(!!height, true, 'Got expected block height');
|
|
74
|
+
equal(id.length, 64, 'Got expected block hash length');
|
|
75
|
+
return;
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
equal(err, null, 'Expected no error');
|
|
79
|
+
} finally {
|
|
80
|
+
await kill({});
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
return end();
|
|
83
|
+
}
|
|
63
84
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
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 {chainSendTransaction} = require('./../macros');
|
|
5
6
|
const {createChainAddress} = require('./../../');
|
|
6
7
|
const {delay} = require('./../macros');
|
|
7
8
|
const {generateBlocks} = require('./../macros');
|
|
9
|
+
const {getChainBalance} = require('./../../');
|
|
10
|
+
const {getChainTransactions} = require('./../../');
|
|
8
11
|
const {getHeight} = require('./../../');
|
|
9
12
|
const {mineTransaction} = require('./../macros');
|
|
13
|
+
const {sendToChainAddress} = require('./../../');
|
|
10
14
|
const {spawnLnd} = require('./../macros');
|
|
11
15
|
const {subscribeToChainAddress} = require('./../../');
|
|
12
16
|
const {waitForTermination} = require('./../macros');
|
|
@@ -15,102 +19,104 @@ const count = 100;
|
|
|
15
19
|
const defaultFee = 1e3;
|
|
16
20
|
const defaultVout = 0;
|
|
17
21
|
const format = 'np2wpkh';
|
|
18
|
-
const interval =
|
|
19
|
-
const times =
|
|
22
|
+
const interval = 1;
|
|
23
|
+
const times = 1500;
|
|
20
24
|
const tokens = 1e8;
|
|
21
25
|
|
|
22
26
|
// Subscribing to chain transaction confirmations should trigger events
|
|
23
27
|
test(`Subscribe to chain transactions`, async ({end, equal, fail}) => {
|
|
24
|
-
const
|
|
28
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
25
29
|
|
|
26
|
-
const
|
|
27
|
-
const host = node.listen_ip;
|
|
28
|
-
const {kill} = node;
|
|
29
|
-
const pass = node.chain_rpc_pass;
|
|
30
|
-
const port = node.chain_rpc_port;
|
|
31
|
-
const {lnd} = node;
|
|
32
|
-
const user = node.chain_rpc_user;
|
|
30
|
+
const [{chain, generate, lnd}] = nodes;
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
// Wait for chainrpc to be active
|
|
33
|
+
await asyncRetry({interval, times}, async () => {
|
|
34
|
+
if (!!(await getChainBalance({lnd})).chain_balance) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
await generate({});
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
const {blocks} = await node.generate({count});
|
|
40
|
+
await getHeight({lnd});
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
throw new Error('ExpectedChainBalance');
|
|
43
|
+
});
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
let firstConf;
|
|
46
|
+
const {address} = await createChainAddress({format, lnd});
|
|
47
|
+
const startHeight = (await getHeight({lnd})).current_block_height;
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
spend_vout: defaultVout,
|
|
52
|
-
});
|
|
49
|
+
await asyncRetry({interval, times}, async () => {
|
|
50
|
+
const sub = subscribeToChainAddress({
|
|
51
|
+
lnd,
|
|
52
|
+
min_height: startHeight,
|
|
53
|
+
p2sh_address: address,
|
|
54
|
+
});
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
min_height: startHeight,
|
|
57
|
-
p2sh_address: address,
|
|
58
|
-
});
|
|
56
|
+
sub.on('confirmation', conf => firstConf = conf);
|
|
57
|
+
sub.on('error', err => {});
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
await generate({count});
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
sub.on('error', err => {});
|
|
61
|
+
await sendToChainAddress({lnd, address, tokens});
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const {transactions} = await getChainTransactions({lnd});
|
|
64
|
+
|
|
65
|
+
const [{transaction}] = transactions
|
|
66
|
+
.filter(n => !n.is_confirmed)
|
|
67
|
+
.filter(n => !!n.is_outgoing);
|
|
68
68
|
|
|
69
|
-
if (!
|
|
70
|
-
throw new Error('
|
|
69
|
+
if (!transaction) {
|
|
70
|
+
throw new Error('ExpectedTrnasaction');
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
// Wait for generation to be over
|
|
74
|
+
await asyncRetry({interval, times}, async () => {
|
|
75
|
+
await generate({});
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (!firstConf) {
|
|
78
|
+
throw new Error('ExpectedSubscribeToChainAddressSeesConf');
|
|
79
|
+
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
equal(firstConf.block.length, 64, 'Confirmation block hash returned');
|
|
82
|
+
equal(firstConf.height >= 102, true, 'Got confirmation block height');
|
|
83
|
+
equal(firstConf.transaction, transaction, 'Confirmation raw tx');
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
min_confirmations: 6,
|
|
85
|
-
min_height: startHeight,
|
|
86
|
-
p2sh_address: address,
|
|
87
|
-
});
|
|
85
|
+
return;
|
|
86
|
+
});
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
let secondConf;
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
const sub2 = subscribeToChainAddress({
|
|
91
|
+
lnd,
|
|
92
|
+
min_confirmations: 6,
|
|
93
|
+
min_height: startHeight,
|
|
94
|
+
p2sh_address: address,
|
|
95
|
+
});
|
|
92
96
|
|
|
93
|
-
|
|
94
|
-
await asyncRetry({interval, times}, async () => {
|
|
95
|
-
await mineTransaction({cert, host, pass, port, transaction, user});
|
|
97
|
+
sub2.on('error', () => {});
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
throw new Error('ExpectedSubscribeToChainAddressSeesMultiConfirmation');
|
|
99
|
-
}
|
|
99
|
+
sub2.on('confirmation', conf => secondConf = conf);
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
// Wait for generation to be over
|
|
102
|
+
await asyncRetry({interval, times}, async () => {
|
|
103
|
+
await generate({});
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
if (!secondConf) {
|
|
106
|
+
throw new Error('ExpectedSubscribeToChainAddressSeesConfirmation');
|
|
107
|
+
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
equal(secondConf.block.length, 64, 'Confirmation block hash returned');
|
|
110
|
+
equal(secondConf.height >= 102, true, 'Confirmation block height');
|
|
111
|
+
equal(secondConf.transaction, transaction, '2nd conf raw tx returned');
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
return;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
[sub, sub2].forEach(n => n.removeAllListeners());
|
|
117
|
+
});
|
|
112
118
|
|
|
113
|
-
await
|
|
119
|
+
await kill({});
|
|
114
120
|
|
|
115
121
|
return end();
|
|
116
122
|
});
|