lightning 5.16.3 → 5.16.6
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 +5 -1
- package/README.md +9 -0
- package/lnd_methods/invoices/subscribe_to_invoices.js +26 -4
- package/lnd_methods/offchain/get_channels.d.ts +1 -1
- package/lnd_methods/offchain/get_channels.js +1 -1
- package/package.json +12 -12
- package/test/lnd_methods/invoices/test_subscribe_to_invoices.js +2 -0
package/CHANGELOG.md
CHANGED
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,12 +2,15 @@ const EventEmitter = require('events');
|
|
|
2
2
|
|
|
3
3
|
const asyncDoUntil = require('async/doUntil');
|
|
4
4
|
|
|
5
|
-
const {
|
|
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;
|
|
13
|
+
const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
|
|
11
14
|
const updateEvent = 'invoice_updated';
|
|
12
15
|
|
|
13
16
|
/** Subscribe to invoices
|
|
@@ -94,6 +97,9 @@ module.exports = args => {
|
|
|
94
97
|
settle_index: !!confirmedAfter ? confirmedAfter.toString() : undefined,
|
|
95
98
|
});
|
|
96
99
|
|
|
100
|
+
// Terminate subscription when all listeners are removed
|
|
101
|
+
handleRemoveListener({subscription, events, emitter: eventEmitter});
|
|
102
|
+
|
|
97
103
|
// Subscription finished callback
|
|
98
104
|
const finished = err => {
|
|
99
105
|
if (!!eventEmitter.listenerCount('error')) {
|
|
@@ -107,14 +113,30 @@ module.exports = args => {
|
|
|
107
113
|
|
|
108
114
|
isFinished = true;
|
|
109
115
|
|
|
116
|
+
const listenerCount = eventEmitter.listenerCount(updateEvent);
|
|
117
|
+
|
|
118
|
+
// Exit early when there are no listeners
|
|
119
|
+
if (!listenerCount) {
|
|
120
|
+
return cbk(null, {listener_count: listenerCount});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Delay restart when there are listeners
|
|
110
124
|
return setTimeout(() => {
|
|
111
|
-
return cbk(null, {
|
|
112
|
-
listener_count: eventEmitter.listenerCount(updateEvent),
|
|
113
|
-
});
|
|
125
|
+
return cbk(null, {listener_count: listenerCount});
|
|
114
126
|
},
|
|
115
127
|
args.restart_delay_ms || restartSubscriptionMs);
|
|
116
128
|
};
|
|
117
129
|
|
|
130
|
+
// Finish early when all listeners are removed
|
|
131
|
+
eventEmitter.on('removeListener', () => {
|
|
132
|
+
// Exit early when there are still active listeners
|
|
133
|
+
if (!!sumOf(events.map(n => eventEmitter.listenerCount(n)))) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return finished();
|
|
138
|
+
});
|
|
139
|
+
|
|
118
140
|
// Relay invoice updates to the emitter
|
|
119
141
|
subscription.on('data', invoice => {
|
|
120
142
|
try {
|
|
@@ -44,7 +44,7 @@ export type GetChannelsResult = {
|
|
|
44
44
|
local_balance: number;
|
|
45
45
|
/** Local CSV Blocks Delay */
|
|
46
46
|
local_csv?: number;
|
|
47
|
-
/**
|
|
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]: <
|
|
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>
|
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.
|
|
11
|
-
"@grpc/proto-loader": "0.
|
|
10
|
+
"@grpc/grpc-js": "1.6.8",
|
|
11
|
+
"@grpc/proto-loader": "0.7.0",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "
|
|
13
|
+
"@types/node": "18.6.3",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.3",
|
|
16
16
|
"async": "3.2.4",
|
|
17
|
-
"asyncjs-util": "1.2.
|
|
18
|
-
"bitcoinjs-lib": "6.0.
|
|
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
|
|
27
|
-
"psbt": "2.
|
|
26
|
+
"invoices": "2.1.0",
|
|
27
|
+
"psbt": "2.7.1",
|
|
28
28
|
"tiny-secp256k1": "2.2.1",
|
|
29
|
-
"type-fest": "2.
|
|
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.
|
|
36
|
-
"typescript": "4.7.
|
|
37
|
-
"ws": "8.
|
|
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.
|
|
62
|
+
"version": "5.16.6"
|
|
63
63
|
}
|