ln-service 56.13.0 → 57.0.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,18 @@
1
1
  # Versions
2
2
 
3
+ ## 57.0.0
4
+
5
+ - Add support for LND 0.17.0
6
+
7
+ ### Breaking Changes
8
+
9
+ - End support for node.js 16, require 18 or higher
10
+ - Remove method `grpcProxyServer`
11
+
12
+ ## 56.14.0
13
+
14
+ - `openChannel`: Add `is_allowing_minimal_reserve` to allow no reserve on peer
15
+
3
16
  ## 56.13.0
4
17
 
5
18
  - `openChannels`: Add `is_simplified_taproot` to make a simplified taproot chan
package/README.md CHANGED
@@ -9,6 +9,7 @@ through npm.
9
9
 
10
10
  Supported LND versions:
11
11
 
12
+ - v0.17.0-beta
12
13
  - v0.16.0-beta to v0.16.4-beta
13
14
  - v0.15.2-beta to v0.15.5-beta
14
15
  - v0.14.4-beta to v0.14.5-beta
@@ -3606,59 +3607,6 @@ const createInvoices = authenticatedLndGrpc({cert, macaroon, socket});
3606
3607
  const {request} = await createInvoice({lnd: createInvoices.lnd, tokens: 1});
3607
3608
  ```
3608
3609
 
3609
- ### grpcProxyServer
3610
-
3611
- Get a gRPC proxy server
3612
-
3613
- {
3614
- [bind]: <Bind to Address String>
3615
- [cert]: <LND Cert Base64 String>
3616
- log: <Log Function>
3617
- path: <Router Path String>
3618
- port: <Listen Port Number>
3619
- socket: <LND Socket String>
3620
- stream: <Log Write Stream Object>
3621
- }
3622
-
3623
- @returns
3624
- {
3625
- app: <Express Application Object>
3626
- server: <Web Server Object>
3627
- wss: <WebSocket Server Object>
3628
- }
3629
-
3630
- ```node
3631
- const {getWalletInfo} = require('ln-service');
3632
- const {lndGateway} = require('lightning');
3633
- const request = require('@alexbosworth/request');
3634
- const websocket = require('ws');
3635
- const {Writable} = require('stream');
3636
-
3637
- const log = output => log(output);
3638
- const path = '/lnd/';
3639
- const port = 8050;
3640
-
3641
- const {app, server, wss} = grpcProxyServer({
3642
- log,
3643
- path,
3644
- port,
3645
- cert: base64Encoded64TlsCertFileString,
3646
- socket: 'localhost:10009',
3647
- stream: new Writable({write: (chunk, encoding, cbk) => cbk()}),
3648
- });
3649
-
3650
- // Create an authenticated LND for the gRPC REST gateway
3651
- const {lnd} = lndGateway({
3652
- request,
3653
- websocket,
3654
- macaroon: base64EncodedMacaroonFileString,
3655
- url: `http://localhost:${port}${path}`,
3656
- });
3657
-
3658
- // Make a request to a gRPC method through the REST proxy
3659
- const nodeInfo = await getWalletInfo({lnd});
3660
- ```
3661
-
3662
3610
  ### isDestinationPayable
3663
3611
 
3664
3612
  Determine if a payment destination is actually payable by probing it
@@ -3758,6 +3706,8 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
3758
3706
  `base_fee_mtokens` is not supported on LND 0.15.5 and below
3759
3707
  `fee_rate` is not supported on LND 0.15.5 and below
3760
3708
 
3709
+ `is_allowing_minimal_reserve` is not supported on LND 0.15.0 and below
3710
+
3761
3711
  `is_max_funding` is not supported on LND 0.16.4 and below
3762
3712
 
3763
3713
  `description` is not supported on LND 0.16.4 and below
@@ -3778,6 +3728,7 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
3778
3728
  transaction_id: <Fund With Unspent Transaction Id Hex String>
3779
3729
  transaction_vout: <Fund With Unspent Transaction Output Index Number>
3780
3730
  }]
3731
+ [is_allowing_minimal_reserve]: <Allow Peer to Have Minimal Reserve Bool>
3781
3732
  [is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
3782
3733
  [is_private]: <Channel is Private Bool> // Defaults to false
3783
3734
  [is_simplified_taproot]: <Channel is Simplified Taproot Type Bool>
package/package.json CHANGED
@@ -8,13 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "bolt07": "1.8.4",
11
- "cors": "2.8.5",
12
- "express": "4.18.2",
13
11
  "invoices": "3.0.0",
14
- "lightning": "9.13.0",
15
- "macaroon": "3.0.4",
16
- "morgan": "1.10.0",
17
- "ws": "8.13.0"
12
+ "lightning": "10.0.0",
13
+ "macaroon": "3.0.4"
18
14
  },
19
15
  "description": "Interaction helper for your Lightning Network daemon",
20
16
  "devDependencies": {
@@ -24,22 +20,22 @@
24
20
  "asyncjs-util": "1.2.12",
25
21
  "bip32": "4.0.0",
26
22
  "bip66": "1.1.5",
27
- "bitcoinjs-lib": "6.1.3",
23
+ "bitcoinjs-lib": "6.1.5",
28
24
  "bn.js": "5.2.1",
29
25
  "bs58check": "3.0.1",
30
26
  "ecpair": "2.1.0",
31
- "ln-docker-daemons": "5.1.3",
27
+ "ln-docker-daemons": "6.0.1",
32
28
  "p2tr": "2.0.0",
33
29
  "portfinder": "1.0.32",
34
30
  "psbt": "3.0.0",
35
- "rimraf": "5.0.1",
31
+ "rimraf": "5.0.5",
36
32
  "secp256k1": "5.0.0",
37
33
  "tiny-secp256k1": "2.2.3",
38
- "uuid": "9.0.0",
34
+ "uuid": "9.0.1",
39
35
  "varuint-bitcoin": "1.1.2"
40
36
  },
41
37
  "engines": {
42
- "node": ">=16"
38
+ "node": ">=18"
43
39
  },
44
40
  "keywords": [
45
41
  "bitcoin",
@@ -56,6 +52,7 @@
56
52
  "url": "https://github.com/alexbosworth/ln-service.git"
57
53
  },
58
54
  "scripts": {
55
+ "integration-test-0.17.0": "DOCKER_LND_VERSION=v0.17.0-beta npm run test",
59
56
  "integration-test-0.16.4": "DOCKER_LND_VERSION=v0.16.4-beta npm run test",
60
57
  "integration-test-0.16.3": "DOCKER_LND_VERSION=v0.16.3-beta npm run test",
61
58
  "integration-test-0.16.2": "DOCKER_LND_VERSION=v0.16.2-beta npm run test",
@@ -69,5 +66,5 @@
69
66
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
70
67
  "test": "echo $DOCKER_LND_VERSION && node test/runner"
71
68
  },
72
- "version": "56.13.0"
69
+ "version": "57.0.0"
73
70
  }
@@ -0,0 +1,92 @@
1
+ const {equal} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const asyncRetry = require('async/retry');
5
+ const {spawnLightningCluster} = require('ln-docker-daemons');
6
+
7
+ const {addPeer} = require('./../../');
8
+ const {getChannels} = require('./../../');
9
+ const {getWalletInfo} = require('./../../');
10
+ const {openChannel} = require('./../../');
11
+ const {subscribeToOpenRequests} = require('./../../');
12
+
13
+ const channelCapacityTokens = 1e6;
14
+ const confirmationCount = 6;
15
+ const count = 100;
16
+ const dustLimit = 354;
17
+ const interval = 10;
18
+ const size = 2;
19
+ const times = 2000;
20
+
21
+ // Open a channel with a low channel reserve
22
+ test(`Open channel but allow a minimal channel reserve`, async () => {
23
+ const {kill, nodes} = await spawnLightningCluster({size});
24
+
25
+ const [control, target] = nodes;
26
+
27
+ const {id, lnd} = control;
28
+
29
+ await target.generate({count});
30
+
31
+ await addPeer({lnd, public_key: target.id, socket: target.socket});
32
+
33
+ await asyncRetry({interval, times}, async () => {
34
+ const wallet = await getWalletInfo({lnd: target.lnd});
35
+
36
+ if (!wallet.is_synced_to_chain) {
37
+ throw new Error('ExpectedWalletSyncedToChain');
38
+ }
39
+ });
40
+
41
+ const acceptSub = subscribeToOpenRequests({lnd});
42
+
43
+ acceptSub.on('channel_request', request => {
44
+ request.accept({
45
+ min_confirmations: 1,
46
+ remote_csv: 999,
47
+ remote_reserve: 354,
48
+ remote_max_htlcs: 20,
49
+ remote_max_pending_mtokens: '200000',
50
+ remote_min_htlc_mtokens: '2000',
51
+ });
52
+
53
+ return;
54
+ });
55
+
56
+ try {
57
+ await asyncRetry({interval, times}, async () => {
58
+ return await openChannel({
59
+ lnd: target.lnd,
60
+ is_private: true,
61
+ is_allowing_minimal_reserve: true,
62
+ local_tokens: channelCapacityTokens,
63
+ partner_public_key: control.id,
64
+ socket: control.socket,
65
+ });
66
+ });
67
+ } catch (err) {
68
+ equal(err, null, 'Expected no error when a channel is accepted');
69
+ }
70
+
71
+ acceptSub.removeAllListeners();
72
+
73
+ await target.generate({count: confirmationCount});
74
+
75
+ const channel = await asyncRetry({interval, times}, async () => {
76
+ const [channel] = (await getChannels({lnd})).channels;
77
+
78
+ await control.generate({});
79
+
80
+ if (!channel) {
81
+ throw new Error('ExpectedChannelCreation');
82
+ }
83
+
84
+ return channel;
85
+ });
86
+
87
+ equal(channel.remote_reserve, dustLimit, 'Got minimal reserve value');
88
+
89
+ await kill({});
90
+
91
+ return;
92
+ });
@@ -1,76 +0,0 @@
1
- const {createServer} = require('https');
2
-
3
- const cors = require('cors');
4
- const {emitGrpcEvents} = require('lightning');
5
- const express = require('express');
6
- const {grpcRouter} = require('lightning');
7
- const logger = require('morgan');
8
- const {Server} = require('ws');
9
-
10
- const defaultBind = '127.0.0.1';
11
- const hexAsBuffer = hex => Buffer.from(hex, 'hex');
12
- const logFormat = ':method :url :status - :response-time ms - :user-agent';
13
- const makeServer = (app, cert, key) => createServer({cert, key}, app);
14
-
15
- /** Get a gRPC proxy server
16
-
17
- {
18
- [bind]: <Bind to Address String>
19
- [cert]: <LND Cert Base64 String>
20
- log: <Log Function>
21
- path: <Router Path String>
22
- port: <Listen Port Number>
23
- socket: <LND Socket String>
24
- stream: <Log Write Stream Object>
25
- [tls]: {
26
- cert: <Server Cert Hex String>
27
- key: <Server Key Hex String>
28
- port: <TLS Server Port Number>
29
- }
30
- }
31
-
32
- @returns
33
- {
34
- app: <Express Application Object>
35
- [secure]: {
36
- server: <HTTPS Server Object>
37
- wss: <HTTPS WebSocket Server Object>
38
- }
39
- server: <Web Server Object>
40
- wss: <WebSocket Server Object>
41
- }
42
- */
43
- module.exports = ({bind, cert, log, path, port, socket, stream, tls}) => {
44
- const app = express();
45
-
46
- const server = app
47
- .listen(port, () => log(null, `Listening: ${port}`))
48
- .on('error', err => log([500, 'ListenError', err]));
49
-
50
- if (!!tls) {
51
- const tlsCert = hexAsBuffer(tls.cert);
52
- const tlsKey = hexAsBuffer(tls.key);
53
-
54
- const secure = makeServer(app, tlsCert, tlsKey);
55
-
56
- const secureWss = new Server({server: secure});
57
-
58
- secureWss.on('connection', ws => emitGrpcEvents({cert, socket, ws}));
59
-
60
- secure.listen(tls.port);
61
-
62
- log(null, `Listening for TLS: ${tls.port}`);
63
- }
64
-
65
- app.use(cors());
66
- app.use(logger(logFormat, {stream}));
67
-
68
- app.use(path, grpcRouter({cert, socket}));
69
-
70
- const wss = new Server({server});
71
-
72
- wss.on('connection', ws => emitGrpcEvents({cert, socket, ws}));
73
- wss.on('listening', () => {});
74
-
75
- return {app, server, wss};
76
- };
package/routers/index.js DELETED
@@ -1,3 +0,0 @@
1
- const grpcProxyServer = require('./grpc_proxy_server');
2
-
3
- module.exports = {grpcProxyServer};