lightning 10.8.0 → 10.8.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 CHANGED
@@ -1,6 +1,10 @@
1
1
  # Versions
2
2
 
3
- ## 10.8.0
3
+ ## 10.8.2
4
+
5
+ - `pay` and payment via request methods: disallow features 30/31 from payments
6
+
7
+ ## 10.8.1
4
8
 
5
9
  - `removeAdvertisedFeature`: Add method to remove a feature bit support ad
6
10
 
package/README.md CHANGED
@@ -271,6 +271,8 @@ variables set:
271
271
  Attempt to recover channel funds from a specific channel backup.
272
272
  - [recoverFundsFromChannels](https://github.com/alexbosworth/ln-service#recoverfundsfromchannels):
273
273
  Attempt to recover funds from multiple channels using a multiple channel backup.
274
+ - [removeAdvertisedFeature](https://github.com/alexbosworth/ln-service#removeadvertisedfeature):
275
+ Remove a supported feature from the graph node announcement
274
276
  - [removeExternalSocket](https://github.com/alexbosworth/ln-service#removeexternalsocket):
275
277
  Remove a LN p2p network socket from the node advertisement
276
278
  - [removePeer](https://github.com/alexbosworth/ln-service#removepeer): Disconnect from a
@@ -388,6 +388,10 @@
388
388
  "method": "restoreChannelBackups",
389
389
  "type": "default"
390
390
  },
391
+ "removeAdvertisedFeature": {
392
+ "method": "updateNodeAnnouncement",
393
+ "type": "peers"
394
+ },
391
395
  "removeExternalSocket": {
392
396
  "method": "updateNodeAnnouncement",
393
397
  "type": "peers"
@@ -4,6 +4,7 @@ const EventEmitter = require('events');
4
4
  const asyncAuto = require('async/auto');
5
5
  const {chanFormat} = require('bolt07');
6
6
  const {chanNumber} = require('bolt07');
7
+ const {parsePaymentRequest} = require('invoices');
7
8
 
8
9
  const {confirmedFromPayment} = require('./../../lnd_responses');
9
10
  const {confirmedFromPaymentStatus} = require('./../../lnd_responses');
@@ -37,6 +38,7 @@ const {round} = Math;
37
38
  const sha256 = preimage => createHash('sha256').update(preimage).digest();
38
39
  const type = 'router';
39
40
  const unknownServiceErr = 'unknown service verrpc.Versioner';
41
+ const unsupportedFeatures = [30, 31];
40
42
 
41
43
  /** Initiate and subscribe to the outcome of a payment
42
44
 
@@ -252,6 +254,14 @@ module.exports = args => {
252
254
  throw new Error('ExpectedTokenAmountToPayWhenPaymentRequestNotSpecified');
253
255
  }
254
256
 
257
+ if (!!args.request) {
258
+ try {
259
+ parsePaymentRequest({request: args.request});
260
+ } catch (err) {
261
+ throw new Error('ExpectedValidPaymentRequestToMakePayment');
262
+ }
263
+ }
264
+
255
265
  if (!!args.routes && !isArray(args.routes)) {
256
266
  throw new Error('UnexpectedFormatForRoutesWhenSubscribingToPayment');
257
267
  }
@@ -296,6 +306,23 @@ module.exports = args => {
296
306
  const finalCltv = !args.cltv_delta ? defaultCltvDelta : args.cltv_delta;
297
307
 
298
308
  asyncAuto({
309
+ // Determine what features would be used with the payment
310
+ featureBits: cbk => {
311
+ // Exit early when there are no features to look at
312
+ if (!args.features && !args.request) {
313
+ return cbk(null, []);
314
+ }
315
+
316
+ // Exit early when feature bits are specified directly
317
+ if (!!features) {
318
+ return cbk(null, features);
319
+ }
320
+
321
+ const request = parsePaymentRequest({request: args.request});
322
+
323
+ return cbk(null, request.features.map(n => n.bit));
324
+ },
325
+
299
326
  // Determine the block height to figure out the height delta
300
327
  getHeight: cbk => {
301
328
  // Exit early when there is no max timeout restriction
@@ -325,6 +352,17 @@ module.exports = args => {
325
352
  }));
326
353
  },
327
354
 
355
+ // Validate the payment request features
356
+ checkFeatures: ['featureBits', ({featureBits}, cbk) => {
357
+ const bit = featureBits.find(n => unsupportedFeatures.includes(n));
358
+
359
+ if (!!bit) {
360
+ return cbk([501, 'UnsupportedPaymentFeatureInPayRequest', {bit}]);
361
+ }
362
+
363
+ return cbk();
364
+ }],
365
+
328
366
  // Determine the maximum CLTV delta
329
367
  maxCltvDelta: ['getHeight', ({getHeight}, cbk) => {
330
368
  if (!args.max_timeout_height) {
@@ -394,7 +432,7 @@ module.exports = args => {
394
432
  }],
395
433
 
396
434
  // Send payment
397
- send: ['params', ({params}, cbk) => {
435
+ send: ['checkFeatures', 'params', ({params}, cbk) => {
398
436
  const sub = args.lnd.router.sendPaymentV2(params);
399
437
 
400
438
  sub.on('data', data => emitPayment({data, emitter}));
package/package.json CHANGED
@@ -7,9 +7,9 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.10.3",
11
- "@grpc/proto-loader": "0.7.10",
12
- "@types/node": "20.11.30",
10
+ "@grpc/grpc-js": "1.10.4",
11
+ "@grpc/proto-loader": "0.7.12",
12
+ "@types/node": "20.12.2",
13
13
  "@types/request": "2.48.12",
14
14
  "@types/ws": "8.5.10",
15
15
  "async": "3.2.5",
@@ -22,11 +22,11 @@
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.13.1"
25
+ "type-fest": "4.14.0"
26
26
  },
27
27
  "description": "Lightning Network client library",
28
28
  "devDependencies": {
29
- "tsd": "0.30.7",
29
+ "tsd": "0.31.0",
30
30
  "typescript": "5.4.3"
31
31
  },
32
32
  "engines": {
@@ -53,5 +53,5 @@
53
53
  "directory": "test/typescript"
54
54
  },
55
55
  "types": "index.d.ts",
56
- "version": "10.8.0"
56
+ "version": "10.8.2"
57
57
  }