ln-service 53.5.2 → 53.7.2
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 +51 -2
- package/index.js +4 -2
- package/package.json +16 -5
- package/test/integration/test_add_peer.js +25 -19
- package/test/integration/test_delete_pending_channel.js +18 -11
- package/test/integration/test_get_failed_payments.js +123 -119
- package/test/integration/test_get_node.js +48 -44
- package/test/integration/test_get_pending_force.js +8 -1
- package/test/integration/test_get_wallet_info.js +30 -15
- package/test/integration/test_open_channels.js +21 -14
- package/test/integration/test_propose_channel.js +438 -421
- package/test/integration/test_subscribe_to_channels.js +1 -1
- package/test/integration/test_subscribe_to_peer_messages.js +77 -71
- package/test/integration/test_subscribe_to_peers.js +23 -19
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +64 -60
- package/test/routerrpc-integration/test_get_route_confidence.js +38 -34
- package/test/routerrpc-integration/test_get_route_through_hops.js +33 -14
- package/test/routerrpc-integration/test_pay_via_payment_details.js +118 -110
- package/test/routerrpc-integration/test_pay_via_routes.js +19 -1
- package/test/routerrpc-integration/test_probe_for_route.js +75 -71
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +2 -2
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +508 -504
- package/test/walletrpc-integration/test_fund_psbt.js +4 -1
- package/test/walletrpc-integration/test_partially_sign_psbt.js +216 -0
- package/test/walletrpc-integration/test_sign_psbt.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 53.7.2
|
|
4
|
+
|
|
5
|
+
- `payViaRoutes`, `subscribeToPayViaRoutes`: Add support for relay messages
|
|
6
|
+
|
|
7
|
+
## 53.6.0
|
|
8
|
+
|
|
9
|
+
- `partiallySignPsbt`: Add method to add a partial signature to a PSBT
|
|
10
|
+
|
|
3
11
|
## 53.5.2
|
|
4
12
|
|
|
5
13
|
- `getPayments`: Correct paging issue that prevented paging through all results
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ through npm.
|
|
|
9
9
|
|
|
10
10
|
Supported LND versions:
|
|
11
11
|
|
|
12
|
-
- v0.14.0-beta to v0.14.
|
|
12
|
+
- v0.14.0-beta to v0.14.2-beta
|
|
13
13
|
- v0.13.0-beta to v0.13.4-beta
|
|
14
14
|
- v0.12.0-beta to v0.12.1-beta
|
|
15
15
|
- v0.11.0-beta to v0.11.1-beta
|
|
@@ -187,6 +187,7 @@ for `unlocker` methods.
|
|
|
187
187
|
- [openChannel](#openchannel) - Open a new channel
|
|
188
188
|
- [openChannels](#openchannels) - Open channels with external funding
|
|
189
189
|
- [parsePaymentRequest](#parsepaymentrequest) - Parse a BOLT11 Payment Request
|
|
190
|
+
- [partiallySignPsbt](#partiallysignpsbt) - Sign a PSBT without finalizing it
|
|
190
191
|
- [pay](#pay) - Send a payment
|
|
191
192
|
- [payViaPaymentDetails](#payviapaymentdetails) - Pay using decomposed details
|
|
192
193
|
- [payViaPaymentRequest](#payviapaymentrequest) - Pay using a payment request
|
|
@@ -2529,7 +2530,7 @@ LND 0.11.1 and below do not return `last_reconnected` or `reconnection_rate`
|
|
|
2529
2530
|
}]
|
|
2530
2531
|
is_inbound: <Is Inbound Peer Bool>
|
|
2531
2532
|
[is_sync_peer]: <Is Syncing Graph Data Bool>
|
|
2532
|
-
[
|
|
2533
|
+
[last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
|
|
2533
2534
|
ping_time: <Ping Latency Milliseconds Number>
|
|
2534
2535
|
public_key: <Node Identity Public Key String>
|
|
2535
2536
|
[reconnection_rate]: <Count of Reconnections Over Time Number>
|
|
@@ -3392,6 +3393,46 @@ const {parsePaymentRequest} = require('ln-service');
|
|
|
3392
3393
|
const requestDetails = parsePaymentRequest({request: 'paymentRequestString'});
|
|
3393
3394
|
```
|
|
3394
3395
|
|
|
3396
|
+
### partiallySignPsbt
|
|
3397
|
+
|
|
3398
|
+
Sign a PSBT to produce a partially signed PSBT
|
|
3399
|
+
|
|
3400
|
+
Requires `onchain:write` permission
|
|
3401
|
+
|
|
3402
|
+
Requires LND built with `walletrpc` tag
|
|
3403
|
+
|
|
3404
|
+
This method is not supported in LND 0.14.2 and below
|
|
3405
|
+
|
|
3406
|
+
{
|
|
3407
|
+
lnd: <Authenticated LND API Object>
|
|
3408
|
+
psbt: <Funded PSBT Hex String>
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
@returns via cbk or Promise
|
|
3412
|
+
{
|
|
3413
|
+
psbt: <Partially Signed PSBT Hex String>
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
Example:
|
|
3418
|
+
|
|
3419
|
+
```node
|
|
3420
|
+
const {broadcastChainTransaction} = require('ln-service');
|
|
3421
|
+
const {fundPsbt, partiallySignPsbt} = require('ln-service');
|
|
3422
|
+
const {extractTransaction, finalizePsbt} = require('psbt');
|
|
3423
|
+
|
|
3424
|
+
const funding = await fundPsbt({
|
|
3425
|
+
lnd,
|
|
3426
|
+
outputs: [{address: chainAddress, tokens: 100000}]
|
|
3427
|
+
})
|
|
3428
|
+
|
|
3429
|
+
const finalize = finalizePsbt({psbt: funding.psbt});
|
|
3430
|
+
|
|
3431
|
+
const {transaction} = extractTransaction({psbt: finalize.psbt});
|
|
3432
|
+
|
|
3433
|
+
await broadcastChainTransaction({lnd, transaction});
|
|
3434
|
+
```
|
|
3435
|
+
|
|
3395
3436
|
### pay
|
|
3396
3437
|
|
|
3397
3438
|
Make a payment.
|
|
@@ -3665,6 +3706,10 @@ Requires `offchain:write` permission
|
|
|
3665
3706
|
fee_mtokens: <Fee Millitokens String>
|
|
3666
3707
|
forward: <Forward Tokens Number>
|
|
3667
3708
|
forward_mtokens: <Forward Millitokens String>
|
|
3709
|
+
[messages]: [{
|
|
3710
|
+
type: <Message Type Number String>
|
|
3711
|
+
value: <Message Raw Value Hex Encoded String>
|
|
3712
|
+
}]
|
|
3668
3713
|
[public_key]: <Public Key Hex String>
|
|
3669
3714
|
timeout: <Timeout Block Height Number>
|
|
3670
3715
|
}]
|
|
@@ -5651,6 +5696,10 @@ Requires `offchain:write` permission
|
|
|
5651
5696
|
fee_mtokens: <Fee Millitokens String>
|
|
5652
5697
|
forward: <Forward Tokens Number>
|
|
5653
5698
|
forward_mtokens: <Forward Millitokens String>
|
|
5699
|
+
[messages]: [{
|
|
5700
|
+
type: <Message Type Number String>
|
|
5701
|
+
value: <Message Raw Value Hex Encoded String>
|
|
5702
|
+
}]
|
|
5654
5703
|
public_key: <Public Key Hex String>
|
|
5655
5704
|
timeout: <Timeout Block Height Number>
|
|
5656
5705
|
}]
|
package/index.js
CHANGED
|
@@ -76,6 +76,7 @@ const {lockUtxo} = require('lightning');
|
|
|
76
76
|
const {openChannel} = require('lightning');
|
|
77
77
|
const {openChannels} = require('lightning');
|
|
78
78
|
const {parsePaymentRequest} = require('invoices');
|
|
79
|
+
const {partiallySignPsbt} = require('lightning');
|
|
79
80
|
const {pay} = require('lightning');
|
|
80
81
|
const {payViaPaymentDetails} = require('lightning');
|
|
81
82
|
const {payViaPaymentRequest} = require('lightning');
|
|
@@ -90,7 +91,7 @@ const {requestChainFeeIncrease} = require('lightning');
|
|
|
90
91
|
const {restrictMacaroon} = require('./macaroons');
|
|
91
92
|
const {revokeAccess} = require('lightning');
|
|
92
93
|
const {routeFromChannels} = require('bolt07');
|
|
93
|
-
const {sendMessageToPeer} = require('lightning
|
|
94
|
+
const {sendMessageToPeer} = require('lightning');
|
|
94
95
|
const {sendToChainAddress} = require('lightning');
|
|
95
96
|
const {sendToChainAddresses} = require('lightning');
|
|
96
97
|
const {sendToChainOutputScripts} = require('lightning');
|
|
@@ -117,7 +118,7 @@ const {subscribeToPastPayments} = require('lightning');
|
|
|
117
118
|
const {subscribeToPayViaDetails} = require('lightning');
|
|
118
119
|
const {subscribeToPayViaRequest} = require('lightning');
|
|
119
120
|
const {subscribeToPayViaRoutes} = require('lightning');
|
|
120
|
-
const {subscribeToPeerMessages} = require('lightning
|
|
121
|
+
const {subscribeToPeerMessages} = require('lightning');
|
|
121
122
|
const {subscribeToPeers} = require('lightning');
|
|
122
123
|
const {subscribeToProbeForRoute} = require('lightning');
|
|
123
124
|
const {subscribeToRpcRequests} = require('lightning');
|
|
@@ -215,6 +216,7 @@ module.exports = {
|
|
|
215
216
|
openChannel,
|
|
216
217
|
openChannels,
|
|
217
218
|
parsePaymentRequest,
|
|
219
|
+
partiallySignPsbt,
|
|
218
220
|
pay,
|
|
219
221
|
payViaPaymentDetails,
|
|
220
222
|
payViaPaymentRequest,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.17.2",
|
|
13
13
|
"invoices": "2.0.3",
|
|
14
|
-
"lightning": "5.
|
|
14
|
+
"lightning": "5.6.1",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.4.2"
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"bitcoinjs-lib": "6.0.1",
|
|
27
27
|
"bn.js": "5.2.0",
|
|
28
28
|
"ecpair": "2.0.1",
|
|
29
|
-
"ln-docker-daemons": "2.2.
|
|
29
|
+
"ln-docker-daemons": "2.2.4",
|
|
30
30
|
"portfinder": "1.0.28",
|
|
31
|
-
"psbt": "
|
|
31
|
+
"psbt": "2.0.0",
|
|
32
32
|
"rimraf": "3.0.2",
|
|
33
33
|
"secp256k1": "4.0.3",
|
|
34
34
|
"tiny-secp256k1": "2.2.0",
|
|
@@ -53,7 +53,18 @@
|
|
|
53
53
|
"url": "https://github.com/alexbosworth/ln-service.git"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
|
-
"test": "
|
|
56
|
+
"integration-test-daily-lnd-build": "DOCKER_LND_VERSION=daily-testing-only npm run test",
|
|
57
|
+
"integration-test-0.14.2": "DOCKER_LND_VERSION=v0.14.2-beta npm run test",
|
|
58
|
+
"integration-test-0.14.1": "DOCKER_LND_VERSION=v0.14.1-beta npm run test",
|
|
59
|
+
"integration-test-0.14.0": "DOCKER_LND_VERSION=v0.14.0-beta npm run test",
|
|
60
|
+
"integration-test-0.13.4": "DOCKER_LND_VERSION=v0.13.4-beta npm run test",
|
|
61
|
+
"integration-test-0.13.3": "DOCKER_LND_VERSION=v0.13.3-beta npm run test",
|
|
62
|
+
"integration-test-0.13.2": "DOCKER_LND_VERSION=v0.13.2-beta npm run test",
|
|
63
|
+
"integration-test-0.13.1": "DOCKER_LND_VERSION=v0.13.1-beta npm run test",
|
|
64
|
+
"integration-test-0.13.0": "DOCKER_LND_VERSION=v0.13.0-beta npm run test",
|
|
65
|
+
"integration-test-0.12.1": "DOCKER_LND_VERSION=v0.12.1-beta npm run test",
|
|
66
|
+
"integration-test-0.12.0": "DOCKER_LND_VERSION=v0.12.0-beta npm run test",
|
|
67
|
+
"test": "echo $DOCKER_LND_VERSION && tap -j 3 --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"
|
|
57
68
|
},
|
|
58
|
-
"version": "53.
|
|
69
|
+
"version": "53.7.2"
|
|
59
70
|
}
|
|
@@ -9,7 +9,7 @@ const {getPeers} = require('./../../');
|
|
|
9
9
|
const interval = 100;
|
|
10
10
|
const size = 2;
|
|
11
11
|
const times = 100;
|
|
12
|
-
const timeout =
|
|
12
|
+
const timeout = 1000;
|
|
13
13
|
|
|
14
14
|
// Adding peers should result in a connected peer
|
|
15
15
|
test(`Add a peer`, async ({end, equal}) => {
|
|
@@ -17,30 +17,36 @@ test(`Add a peer`, async ({end, equal}) => {
|
|
|
17
17
|
|
|
18
18
|
const [{lnd}, target] = nodes;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
try {
|
|
21
|
+
const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
equal(connectedKeys.find(n => n === target.id), undefined, 'No peer');
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
await asyncRetry({interval, times}, async () => {
|
|
26
|
+
await addPeer({
|
|
27
|
+
lnd,
|
|
28
|
+
timeout,
|
|
29
|
+
public_key: target.id,
|
|
30
|
+
retry_count: 1,
|
|
31
|
+
retry_delay: 1,
|
|
32
|
+
socket: target.socket,
|
|
33
|
+
});
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const {peers} = await getPeers({lnd});
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
throw new Error('ExpectedConnectionToTarget');
|
|
38
|
-
}
|
|
37
|
+
const connected = peers.find(n => n.public_key === target.id);
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if (!connected) {
|
|
40
|
+
throw new Error('ExpectedConnectionToTarget');
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
equal(connected.public_key, target.id, 'Connected to remote node');
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
equal(err, null, 'Expected no error');
|
|
47
|
+
} finally {
|
|
48
|
+
await kill({});
|
|
49
|
+
}
|
|
44
50
|
|
|
45
51
|
return end();
|
|
46
52
|
});
|
|
@@ -5,6 +5,7 @@ const asyncRetry = require('async/retry');
|
|
|
5
5
|
const {extractTransaction} = require('psbt');
|
|
6
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
7
|
const {test} = require('@alexbosworth/tap');
|
|
8
|
+
const tinysecp = require('tiny-secp256k1');
|
|
8
9
|
|
|
9
10
|
const {addPeer} = require('./../../');
|
|
10
11
|
const {broadcastChainTransaction} = require('./../../');
|
|
@@ -27,11 +28,13 @@ const count = 100;
|
|
|
27
28
|
const interval = 100;
|
|
28
29
|
const race = promises => Promise.race(promises);
|
|
29
30
|
const size = 3;
|
|
30
|
-
const timeout = 1000 *
|
|
31
|
+
const timeout = 1000 * 20;
|
|
31
32
|
const times = 200;
|
|
32
33
|
|
|
33
34
|
// Forfeiting a pending channel should remove the pending channel
|
|
34
|
-
test(`Forfeit pending channel`, async ({end, equal}) => {
|
|
35
|
+
test(`Forfeit pending channel`, async ({end, equal, strictSame}) => {
|
|
36
|
+
const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
|
|
37
|
+
|
|
35
38
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
36
39
|
|
|
37
40
|
const [control, target, remote] = nodes;
|
|
@@ -105,7 +108,7 @@ test(`Forfeit pending channel`, async ({end, equal}) => {
|
|
|
105
108
|
funding: signRemote.psbt,
|
|
106
109
|
});
|
|
107
110
|
|
|
108
|
-
const {transaction} = extractTransaction({psbt: signRemote.psbt});
|
|
111
|
+
const {transaction} = extractTransaction({ecp, psbt: signRemote.psbt});
|
|
109
112
|
|
|
110
113
|
await broadcastChainTransaction({lnd, transaction});
|
|
111
114
|
|
|
@@ -136,16 +139,20 @@ test(`Forfeit pending channel`, async ({end, equal}) => {
|
|
|
136
139
|
equal(code, 503, 'Pending channel cannot be canceled');
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
try {
|
|
143
|
+
await deletePendingChannel({
|
|
144
|
+
lnd,
|
|
145
|
+
confirmed_transaction: transaction,
|
|
146
|
+
pending_transaction: stuckTx.transaction,
|
|
147
|
+
pending_transaction_vout: pending.transaction_vout,
|
|
148
|
+
});
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
const [notPending] = (await getPendingChannels({lnd})).pending_channels;
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
equal(notPending, undefined, 'Conflicting pending channel deleted');
|
|
153
|
+
} catch (err) {
|
|
154
|
+
strictSame(err, [501, 'DeletePendingChannelMethodNotSupported']);
|
|
155
|
+
}
|
|
149
156
|
} catch (err) {
|
|
150
157
|
equal(err, null, 'No error is expected');
|
|
151
158
|
} finally {
|
|
@@ -28,128 +28,132 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
|
|
|
28
28
|
|
|
29
29
|
const [{generate, lnd}, target, remote] = nodes;
|
|
30
30
|
|
|
31
|
-
const {address} = await createChainAddress({lnd: remote.lnd});
|
|
32
|
-
|
|
33
|
-
await generate({count});
|
|
34
|
-
|
|
35
|
-
// Send coins to remote so that it can accept the channel
|
|
36
|
-
await sendToChainAddress({lnd, address, tokens: channelCapacityTokens});
|
|
37
|
-
|
|
38
|
-
// Generate to confirm the tx
|
|
39
|
-
await generate({count: confirmationCount});
|
|
40
|
-
await remote.generate({count: confirmationCount});
|
|
41
|
-
|
|
42
|
-
await setupChannel({
|
|
43
|
-
generate,
|
|
44
|
-
lnd,
|
|
45
|
-
capacity: channelCapacityTokens + channelCapacityTokens,
|
|
46
|
-
to: target,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
await setupChannel({
|
|
50
|
-
capacity: channelCapacityTokens,
|
|
51
|
-
lnd: target.lnd,
|
|
52
|
-
generate: target.generate,
|
|
53
|
-
generator: target,
|
|
54
|
-
give: Math.round(channelCapacityTokens / 2),
|
|
55
|
-
to: remote,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
59
|
-
|
|
60
|
-
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
61
|
-
|
|
62
|
-
const bigInvoice = await createInvoice({
|
|
63
|
-
tokens: (channelCapacityTokens / 2) + (channelCapacityTokens / 4),
|
|
64
|
-
lnd: remote.lnd,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
31
|
try {
|
|
68
|
-
await
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
generate:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
32
|
+
const {address} = await createChainAddress({lnd: remote.lnd});
|
|
33
|
+
|
|
34
|
+
await generate({count});
|
|
35
|
+
|
|
36
|
+
// Send coins to remote so that it can accept the channel
|
|
37
|
+
await sendToChainAddress({lnd, address, tokens: channelCapacityTokens});
|
|
38
|
+
|
|
39
|
+
// Generate to confirm the tx
|
|
40
|
+
await generate({count: confirmationCount});
|
|
41
|
+
await remote.generate({count: confirmationCount});
|
|
42
|
+
|
|
43
|
+
await setupChannel({
|
|
44
|
+
generate,
|
|
45
|
+
lnd,
|
|
46
|
+
capacity: channelCapacityTokens + channelCapacityTokens,
|
|
47
|
+
to: target,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await setupChannel({
|
|
51
|
+
capacity: channelCapacityTokens,
|
|
52
|
+
lnd: target.lnd,
|
|
53
|
+
generate: target.generate,
|
|
54
|
+
generator: target,
|
|
55
|
+
give: Math.round(channelCapacityTokens / 2),
|
|
56
|
+
to: remote,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
60
|
+
|
|
61
|
+
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
62
|
+
|
|
63
|
+
const bigInvoice = await createInvoice({
|
|
64
|
+
tokens: (channelCapacityTokens / 2) + (channelCapacityTokens / 4),
|
|
65
|
+
lnd: remote.lnd,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
await pay({lnd, request: bigInvoice.request});
|
|
70
|
+
} catch (err) {
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Create a new channel to increase total edge liquidity
|
|
74
|
+
await setupChannel({
|
|
75
|
+
capacity: channelCapacityTokens,
|
|
76
|
+
lnd: target.lnd,
|
|
77
|
+
generate: target.generate,
|
|
78
|
+
generator: target,
|
|
79
|
+
to: remote,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await deleteForwardingReputations({lnd});
|
|
83
|
+
|
|
84
|
+
await asyncRetry({times}, async () => {
|
|
85
|
+
await pay({lnd, request: invoice.request});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
const {payments} = await getFailedPayments({lnd});
|
|
90
|
+
|
|
91
|
+
const [payment] = payments.filter(n => n.mtokens === bigInvoice.mtokens);
|
|
92
|
+
|
|
93
|
+
equal(payment.destination, remote.id, 'Payment to');
|
|
94
|
+
equal(payment.confirmed_at, undefined, 'No confirmation date');
|
|
95
|
+
equal(!!payment.created_at, true, 'Got payment created date');
|
|
96
|
+
equal(payment.fee, undefined, 'No fee when not paid');
|
|
97
|
+
equal(payment.fee_mtokens, undefined, 'No fee mtokens when not paid');
|
|
98
|
+
equal(!!payment.id, true, 'Got a payment id');
|
|
99
|
+
equal(!!payment.index, true, 'Got payment index');
|
|
100
|
+
equal(payment.is_confirmed, false, 'Failed payment is not confirmed');
|
|
101
|
+
equal(payment.is_outgoing, true, 'Failed payment is outgoing');
|
|
102
|
+
equal(payment.mtokens, bigInvoice.mtokens, 'Payment has mtokens');
|
|
103
|
+
equal(payment.request, bigInvoice.request, 'Probe has a request');
|
|
104
|
+
equal(payment.secret, undefined, 'Failed has no secret');
|
|
105
|
+
equal(payment.safe_fee, undefined, 'Failed has no fee');
|
|
106
|
+
equal(payment.safe_tokens, bigInvoice.tokens, 'Failed has safe tokens');
|
|
107
|
+
equal(payment.tokens, bigInvoice.tokens, 'Failed has tokens');
|
|
108
|
+
|
|
109
|
+
const gotFailed = await getPayment({lnd, id: payment.id});
|
|
110
|
+
|
|
111
|
+
strictSame(
|
|
112
|
+
gotFailed,
|
|
113
|
+
{
|
|
114
|
+
failed: {
|
|
115
|
+
is_insufficient_balance: false,
|
|
116
|
+
is_invalid_payment: false,
|
|
117
|
+
is_pathfinding_timeout: false,
|
|
118
|
+
is_route_not_found: true,
|
|
119
|
+
},
|
|
120
|
+
is_confirmed: false,
|
|
121
|
+
is_failed: true,
|
|
122
|
+
is_pending: false,
|
|
123
|
+
payment: undefined,
|
|
124
|
+
pending: undefined,
|
|
118
125
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
equal(payment.tokens, invoice.tokens, 'Failed has tokens');
|
|
126
|
+
'Got failed state'
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
{
|
|
131
|
+
const {payments} = await getPayments({lnd});
|
|
132
|
+
|
|
133
|
+
const [payment] = payments;
|
|
134
|
+
|
|
135
|
+
equal(payment.destination, remote.id, 'Paid to');
|
|
136
|
+
equal(!!payment.confirmed_at, true, 'Got confirmation date');
|
|
137
|
+
equal(!!payment.created_at, true, 'Got payment start date');
|
|
138
|
+
equal(payment.fee, 1, 'Got fee paid');
|
|
139
|
+
equal(payment.fee_mtokens, '1500', 'Got fee mtokens paid');
|
|
140
|
+
strictSame(payment.hops, [target.id], 'Got hops');
|
|
141
|
+
equal(!!payment.id, true, 'Got a payment id');
|
|
142
|
+
equal(!!payment.index, true, 'Got payment index');
|
|
143
|
+
equal(payment.is_confirmed, true, 'Failed payment is not confirmed');
|
|
144
|
+
equal(payment.is_outgoing, true, 'Failed payment is outgoing');
|
|
145
|
+
equal(payment.mtokens, invoice.mtokens, 'Payment has mtokens');
|
|
146
|
+
equal(payment.request, invoice.request, 'Payment has a request');
|
|
147
|
+
equal(!!payment.secret, true, 'Failed has no secret');
|
|
148
|
+
equal(payment.safe_fee, 2, 'Failed has no fee');
|
|
149
|
+
equal(payment.safe_tokens, invoice.tokens, 'Failed has safe tokens');
|
|
150
|
+
equal(payment.tokens, invoice.tokens, 'Failed has tokens');
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
strictSame(err, null, 'Expected no error');
|
|
154
|
+
} finally {
|
|
155
|
+
await kill({});
|
|
150
156
|
}
|
|
151
157
|
|
|
152
|
-
await kill({});
|
|
153
|
-
|
|
154
158
|
return end();
|
|
155
159
|
});
|