lightning 9.8.1 → 9.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,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 9.8.2
4
+
5
+ - `subscribeToForwards`: Cancel subscription when there are no event listeners
6
+
3
7
  ## 9.8.1
4
8
 
5
9
  - `getPendingChannels`: Add `blocks_until_expiry` for opening funding expiry
@@ -4,9 +4,11 @@ const asyncDoUntil = require('async/doUntil');
4
4
  const {chanFormat} = require('bolt07');
5
5
 
6
6
  const {forwardFromHtlcEvent} = require('./../../lnd_responses');
7
+ const {handleRemoveListener} = require('./../../grpc');
7
8
  const {isLnd} = require('./../../lnd_requests');
8
9
 
9
10
  const event = 'forward';
11
+ const events = ['error', 'forward'];
10
12
  const method = 'subscribeHtlcEvents';
11
13
  const restartForwardListenerDelayMs = 1e3;
12
14
  const type = 'router';
@@ -70,6 +72,9 @@ module.exports = ({lnd}) => {
70
72
 
71
73
  const sub = lnd[type][method]({});
72
74
 
75
+ // Terminate subscription when all listeners are removed
76
+ handleRemoveListener({events, emitter, subscription: sub});
77
+
73
78
  sub.on('data', data => {
74
79
  // Exit early on subscribed events
75
80
  if (!!data && !!data.subscribed_event) {
package/package.json CHANGED
@@ -7,10 +7,10 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.8.17",
11
- "@grpc/proto-loader": "0.7.7",
10
+ "@grpc/grpc-js": "1.8.18",
11
+ "@grpc/proto-loader": "0.7.8",
12
12
  "@types/express": "4.17.17",
13
- "@types/node": "20.4.1",
13
+ "@types/node": "20.4.2",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.5",
16
16
  "async": "3.2.4",
@@ -26,7 +26,7 @@
26
26
  "invoices": "3.0.0",
27
27
  "psbt": "3.0.0",
28
28
  "tiny-secp256k1": "2.2.3",
29
- "type-fest": "3.12.0"
29
+ "type-fest": "4.0.0"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
@@ -58,5 +58,5 @@
58
58
  "directory": "test/typescript"
59
59
  },
60
60
  "types": "index.d.ts",
61
- "version": "9.8.1"
61
+ "version": "9.8.2"
62
62
  }
@@ -7,6 +7,8 @@ const {subscribeToForwards} = require('./../../../');
7
7
 
8
8
  const emitter = new EventEmitter();
9
9
 
10
+ emitter.cancel = () => {};
11
+
10
12
  const makeForwardResponse = () => {
11
13
  return {
12
14
  event_type: 'UNKNOWN',