lightning 5.12.0 → 5.14.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 +16 -0
- package/grpc/protos/lightning.proto +9 -0
- package/grpc/protos/router.proto +6 -0
- package/index.js +4 -0
- package/lnd_methods/index.js +4 -0
- package/lnd_methods/info/get_route_to_destination.js +10 -0
- package/lnd_methods/macaroon/methods.json +8 -0
- package/lnd_methods/offchain/is_destination_payable.js +4 -0
- package/lnd_methods/offchain/pay.js +4 -0
- package/lnd_methods/offchain/pay_via_payment_details.js +4 -0
- package/lnd_methods/offchain/pay_via_payment_request.js +4 -0
- package/lnd_methods/offchain/probe_for_route.js +4 -0
- package/lnd_methods/offchain/subscribe_to_pay.js +10 -0
- package/lnd_methods/offchain/subscribe_to_pay_via_details.js +4 -0
- package/lnd_methods/offchain/subscribe_to_pay_via_request.js +4 -0
- package/lnd_methods/offchain/subscribe_to_probe_for_route.js +4 -0
- package/lnd_methods/peers/add_external_socket.js +62 -0
- package/lnd_methods/peers/index.js +4 -0
- package/lnd_methods/peers/remove_external_socket.js +62 -0
- package/lnd_methods/signer/sign_transaction.js +20 -5
- package/package.json +2 -2
- package/test/lnd_methods/peers/test_add_external_socket.js +56 -0
- package/test/lnd_methods/peers/test_remove_external_socket.js +56 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 5.14.0
|
|
4
|
+
|
|
5
|
+
- `getRouteToDestination`, `isDestinationPayable`, `pay`,
|
|
6
|
+
`payViaPaymentDetails`, `payViaPaymentRequest`, `probeForRoute`,
|
|
7
|
+
`subscribeToPayViaDetails`, `subscribeToPayViaRequest`,
|
|
8
|
+
`subscribeToProbeForRoute` - add support for pathfinding `confidence`
|
|
9
|
+
|
|
10
|
+
## 5.13.1
|
|
11
|
+
|
|
12
|
+
- `signTransaction`: Fix multi-input signing for upcoming Taproot API changes
|
|
13
|
+
|
|
14
|
+
## 5.13.0
|
|
15
|
+
|
|
16
|
+
- `addExternalSocket`: Add method to add a socket to graph announcements
|
|
17
|
+
- `removeExternalSocket`: Add method to remove sockets from graph announcements
|
|
18
|
+
|
|
3
19
|
## 5.12.0
|
|
4
20
|
|
|
5
21
|
- `getWalletVersion`: Add support for LND 0.14.3-beta
|
|
@@ -2692,6 +2692,12 @@ message QueryRoutesRequest {
|
|
|
2692
2692
|
fallback.
|
|
2693
2693
|
*/
|
|
2694
2694
|
repeated lnrpc.FeatureBit dest_features = 17;
|
|
2695
|
+
|
|
2696
|
+
/*
|
|
2697
|
+
The time preference for this payment. Set to -1 to optimize for fees
|
|
2698
|
+
only, to 1 to optimize for reliability only or a value inbetween for a mix.
|
|
2699
|
+
*/
|
|
2700
|
+
double time_pref = 18;
|
|
2695
2701
|
}
|
|
2696
2702
|
|
|
2697
2703
|
message NodePair {
|
|
@@ -2786,6 +2792,9 @@ message Hop {
|
|
|
2786
2792
|
to drop off at each hop within the onion.
|
|
2787
2793
|
*/
|
|
2788
2794
|
map<uint64, bytes> custom_records = 11;
|
|
2795
|
+
|
|
2796
|
+
// The payment metadata to send along with the payment to the payee.
|
|
2797
|
+
bytes metadata = 13;
|
|
2789
2798
|
}
|
|
2790
2799
|
|
|
2791
2800
|
message MPPRecord {
|
package/grpc/protos/router.proto
CHANGED
|
@@ -284,6 +284,12 @@ message SendPaymentRequest {
|
|
|
284
284
|
If set, an AMP-payment will be attempted.
|
|
285
285
|
*/
|
|
286
286
|
bool amp = 22;
|
|
287
|
+
|
|
288
|
+
/*
|
|
289
|
+
The time preference for this payment. Set to -1 to optimize for fees
|
|
290
|
+
only, to 1 to optimize for reliability only or a value inbetween for a mix.
|
|
291
|
+
*/
|
|
292
|
+
double time_pref = 23;
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
message TrackPaymentRequest {
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {addExternalSocket} = require('./lnd_methods');
|
|
1
2
|
const {addPeer} = require('./lnd_methods');
|
|
2
3
|
const {authenticatedLndGrpc} = require('./lnd_grpc');
|
|
3
4
|
const {broadcastChainTransaction} = require('./lnd_methods');
|
|
@@ -88,6 +89,7 @@ const {probeForRoute} = require('./lnd_methods');
|
|
|
88
89
|
const {proposeChannel} = require('./lnd_methods');
|
|
89
90
|
const {recoverFundsFromChannel} = require('./lnd_methods');
|
|
90
91
|
const {recoverFundsFromChannels} = require('./lnd_methods');
|
|
92
|
+
const {removeExternalSocket} = require('./lnd_methods');
|
|
91
93
|
const {removePeer} = require('./lnd_methods');
|
|
92
94
|
const {requestChainFeeIncrease} = require('./lnd_methods');
|
|
93
95
|
const {revokeAccess} = require('./lnd_methods');
|
|
@@ -140,6 +142,7 @@ const {verifyBytesSignature} = require('./lnd_methods');
|
|
|
140
142
|
const {verifyMessage} = require('./lnd_methods');
|
|
141
143
|
|
|
142
144
|
module.exports = {
|
|
145
|
+
addExternalSocket,
|
|
143
146
|
addPeer,
|
|
144
147
|
authenticatedLndGrpc,
|
|
145
148
|
broadcastChainTransaction,
|
|
@@ -230,6 +233,7 @@ module.exports = {
|
|
|
230
233
|
proposeChannel,
|
|
231
234
|
recoverFundsFromChannel,
|
|
232
235
|
recoverFundsFromChannels,
|
|
236
|
+
removeExternalSocket,
|
|
233
237
|
removePeer,
|
|
234
238
|
requestChainFeeIncrease,
|
|
235
239
|
revokeAccess,
|
package/lnd_methods/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const {addExternalSocket} = require('./peers');
|
|
1
2
|
const {addPeer} = require('./peers');
|
|
2
3
|
const {broadcastChainTransaction} = require('./onchain');
|
|
3
4
|
const {cancelHodlInvoice} = require('./invoices');
|
|
@@ -85,6 +86,7 @@ const {probeForRoute} = require('./offchain');
|
|
|
85
86
|
const {proposeChannel} = require('./onchain');
|
|
86
87
|
const {recoverFundsFromChannel} = require('./offchain');
|
|
87
88
|
const {recoverFundsFromChannels} = require('./offchain');
|
|
89
|
+
const {removeExternalSocket} = require('./peers');
|
|
88
90
|
const {removePeer} = require('./peers');
|
|
89
91
|
const {requestChainFeeIncrease} = require('./onchain');
|
|
90
92
|
const {revokeAccess} = require('./macaroon');
|
|
@@ -136,6 +138,7 @@ const {verifyBytesSignature} = require('./signer');
|
|
|
136
138
|
const {verifyMessage} = require('./message');
|
|
137
139
|
|
|
138
140
|
module.exports = {
|
|
141
|
+
addExternalSocket,
|
|
139
142
|
addPeer,
|
|
140
143
|
broadcastChainTransaction,
|
|
141
144
|
cancelHodlInvoice,
|
|
@@ -223,6 +226,7 @@ module.exports = {
|
|
|
223
226
|
proposeChannel,
|
|
224
227
|
recoverFundsFromChannel,
|
|
225
228
|
recoverFundsFromChannels,
|
|
229
|
+
removeExternalSocket,
|
|
226
230
|
removePeer,
|
|
227
231
|
requestChainFeeIncrease,
|
|
228
232
|
revokeAccess,
|
|
@@ -17,6 +17,7 @@ const {pathNotFoundErrors} = require('./constants');
|
|
|
17
17
|
const {routeHintFromRoute} = require('./../../lnd_requests');
|
|
18
18
|
const {routesFromQueryRoutes} = require('./../../lnd_responses');
|
|
19
19
|
|
|
20
|
+
const asTimePreference = n => n === undefined ? n : ((n * 2) - 1e6) / 1e6;
|
|
20
21
|
const bufFromHex = hex => !hex ? null : Buffer.from(hex, 'hex');
|
|
21
22
|
const {concat} = Buffer;
|
|
22
23
|
const defaultRetryInterval = retryCount => 50 * Math.pow(2, retryCount);
|
|
@@ -24,6 +25,7 @@ const defaultMaxFee = Number.MAX_SAFE_INTEGER;
|
|
|
24
25
|
const errorFilter = err => Array.isArray(err) && err.slice().shift() === 429;
|
|
25
26
|
const internalServerError = /internal.server.error/i;
|
|
26
27
|
const {isArray} = Array;
|
|
28
|
+
const isConfidence = n => !isNaN(n) && n >= 0 && n <= 1e6;
|
|
27
29
|
const isHex = n => !(n.length % 2) && /^[0-9A-F]*$/i.test(n);
|
|
28
30
|
const mtokensByteLength = 8;
|
|
29
31
|
const networkBusyError = /device.or.resource.busy/;
|
|
@@ -41,8 +43,11 @@ const trimByte = 0;
|
|
|
41
43
|
|
|
42
44
|
Requires `info:read` permission
|
|
43
45
|
|
|
46
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
47
|
+
|
|
44
48
|
{
|
|
45
49
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
50
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
46
51
|
destination: <Final Send Destination Hex Encoded Public Key String>
|
|
47
52
|
[features]: [{
|
|
48
53
|
bit: <Feature Bit Number>
|
|
@@ -112,6 +117,10 @@ module.exports = (args, cbk) => {
|
|
|
112
117
|
return asyncAuto({
|
|
113
118
|
// Check arguments
|
|
114
119
|
validate: cbk => {
|
|
120
|
+
if (args.confidence !== undefined && !isConfidence(args.confidence)) {
|
|
121
|
+
return cbk([400, 'ExpectedConfidenceInPartsPerMillionForQuery']);
|
|
122
|
+
}
|
|
123
|
+
|
|
115
124
|
if (!args.destination || !isHex(args.destination)) {
|
|
116
125
|
return cbk([400, 'ExpectedDestinationKeyToGetRouteToDestination']);
|
|
117
126
|
}
|
|
@@ -261,6 +270,7 @@ module.exports = (args, cbk) => {
|
|
|
261
270
|
pub_key: args.destination,
|
|
262
271
|
route_hints: routeHints || undefined,
|
|
263
272
|
source_pub_key: args.start || undefined,
|
|
273
|
+
time_pref: asTimePreference(args.confidence),
|
|
264
274
|
use_mission_control: !args.is_ignoring_past_failures,
|
|
265
275
|
},
|
|
266
276
|
(err, response) => {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"addExternalSocket": {
|
|
3
|
+
"method": "updateNodeAnnouncement",
|
|
4
|
+
"type": "peers"
|
|
5
|
+
},
|
|
2
6
|
"addPeer": {
|
|
3
7
|
"method": "ConnectPeer",
|
|
4
8
|
"type": "default"
|
|
@@ -338,6 +342,10 @@
|
|
|
338
342
|
"method": "restoreChannelBackups",
|
|
339
343
|
"type": "default"
|
|
340
344
|
},
|
|
345
|
+
"removeExternalSocket": {
|
|
346
|
+
"method": "updateNodeAnnouncement",
|
|
347
|
+
"type": "peers"
|
|
348
|
+
},
|
|
341
349
|
"removePeer": {
|
|
342
350
|
"method": "DisconnectPeer",
|
|
343
351
|
"type": "default"
|
|
@@ -9,8 +9,11 @@ const defaultTokens = 1;
|
|
|
9
9
|
|
|
10
10
|
Requires `offchain:write` permission
|
|
11
11
|
|
|
12
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
13
|
+
|
|
12
14
|
{
|
|
13
15
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
16
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
14
17
|
destination: <Pay to Node with Public Key Hex String>
|
|
15
18
|
[incoming_peer]: <Pay Through Specific Final Hop Public Key Hex String>
|
|
16
19
|
lnd: <Authenticated LND API Object>
|
|
@@ -57,6 +60,7 @@ module.exports = (args, cbk) => {
|
|
|
57
60
|
|
|
58
61
|
const sub = subscribeToPayViaDetails({
|
|
59
62
|
cltv_delta: args.cltv_delta,
|
|
63
|
+
confidence: args.confidence,
|
|
60
64
|
destination: args.destination,
|
|
61
65
|
lnd: args.lnd,
|
|
62
66
|
max_fee: args.max_fee,
|
|
@@ -17,7 +17,10 @@ const payViaRoutes = require('./pay_via_routes');
|
|
|
17
17
|
|
|
18
18
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
19
19
|
|
|
20
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
21
|
+
|
|
20
22
|
{
|
|
23
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
21
24
|
[incoming_peer]: <Pay Through Specific Final Hop Public Key Hex String>
|
|
22
25
|
lnd: <Authenticated LND API Object>
|
|
23
26
|
[max_fee]: <Maximum Additional Fee Tokens To Pay Number>
|
|
@@ -124,6 +127,7 @@ module.exports = (args, cbk) => {
|
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
return payViaPaymentRequest({
|
|
130
|
+
confidence: args.confidence,
|
|
127
131
|
incoming_peer: args.incoming_peer,
|
|
128
132
|
lnd: args.lnd,
|
|
129
133
|
max_fee: args.max_fee,
|
|
@@ -19,8 +19,11 @@ const type = 'router';
|
|
|
19
19
|
|
|
20
20
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
21
21
|
|
|
22
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
23
|
+
|
|
22
24
|
{
|
|
23
25
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
26
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
24
27
|
destination: <Destination Public Key String>
|
|
25
28
|
[features]: [{
|
|
26
29
|
bit: <Feature Bit Number>
|
|
@@ -109,6 +112,7 @@ module.exports = (args, cbk) => {
|
|
|
109
112
|
try {
|
|
110
113
|
const sub = subscribeToPayViaDetails({
|
|
111
114
|
cltv_delta: args.cltv_delta,
|
|
115
|
+
confidence: args.confidence,
|
|
112
116
|
destination: args.destination,
|
|
113
117
|
features: args.features,
|
|
114
118
|
id: args.id,
|
|
@@ -14,7 +14,10 @@ const type = 'router';
|
|
|
14
14
|
|
|
15
15
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
16
16
|
|
|
17
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
18
|
+
|
|
17
19
|
{
|
|
20
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
18
21
|
[incoming_peer]: <Pay Through Specific Final Hop Public Key Hex String>
|
|
19
22
|
lnd: <Authenticated LND API Object>
|
|
20
23
|
[max_fee]: <Maximum Fee Tokens To Pay Number>
|
|
@@ -89,6 +92,7 @@ module.exports = (args, cbk) => {
|
|
|
89
92
|
// Pay payment request
|
|
90
93
|
pay: ['validate', ({}, cbk) => {
|
|
91
94
|
const sub = subscribeToPayViaRequest({
|
|
95
|
+
confidence: args.confidence,
|
|
92
96
|
incoming_peer: args.incoming_peer,
|
|
93
97
|
lnd: args.lnd,
|
|
94
98
|
max_fee: args.max_fee,
|
|
@@ -17,8 +17,11 @@ const isHex = n => !(n.length % 2) && /^[0-9A-F]*$/i.test(n);
|
|
|
17
17
|
|
|
18
18
|
Requires `offchain:write` permission
|
|
19
19
|
|
|
20
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
21
|
+
|
|
20
22
|
{
|
|
21
23
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
24
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
22
25
|
destination: <Destination Public Key Hex String>
|
|
23
26
|
[features]: [{
|
|
24
27
|
bit: <Feature Bit Number>
|
|
@@ -117,6 +120,7 @@ module.exports = (args, cbk) => {
|
|
|
117
120
|
|
|
118
121
|
const sub = subscribeToProbeForRoute({
|
|
119
122
|
cltv_delta: args.cltv_delta,
|
|
123
|
+
confidence: args.confidence,
|
|
120
124
|
destination: args.destination,
|
|
121
125
|
features: args.features,
|
|
122
126
|
ignore: args.ignore,
|
|
@@ -16,6 +16,7 @@ const {routeHintFromRoute} = require('./../../lnd_requests');
|
|
|
16
16
|
const {safeTokens} = require('./../../bolt00');
|
|
17
17
|
const {states} = require('./payment_states');
|
|
18
18
|
|
|
19
|
+
const asTimePreference = n => n === undefined ? n : ((n * 2) - 1e6) / 1e6;
|
|
19
20
|
const cltvBuf = 3;
|
|
20
21
|
const cltvLimit = (limit, height) => !limit ? undefined : limit - height;
|
|
21
22
|
const cltvLimitErr = /cltv limit \d+ should be greater than \d+/;
|
|
@@ -24,6 +25,7 @@ const defaultMaxPaths = 1;
|
|
|
24
25
|
const defaultTimeoutSeconds = 25;
|
|
25
26
|
const hexToBuf = hex => !hex ? undefined : Buffer.from(hex, 'hex');
|
|
26
27
|
const {isArray} = Array;
|
|
28
|
+
const isConfidence = n => !isNaN(n) && n >= 0 && n <= 1e6;
|
|
27
29
|
const isHex = n => !!n && !(n.length % 2) && /^[0-9A-F]*$/i.test(n);
|
|
28
30
|
const maxTokens = '4294967296';
|
|
29
31
|
const method = 'sendPaymentV2';
|
|
@@ -42,8 +44,11 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
|
42
44
|
|
|
43
45
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
44
46
|
|
|
47
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
48
|
+
|
|
45
49
|
{
|
|
46
50
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
51
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
47
52
|
[destination]: <Destination Public Key String>
|
|
48
53
|
[features]: [{
|
|
49
54
|
bit: <Feature Bit Number>
|
|
@@ -208,6 +213,10 @@ module.exports = args => {
|
|
|
208
213
|
throw new Error('UnexpectedCltvDeltaWhenSubscribingToPayPaymentRequest');
|
|
209
214
|
}
|
|
210
215
|
|
|
216
|
+
if (args.confidence !== undefined && !isConfidence(args.confidence)) {
|
|
217
|
+
throw new Error('ExpectedConfidencePartsPerMillionForPaymentReq');
|
|
218
|
+
}
|
|
219
|
+
|
|
211
220
|
if (!args.destination && !args.request) {
|
|
212
221
|
throw new Error('ExpectedDestinationWhenPaymentRequestNotSpecified');
|
|
213
222
|
}
|
|
@@ -378,6 +387,7 @@ module.exports = args => {
|
|
|
378
387
|
payment_hash: !args.id ? undefined : hexToBuf(args.id),
|
|
379
388
|
payment_request: !args.request ? undefined : args.request,
|
|
380
389
|
route_hints: !hints.length ? undefined : hints,
|
|
390
|
+
time_pref: asTimePreference(args.confidence),
|
|
381
391
|
timeout_seconds: timeoutSecs || defaultTimeoutSeconds,
|
|
382
392
|
});
|
|
383
393
|
}],
|
|
@@ -17,8 +17,11 @@ const type = 'router';
|
|
|
17
17
|
|
|
18
18
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
19
19
|
|
|
20
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
21
|
+
|
|
20
22
|
{
|
|
21
23
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
24
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
22
25
|
destination: <Destination Public Key String>
|
|
23
26
|
[features]: [{
|
|
24
27
|
bit: <Feature Bit Number>
|
|
@@ -191,6 +194,7 @@ module.exports = args => {
|
|
|
191
194
|
|
|
192
195
|
return subscribeToPay({
|
|
193
196
|
cltv_delta: args.cltv_delta || defaultCltvDelta,
|
|
197
|
+
confidence: args.confidence,
|
|
194
198
|
destination: args.destination,
|
|
195
199
|
features: args.features,
|
|
196
200
|
id: args.id || randomId(),
|
|
@@ -10,7 +10,10 @@ const type = 'router';
|
|
|
10
10
|
|
|
11
11
|
`max_path_mtokens` is not supported in LND 0.12.0 or below
|
|
12
12
|
|
|
13
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
14
|
+
|
|
13
15
|
{
|
|
16
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
14
17
|
[incoming_peer]: <Pay Through Specific Final Hop Public Key Hex String>
|
|
15
18
|
lnd: <Authenticated LND API Object>
|
|
16
19
|
[max_fee]: <Maximum Fee Tokens To Pay Number>
|
|
@@ -167,6 +170,7 @@ module.exports = args => {
|
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
return subscribeToPay({
|
|
173
|
+
confidence: args.confidence,
|
|
170
174
|
incoming_peer: args.incoming_peer,
|
|
171
175
|
lnd: args.lnd,
|
|
172
176
|
max_fee: args.max_fee,
|
|
@@ -20,8 +20,11 @@ const {nextTick} = process;
|
|
|
20
20
|
|
|
21
21
|
Requires `offchain:write` permission
|
|
22
22
|
|
|
23
|
+
Preferred `confidence` is not supported on LND 0.14.3 and below
|
|
24
|
+
|
|
23
25
|
{
|
|
24
26
|
[cltv_delta]: <Final CLTV Delta Number>
|
|
27
|
+
[confidence]: <Preferred Route Confidence Number Out of One Million Number>
|
|
25
28
|
destination: <Destination Public Key Hex String>
|
|
26
29
|
[features]: [{
|
|
27
30
|
bit: <Feature Bit Number>
|
|
@@ -241,6 +244,7 @@ module.exports = args => {
|
|
|
241
244
|
return getRouteToDestination({
|
|
242
245
|
mtokens,
|
|
243
246
|
cltv_delta: args.cltv_delta,
|
|
247
|
+
confidence: args.confidence,
|
|
244
248
|
destination: args.destination,
|
|
245
249
|
features: args.features,
|
|
246
250
|
ignore: ignore.concat(temporaryChannelFailures),
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const action = 0;
|
|
7
|
+
const errorUnimplemented = 'unknown service peersrpc.Peers';
|
|
8
|
+
const method = 'updateNodeAnnouncement';
|
|
9
|
+
const type = 'peers';
|
|
10
|
+
|
|
11
|
+
/** Add a new advertised p2p socket address
|
|
12
|
+
|
|
13
|
+
Note: this method is not supported in LND versions 0.14.3 and below
|
|
14
|
+
|
|
15
|
+
Requires LND built with `peersrpc` build tag
|
|
16
|
+
|
|
17
|
+
Requires `peers:write` permissions
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
lnd: <Authenticated LND API Object>
|
|
21
|
+
socket: <Add Socket Address String>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@returns via cbk or Promise
|
|
25
|
+
*/
|
|
26
|
+
module.exports = ({lnd, socket}, cbk) => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
return asyncAuto({
|
|
29
|
+
// Check arguments
|
|
30
|
+
validate: cbk => {
|
|
31
|
+
if (!isLnd({lnd, method, type})) {
|
|
32
|
+
return cbk([400, 'ExpectedLndToAddExternalSocket']);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!socket) {
|
|
36
|
+
return cbk([400, 'ExpectedHostAndPortOfSocketToAdd']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return cbk();
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Add external socket to be advertised
|
|
43
|
+
add: ['validate', ({}, cbk) => {
|
|
44
|
+
return lnd[type][method]({
|
|
45
|
+
address_updates: [{action, address: socket}],
|
|
46
|
+
},
|
|
47
|
+
err => {
|
|
48
|
+
if (!!err && err.details === errorUnimplemented) {
|
|
49
|
+
return cbk([400, 'ExpectedPeersRpcLndBuildTagToAddSocket']);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!!err) {
|
|
53
|
+
return cbk([503, 'UnexpectedErrorAddingExternalSocket', {err}]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return cbk();
|
|
57
|
+
});
|
|
58
|
+
}],
|
|
59
|
+
},
|
|
60
|
+
returnResult({reject, resolve}, cbk));
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
const addExternalSocket = require('./add_external_socket');
|
|
1
2
|
const addPeer = require('./add_peer');
|
|
2
3
|
const getPeers = require('./get_peers');
|
|
4
|
+
const removeExternalSocket = require('./remove_external_socket');
|
|
3
5
|
const removePeer = require('./remove_peer');
|
|
4
6
|
const subscribeToPeers = require('./subscribe_to_peers');
|
|
5
7
|
const updateAlias = require('./update_alias');
|
|
6
8
|
const updateColor = require('./update_color');
|
|
7
9
|
|
|
8
10
|
module.exports = {
|
|
11
|
+
addExternalSocket,
|
|
9
12
|
addPeer,
|
|
10
13
|
getPeers,
|
|
14
|
+
removeExternalSocket,
|
|
11
15
|
removePeer,
|
|
12
16
|
subscribeToPeers,
|
|
13
17
|
updateAlias,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const action = 1;
|
|
7
|
+
const errorUnimplemented = 'unknown service peersrpc.Peers';
|
|
8
|
+
const method = 'updateNodeAnnouncement';
|
|
9
|
+
const type = 'peers';
|
|
10
|
+
|
|
11
|
+
/** Remove an existing advertised p2p socket address
|
|
12
|
+
|
|
13
|
+
Note: this method is not supported in LND versions 0.14.3 and below
|
|
14
|
+
|
|
15
|
+
Requires LND built with `peersrpc` build tag
|
|
16
|
+
|
|
17
|
+
Requires `peers:write` permissions
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
lnd: <Authenticated LND API Object>
|
|
21
|
+
socket: <Remove Socket Address String>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@returns via cbk or Promise
|
|
25
|
+
*/
|
|
26
|
+
module.exports = ({lnd, socket}, cbk) => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
return asyncAuto({
|
|
29
|
+
// Check arguments
|
|
30
|
+
validate: cbk => {
|
|
31
|
+
if (!isLnd({lnd, method, type})) {
|
|
32
|
+
return cbk([400, 'ExpectedLndToRemoveExternalSocket']);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!socket) {
|
|
36
|
+
return cbk([400, 'ExpectedHostAndPortOfSocketToRemove']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return cbk();
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Stop external socket from being advertised
|
|
43
|
+
add: ['validate', ({}, cbk) => {
|
|
44
|
+
return lnd[type][method]({
|
|
45
|
+
address_updates: [{action, address: socket}],
|
|
46
|
+
},
|
|
47
|
+
err => {
|
|
48
|
+
if (!!err && err.details === errorUnimplemented) {
|
|
49
|
+
return cbk([400, 'ExpectedPeersRpcLndBuildTagToRemoveSocket']);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!!err) {
|
|
53
|
+
return cbk([503, 'UnexpectedErrorRemovingExternalSocket', {err}]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return cbk();
|
|
57
|
+
});
|
|
58
|
+
}],
|
|
59
|
+
},
|
|
60
|
+
returnResult({reject, resolve}, cbk));
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -6,6 +6,7 @@ const {isLnd} = require('./../../lnd_requests');
|
|
|
6
6
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
7
7
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
8
8
|
const {isArray} = Array;
|
|
9
|
+
const isV1 = scriptHex => scriptHex.length === 68 && /5120/.test(scriptHex);
|
|
9
10
|
const method = 'signOutputRaw';
|
|
10
11
|
const notFound = -1;
|
|
11
12
|
const type = 'signer';
|
|
@@ -64,13 +65,27 @@ module.exports = ({inputs, lnd, spending, transaction}, cbk) => {
|
|
|
64
65
|
return cbk();
|
|
65
66
|
},
|
|
66
67
|
|
|
68
|
+
// Derive the previous outputs set
|
|
69
|
+
previousOutputs: ['validate', ({}, cbk) => {
|
|
70
|
+
const outputs = [].concat(inputs).concat(spending || []).map(utxo => ({
|
|
71
|
+
pk_script: hexAsBuffer(utxo.output_script),
|
|
72
|
+
value: utxo.output_tokens,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const v1Spends = outputs.filter(n => isV1(bufferAsHex(n.pk_script)));
|
|
76
|
+
|
|
77
|
+
// Exit early when there is no need to provide prev outs, non-taproot
|
|
78
|
+
if (!v1Spends.length) {
|
|
79
|
+
return cbk();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return cbk(null, outputs);
|
|
83
|
+
}],
|
|
84
|
+
|
|
67
85
|
// Get signatures
|
|
68
|
-
signTransaction: ['
|
|
86
|
+
signTransaction: ['previousOutputs', ({previousOutputs}, cbk) => {
|
|
69
87
|
return lnd[type][method]({
|
|
70
|
-
prev_outputs:
|
|
71
|
-
pk_script: hexAsBuffer(utxo.output_script),
|
|
72
|
-
value: utxo.output_tokens,
|
|
73
|
-
})),
|
|
88
|
+
prev_outputs: previousOutputs,
|
|
74
89
|
raw_tx_bytes: hexAsBuffer(transaction),
|
|
75
90
|
sign_descs: inputs.map(input => ({
|
|
76
91
|
input_index: input.vin,
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/lightning/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@grpc/grpc-js": "1.6.
|
|
10
|
+
"@grpc/grpc-js": "1.6.7",
|
|
11
11
|
"@grpc/proto-loader": "0.6.9",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
13
|
"@types/node": "17.0.25",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.
|
|
62
|
+
"version": "5.14.0"
|
|
63
63
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {addExternalSocket} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({err}) => {
|
|
6
|
+
return {peers: {updateNodeAnnouncement: (args, cbk) => cbk(err)}};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const makeArgs = overrides => {
|
|
10
|
+
const args = {lnd: makeLnd({}), socket: '127.0.0.1:9735'};
|
|
11
|
+
|
|
12
|
+
Object.keys(overrides).forEach(key => args[key] = overrides[key]);
|
|
13
|
+
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const tests = [
|
|
18
|
+
{
|
|
19
|
+
args: makeArgs({lnd: undefined}),
|
|
20
|
+
description: 'LND is required to add an external socket',
|
|
21
|
+
error: [400, 'ExpectedLndToAddExternalSocket'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: makeArgs({socket: undefined}),
|
|
25
|
+
description: 'A socket is required to add an external socket',
|
|
26
|
+
error: [400, 'ExpectedHostAndPortOfSocketToAdd'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
args: makeArgs({
|
|
30
|
+
lnd: makeLnd({err: {details: 'unknown service peersrpc.Peers'}}),
|
|
31
|
+
}),
|
|
32
|
+
description: 'LND with peersrpc is required to add an external socket',
|
|
33
|
+
error: [400, 'ExpectedPeersRpcLndBuildTagToAddSocket'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
args: makeArgs({lnd: makeLnd({err: 'err'})}),
|
|
37
|
+
description: 'LND error is returned',
|
|
38
|
+
error: [503, 'UnexpectedErrorAddingExternalSocket', {err: 'err'}],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
args: makeArgs({}),
|
|
42
|
+
description: 'Socket added successfully',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
47
|
+
return test(description, async ({deepEqual, end, equal, rejects}) => {
|
|
48
|
+
if (!!error) {
|
|
49
|
+
await rejects(() => addExternalSocket(args), error, 'Got error');
|
|
50
|
+
} else {
|
|
51
|
+
await addExternalSocket(args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return end();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {removeExternalSocket} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({err}) => {
|
|
6
|
+
return {peers: {updateNodeAnnouncement: (args, cbk) => cbk(err)}};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const makeArgs = overrides => {
|
|
10
|
+
const args = {lnd: makeLnd({}), socket: '127.0.0.1:9735'};
|
|
11
|
+
|
|
12
|
+
Object.keys(overrides).forEach(key => args[key] = overrides[key]);
|
|
13
|
+
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const tests = [
|
|
18
|
+
{
|
|
19
|
+
args: makeArgs({lnd: undefined}),
|
|
20
|
+
description: 'LND is required to remove an external socket',
|
|
21
|
+
error: [400, 'ExpectedLndToRemoveExternalSocket'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: makeArgs({socket: undefined}),
|
|
25
|
+
description: 'A socket is required to remove an external socket',
|
|
26
|
+
error: [400, 'ExpectedHostAndPortOfSocketToRemove'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
args: makeArgs({
|
|
30
|
+
lnd: makeLnd({err: {details: 'unknown service peersrpc.Peers'}}),
|
|
31
|
+
}),
|
|
32
|
+
description: 'LND with peersrpc is required to add an external socket',
|
|
33
|
+
error: [400, 'ExpectedPeersRpcLndBuildTagToRemoveSocket'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
args: makeArgs({lnd: makeLnd({err: 'err'})}),
|
|
37
|
+
description: 'LND error is returned',
|
|
38
|
+
error: [503, 'UnexpectedErrorRemovingExternalSocket', {err: 'err'}],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
args: makeArgs({}),
|
|
42
|
+
description: 'Socket removed successfully',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
47
|
+
return test(description, async ({deepEqual, end, equal, rejects}) => {
|
|
48
|
+
if (!!error) {
|
|
49
|
+
await rejects(() => removeExternalSocket(args), error, 'Got error');
|
|
50
|
+
} else {
|
|
51
|
+
await removeExternalSocket(args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return end();
|
|
55
|
+
});
|
|
56
|
+
});
|