lightning 5.13.1 → 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 CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## 5.13.1
4
11
 
5
12
  - `signTransaction`: Fix multi-input signing for upcoming Taproot API changes
@@ -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 {
@@ -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 {
@@ -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) => {
@@ -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),
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "5.13.1"
62
+ "version": "5.14.0"
63
63
  }