lightning 5.16.2 → 5.16.5

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
- ## 5.16.2
3
+ ## 5.16.5
4
+
5
+ - `subscribeToInvoices`: Cancel subscription when there are no event listeners
6
+
7
+ ## 5.16.4
4
8
 
5
9
  - `signTransaction`: Add `root_hash` to support Taproot signatures with scripts
6
10
 
package/README.md CHANGED
@@ -18,6 +18,7 @@ Methods for working with the Lightning Network
18
18
  https://github.com/ibz/lightning-shell
19
19
  - [LNMarkets](https://twitter.com/lnmarkets) -
20
20
  https://github.com/lnmarkets/umbrel
21
+ - [mempool.space](https://mempool.space/) - https://github.com/mempool/mempool
21
22
  - [p2plnbot](https://telegram.me/lnp2pbot) - https://github.com/grunch/p2plnbot
22
23
  - [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
23
24
  - [stackernews](https://stacker.news/) -
@@ -64,6 +65,14 @@ const {lnd} = authenticatedLndGrpc({
64
65
  To access unauthenticated methods like the wallet unlocker, use
65
66
  `unauthenticatedLndGrpc` instead.
66
67
 
68
+ ## Debugging
69
+
70
+ If you encounter any issues connecting and wish to view detailed information
71
+ about the underlying grpc calls, you can run Node with these environment
72
+ variables set:
73
+
74
+ GRPC_VERBOSITY=DEBUG GRPC_TRACE=all node YOURSCRIPTNAME.js
75
+
67
76
  ## Methods
68
77
 
69
78
  - [addExternalSocket](https://github.com/alexbosworth/ln-service#addexternalsocket):
@@ -2,10 +2,12 @@ const EventEmitter = require('events');
2
2
 
3
3
  const asyncDoUntil = require('async/doUntil');
4
4
 
5
- const {rpcInvoiceAsInvoice} = require('./../../lnd_responses');
5
+ const {handleRemoveListener} = require('./../../grpc');
6
6
  const {isLnd} = require('./../../lnd_requests');
7
+ const {rpcInvoiceAsInvoice} = require('./../../lnd_responses');
7
8
 
8
9
  const connectionFailureMessage = 'failed to connect to all addresses';
10
+ const events = ['end', 'error', 'invoice_updated', 'status'];
9
11
  const msPerSec = 1e3;
10
12
  const restartSubscriptionMs = 1000 * 30;
11
13
  const updateEvent = 'invoice_updated';
@@ -94,6 +96,9 @@ module.exports = args => {
94
96
  settle_index: !!confirmedAfter ? confirmedAfter.toString() : undefined,
95
97
  });
96
98
 
99
+ // Terminate subscription when all listeners are removed
100
+ handleRemoveListener({subscription, events, emitter: eventEmitter});
101
+
97
102
  // Subscription finished callback
98
103
  const finished = err => {
99
104
  if (!!eventEmitter.listenerCount('error')) {
@@ -44,7 +44,7 @@ export type GetChannelsResult = {
44
44
  local_balance: number;
45
45
  /** Local CSV Blocks Delay */
46
46
  local_csv?: number;
47
- /** Remote Non-Enforceable Amount Tokens */
47
+ /** Local Non-Enforceable Amount Tokens */
48
48
  local_dust?: number;
49
49
  /** Local Initially Pushed Tokens */
50
50
  local_given?: number;
@@ -40,7 +40,7 @@ const type = 'default';
40
40
  is_private: <Channel Is Private Bool>
41
41
  local_balance: <Local Balance Tokens Number>
42
42
  [local_csv]: <Local CSV Blocks Delay Number>
43
- [local_dust]: <Remote Non-Enforceable Amount Tokens Number>
43
+ [local_dust]: <Local Non-Enforceable Amount Tokens Number>
44
44
  [local_given]: <Local Initially Pushed Tokens Number>
45
45
  [local_max_htlcs]: <Local Maximum Attached HTLCs Number>
46
46
  [local_max_pending_mtokens]: <Local Maximum Pending Millitokens String>
@@ -105,6 +105,10 @@ module.exports = (args, cbk) => {
105
105
  return cbk([400, 'ExpectedArrayOfRoutesToPayViaRoutes']);
106
106
  }
107
107
 
108
+ if (!!args.routes.filter(n => !n).length) {
109
+ return cbk([400, 'ExpectedArrayOfRoutesToAttemptPayingOver']);
110
+ }
111
+
108
112
  if (args.routes.findIndex(n => !isArray(n.hops)) !== notFound) {
109
113
  return cbk([400, 'ExpectedArrayOfHopsForPayViaRoute']);
110
114
  }
package/package.json CHANGED
@@ -7,15 +7,15 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.6.7",
11
- "@grpc/proto-loader": "0.6.12",
10
+ "@grpc/grpc-js": "1.6.8",
11
+ "@grpc/proto-loader": "0.7.0",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "17.0.38",
13
+ "@types/node": "18.6.2",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.3",
16
- "async": "3.2.3",
17
- "asyncjs-util": "1.2.9",
18
- "bitcoinjs-lib": "6.0.1",
16
+ "async": "3.2.4",
17
+ "asyncjs-util": "1.2.10",
18
+ "bitcoinjs-lib": "6.0.2",
19
19
  "bn.js": "5.2.1",
20
20
  "body-parser": "1.20.0",
21
21
  "bolt07": "1.8.2",
@@ -23,18 +23,18 @@
23
23
  "cbor": "8.1.0",
24
24
  "ecpair": "2.0.1",
25
25
  "express": "4.18.1",
26
- "invoices": "2.0.7",
27
- "psbt": "2.4.0",
26
+ "invoices": "2.1.0",
27
+ "psbt": "2.7.1",
28
28
  "tiny-secp256k1": "2.2.1",
29
- "type-fest": "2.13.0"
29
+ "type-fest": "2.18.0"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
33
33
  "@alexbosworth/node-fetch": "2.6.2",
34
34
  "@alexbosworth/tap": "15.0.11",
35
- "tsd": "0.20.0",
36
- "typescript": "4.7.2",
37
- "ws": "8.7.0"
35
+ "tsd": "0.22.0",
36
+ "typescript": "4.7.4",
37
+ "ws": "8.8.1"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=12.20"
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "5.16.2"
62
+ "version": "5.16.5"
63
63
  }
@@ -7,6 +7,8 @@ const {subscribeToInvoices} = require('./../../../');
7
7
 
8
8
  const emitter = new EventEmitter();
9
9
 
10
+ emitter.cancel = () => {};
11
+
10
12
  const makeLnd = ({err}) => ({default: {subscribeInvoices: ({}) => emitter}});
11
13
 
12
14
  const tests = [
@@ -57,6 +57,28 @@ const tests = [
57
57
  description: 'A non-empty array of routes is expected',
58
58
  error: [400, 'ExpectedArrayOfRoutesToPayViaRoutes'],
59
59
  },
60
+ {
61
+ args: {
62
+ lnd: {
63
+ default: {deletePayment, getInfo},
64
+ router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
65
+ },
66
+ routes: [null],
67
+ },
68
+ description: 'An array of non-empty routes is expected',
69
+ error: [400, 'ExpectedArrayOfRoutesToAttemptPayingOver'],
70
+ },
71
+ {
72
+ args: {
73
+ lnd: {
74
+ default: {deletePayment, getInfo},
75
+ router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
76
+ },
77
+ routes: [{}],
78
+ },
79
+ description: 'Routes are expected to have hops',
80
+ error: [400, 'ExpectedArrayOfHopsForPayViaRoute'],
81
+ },
60
82
  {
61
83
  args: {
62
84
  lnd: {