Skip to content

Commit 1c48c62

Browse files
Release 0.0.5 (#60)
* Updated dependencies for vulnerabilities fixes * Make env.sh compatible with zsh * library updates * Fix README.md typos * Add react router * Components breakup after root router added * Fix empty transactions channel helper text * Add tests * Fixed warning and cleanup * Adding local env.sh and indentation fixes * Replace listpeers.channels with listpeerchannels * Updated request to wait till node version available before fetching channels * Updated types and actions for listChannels * Updating store to aggregate channels from old listpeers.peers array * Updated UI components for listChannel's latest field names * Adjusted tests for listPeerChannels migration * Updated the mock data and checks with more realistic dataset * Remove msatoshi_received, msatoshi, msatoshi_sent from Payments and Invoices * Callback warning fix * RC Version compatibility check and tests * Add grpc option on connect wallet modal --------- Release 0.0.5 (#63) * Updated dependencies for vulnerabilities fixes * Make env.sh compatible with zsh * library updates * Fix README.md typos * Add react router * Components breakup after root router added * Fix empty transactions channel helper text * Add tests * Fixed warning and cleanup * Adding local env.sh and indentation fixes * Replace listpeers.channels with listpeerchannels * Updated request to wait till node version available before fetching channels * Updated types and actions for listChannels * Updating store to aggregate channels from old listpeers.peers array * Updated UI components for listChannel's latest field names * Adjusted tests for listPeerChannels migration * Updated the mock data and checks with more realistic dataset * Remove msatoshi_received, msatoshi, msatoshi_sent from Payments and Invoices * Callback warning fix * RC Version compatibility check and tests * Add grpc option on connect wallet modal --------- Co-Authored-By: evansmj <[email protected]>
1 parent b697973 commit 1c48c62

File tree

109 files changed

+9432
-4054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+9432
-4054
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ data/app/application-cln.log
88
data/app-2/*
99
application-cln.log
1010
.commando-env
11-
env.sh
1211
.commando
1312
data/app/config.json
14-
release
13+
release
14+
env-local.sh

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Build Stage
22
FROM node:18-buster AS cln-app-builder
33

4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
libcairo2-dev \
8+
libpango1.0-dev \
9+
libjpeg-dev \
10+
libgif-dev \
11+
librsvg2-dev
12+
413
# Create app directory
514
WORKDIR /app
615

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
```
4242
4343
- ### Environment Variables
44-
This application accepts & depeneds upon these variables to be passed through environment:
44+
This application accepts & depends upon these variables to be passed through environment:
4545
4646
```
4747
- APP_CORE_LIGHTNING_IP: IP address of this application (cln-application) container (required)
@@ -52,7 +52,6 @@
5252
- COMMANDO_CONFIG: Full Path including file name for commando auth with PUBKEY & RUNE (required)
5353
- APP_BITCOIN_NODE_IP: IP address of bitcoin node container (required)
5454
- APP_CORE_LIGHTNING_BITCOIN_NETWORK: Bitcoin network type (optional; for entrypoint.sh; valid values: bitcoin/signet/testnet/regtest)
55-
- APP_CORE_LIGHTNING_REST_IP: IP address of the c-lightning-REST container (optional; for connect wallet screen)
5655
- APP_CORE_LIGHTNING_REST_PORT: c-lightning-REST server port (optional; for connect wallet screen)
5756
- APP_CORE_LIGHTNING_REST_CERT_DIR: Path for c-lightning-REST certificates (optional; for connect wallet screen)
5857
- APP_CORE_LIGHTNING_DAEMON_GRPC_PORT: Core lightning's GRPC port (optional; future proofing for connect wallet screen)
@@ -65,7 +64,7 @@
6564
- CORE_LIGHTNING_PATH: Path for core lightning (optional; required for entrypoint.sh)
6665
```
6766
68-
Set these variables either via terminal OR by env.sh script OR by explicity loading varibles from .env files.
67+
Set these variables either via terminal OR by env.sh script OR by explicitly loading variables from .env files.
6968
Important Note: Environment variables take precedence over config.json variables. Like `SINGLE_SIGN_ON` will take higher precedence over
7069
`singleSignOn` from config.json.
7170
@@ -98,7 +97,7 @@
9897
```
9998
10099
- ### Start The Application
101-
- Setup envirnoment variables either via terminal OR by env.sh script OR by explicity loading varibles from .env files.
100+
- Setup environment variables either via terminal OR by env.sh script OR by explicitly loading variables from .env files.
102101
- Run `start` script for starting your application's server at port `APP_CORE_LIGHTNING_PORT`
103102
104103
```

apps/backend/dist/controllers/lightning.js

+4-40
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
import handleError from '../shared/error-handler.js';
22
import { LNMessage } from '../service/lightning.service.js';
33
import { logger } from '../shared/logger.js';
4-
import { LightningError } from '../models/errors.js';
5-
import { HttpStatusCode } from '../shared/consts.js';
64
const lnMessage = LNMessage;
7-
export const getNodesInfo = (lightningPeers) => {
8-
return Promise.all(lightningPeers.peers.map((peer) => {
9-
return new Promise((resolve, reject) => {
10-
lnMessage
11-
.call('listnodes', [peer.id])
12-
.then(data => {
13-
peer.alias = data.nodes[0].alias || peer.id.substring(0, 20);
14-
resolve(peer);
15-
})
16-
.catch(err => {
17-
peer.alias = peer.id.substring(0, 20);
18-
resolve(peer);
19-
});
20-
});
21-
}))
22-
.then(peersWithAliases => {
23-
logger.info('Peers with Aliases: ' + JSON.stringify(peersWithAliases));
24-
return { peers: peersWithAliases };
25-
})
26-
.catch(err => {
27-
logger.error('Controller caught lightning error from list nodes: ' + JSON.stringify(err));
28-
throw new LightningError('Controller caught lightning error from list nodes: ' + JSON.stringify(err), err, HttpStatusCode.LIGHTNING_SERVER, 'Get Network Nodes Information');
29-
});
30-
};
315
class LightningController {
326
callMethod(req, res, next) {
337
try {
@@ -40,20 +14,10 @@ class LightningController {
4014
': ' +
4115
JSON.stringify(commandRes));
4216
if (req.body.method && req.body.method === 'listpeers') {
43-
try {
44-
// Filter out ln message pubkey from peers list
45-
const lnmPubkey = lnMessage.getLNMsgPubkey();
46-
commandRes.peers = commandRes.peers.filter((peer) => peer.id !== lnmPubkey);
47-
// To get node aliases from liseNodes
48-
getNodesInfo(commandRes).then((resWithAliases) => {
49-
logger.info(resWithAliases);
50-
res.status(200).json(resWithAliases);
51-
});
52-
}
53-
catch (error) {
54-
logger.error('Lightning error from Get Nodes Info : ' + JSON.stringify(error));
55-
return handleError(error, req, res, next);
56-
}
17+
// Filter out ln message pubkey from peers list
18+
const lnmPubkey = lnMessage.getLNMsgPubkey();
19+
commandRes.peers = commandRes.peers.filter((peer) => peer.id !== lnmPubkey);
20+
res.status(200).json(commandRes);
5721
}
5822
else {
5923
res.status(200).json(commandRes);

apps/backend/dist/controllers/shared.js

+29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { logger } from '../shared/logger.js';
55
import handleError from '../shared/error-handler.js';
66
import { APIError } from '../models/errors.js';
77
import { setSharedApplicationConfig, overrideSettingsWithEnvVariables } from '../shared/utils.js';
8+
import { sep } from 'path';
89
class SharedController {
910
getApplicationSettings(req, res, next) {
1011
try {
@@ -37,7 +38,11 @@ class SharedController {
3738
getWalletConnectSettings(req, res, next) {
3839
try {
3940
logger.info('Getting Connection Settings');
41+
const CERTS_PATH = process.env.CORE_LIGHTNING_PATH + sep + process.env.APP_BITCOIN_NETWORK + sep;
4042
let macaroon = '';
43+
let clientKey = '';
44+
let clientCert = '';
45+
let caCert = '';
4146
let packageData = '{ version: "0.0.4" }';
4247
if (fs.existsSync(APP_CONSTANTS.MACAROON_PATH)) {
4348
logger.info('Getting REST Access Macaroon from ' + process.env.APP_CORE_LIGHTNING_REST_CERT_DIR);
@@ -46,12 +51,36 @@ class SharedController {
4651
if (fs.existsSync('package.json')) {
4752
packageData = Buffer.from(fs.readFileSync('package.json')).toString();
4853
}
54+
if (fs.existsSync(CERTS_PATH + 'client-key.pem')) {
55+
clientKey = fs.readFileSync(CERTS_PATH + 'client-key.pem').toString();
56+
clientKey = clientKey
57+
.replace(/(\r\n|\n|\r)/gm, '')
58+
.replace('-----BEGIN PRIVATE KEY-----', '')
59+
.replace('-----END PRIVATE KEY-----', '');
60+
}
61+
if (fs.existsSync(CERTS_PATH + 'client.pem')) {
62+
clientCert = fs.readFileSync(CERTS_PATH + 'client.pem').toString();
63+
clientCert = clientCert
64+
.replace(/(\r\n|\n|\r)/gm, '')
65+
.replace('-----BEGIN CERTIFICATE-----', '')
66+
.replace('-----END CERTIFICATE-----', '');
67+
}
68+
if (fs.existsSync(CERTS_PATH + 'ca.pem')) {
69+
caCert = fs.readFileSync(CERTS_PATH + 'ca.pem').toString();
70+
caCert = caCert
71+
.replace(/(\r\n|\n|\r)/gm, '')
72+
.replace('-----BEGIN CERTIFICATE-----', '')
73+
.replace('-----END CERTIFICATE-----', '');
74+
}
4975
const CONNECT_WALLET_SETTINGS = {
5076
LOCAL_HOST: process.env.LOCAL_HOST || '',
5177
DEVICE_DOMAIN_NAME: process.env.DEVICE_DOMAIN_NAME || '',
5278
TOR_HOST: process.env.APP_CORE_LIGHTNING_REST_HIDDEN_SERVICE || '',
5379
WS_PORT: process.env.APP_CORE_LIGHTNING_WEBSOCKET_PORT || '',
5480
GRPC_PORT: process.env.APP_CORE_LIGHTNING_DAEMON_GRPC_PORT || '',
81+
CLIENT_KEY: clientKey,
82+
CLIENT_CERT: clientCert,
83+
CA_CERT: caCert,
5584
REST_PORT: process.env.APP_CORE_LIGHTNING_REST_PORT || '',
5685
REST_MACAROON: macaroon,
5786
CLN_NODE_IP: process.env.APP_CORE_LIGHTNING_DAEMON_IP || '',

apps/backend/dist/shared/error-handler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function handleError(error, req, res, next) {
1010
? JSON.stringify(error)
1111
: typeof error === 'string'
1212
? error
13-
: 'Unknow Error!';
13+
: 'Unknown Error!';
1414
logger.error(message, route, error.stack);
1515
return res.status(error.statusCode || HttpStatusCode.INTERNAL_SERVER).json(message);
1616
}

apps/backend/package.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cln-application-backend",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Core lightning application backend",
55
"private": true,
66
"license": "MIT",
@@ -11,28 +11,28 @@
1111
"start": "tsc --project tsconfig.json --watch & prettier --write source/ & nodemon ./dist/server.js",
1212
"watch": "tsc --project tsconfig.json --watch & prettier --write source/"
1313
},
14-
"devDependencies": {
15-
"@types/cookie-parser": "^1.4.3",
16-
"@types/cors": "^2.8.13",
17-
"@types/csurf": "^1.11.2",
18-
"@types/express": "^4.17.15",
19-
"@types/jsonwebtoken": "^9.0.2",
20-
"@types/morgan": "^1.9.3",
21-
"@types/node": "^18.11.18",
22-
"nodemon": "^2.0.20",
23-
"prettier": "^2.8.1",
24-
"tslint": "^6.1.3",
25-
"typescript": "^4.9.4"
26-
},
2714
"dependencies": {
2815
"cookie-parser": "^1.4.6",
2916
"cors": "^2.8.5",
3017
"csurf": "^1.11.0",
3118
"express": "^4.18.2",
3219
"express-winston": "^4.2.0",
33-
"jsonwebtoken": "^9.0.1",
34-
"lnmessage": "^0.2.2",
20+
"jsonwebtoken": "^9.0.2",
21+
"lnmessage": "^0.2.6",
3522
"ts-node": "^10.9.1",
36-
"winston": "^3.8.2"
23+
"winston": "^3.11.0"
24+
},
25+
"devDependencies": {
26+
"@types/cookie-parser": "^1.4.6",
27+
"@types/cors": "^2.8.17",
28+
"@types/csurf": "^1.11.5",
29+
"@types/express": "^4.17.21",
30+
"@types/jsonwebtoken": "^9.0.5",
31+
"@types/morgan": "^1.9.9",
32+
"@types/node": "^20.9.4",
33+
"nodemon": "^3.0.1",
34+
"prettier": "^3.1.0",
35+
"tslint": "^6.1.3",
36+
"typescript": "^5.3.2"
3737
}
3838
}

apps/backend/source/controllers/lightning.ts

+4-45
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,6 @@ import { HttpStatusCode } from '../shared/consts.js';
77

88
const lnMessage: LightningService = LNMessage;
99

10-
export const getNodesInfo = (lightningPeers: any) => {
11-
return Promise.all(
12-
lightningPeers.peers.map((peer: any) => {
13-
return new Promise((resolve, reject) => {
14-
lnMessage
15-
.call('listnodes', [peer.id])
16-
.then(data => {
17-
peer.alias = data.nodes[0].alias || peer.id.substring(0, 20);
18-
resolve(peer);
19-
})
20-
.catch(err => {
21-
peer.alias = peer.id.substring(0, 20);
22-
resolve(peer);
23-
});
24-
});
25-
}),
26-
)
27-
.then(peersWithAliases => {
28-
logger.info('Peers with Aliases: ' + JSON.stringify(peersWithAliases));
29-
return { peers: peersWithAliases };
30-
})
31-
.catch(err => {
32-
logger.error('Controller caught lightning error from list nodes: ' + JSON.stringify(err));
33-
throw new LightningError(
34-
'Controller caught lightning error from list nodes: ' + JSON.stringify(err),
35-
err,
36-
HttpStatusCode.LIGHTNING_SERVER,
37-
'Get Network Nodes Information',
38-
);
39-
});
40-
};
41-
4210
class LightningController {
4311
callMethod(req: Request, res: Response, next: NextFunction) {
4412
try {
@@ -53,19 +21,10 @@ class LightningController {
5321
JSON.stringify(commandRes),
5422
);
5523
if (req.body.method && req.body.method === 'listpeers') {
56-
try {
57-
// Filter out ln message pubkey from peers list
58-
const lnmPubkey = lnMessage.getLNMsgPubkey();
59-
commandRes.peers = commandRes.peers.filter((peer: any) => peer.id !== lnmPubkey);
60-
// To get node aliases from liseNodes
61-
getNodesInfo(commandRes).then((resWithAliases: any) => {
62-
logger.info(resWithAliases);
63-
res.status(200).json(resWithAliases);
64-
});
65-
} catch (error: any) {
66-
logger.error('Lightning error from Get Nodes Info : ' + JSON.stringify(error));
67-
return handleError(error, req, res, next);
68-
}
24+
// Filter out ln message pubkey from peers list
25+
const lnmPubkey = lnMessage.getLNMsgPubkey();
26+
commandRes.peers = commandRes.peers.filter((peer: any) => peer.id !== lnmPubkey);
27+
res.status(200).json(commandRes);
6928
} else {
7029
res.status(200).json(commandRes);
7130
}

apps/backend/source/controllers/shared.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { logger } from '../shared/logger.js';
77
import handleError from '../shared/error-handler.js';
88
import { APIError } from '../models/errors.js';
99
import { setSharedApplicationConfig, overrideSettingsWithEnvVariables } from '../shared/utils.js';
10+
import { sep } from 'path';
1011

1112
class SharedController {
1213
getApplicationSettings(req: Request, res: Response, next: NextFunction) {
@@ -44,9 +45,13 @@ class SharedController {
4445
getWalletConnectSettings(req: Request, res: Response, next: NextFunction) {
4546
try {
4647
logger.info('Getting Connection Settings');
48+
const CERTS_PATH =
49+
process.env.CORE_LIGHTNING_PATH + sep + process.env.APP_BITCOIN_NETWORK + sep;
4750
let macaroon = '';
51+
let clientKey = '';
52+
let clientCert = '';
53+
let caCert = '';
4854
let packageData = '{ version: "0.0.4" }';
49-
5055
if (fs.existsSync(APP_CONSTANTS.MACAROON_PATH)) {
5156
logger.info(
5257
'Getting REST Access Macaroon from ' + process.env.APP_CORE_LIGHTNING_REST_CERT_DIR,
@@ -56,12 +61,36 @@ class SharedController {
5661
if (fs.existsSync('package.json')) {
5762
packageData = Buffer.from(fs.readFileSync('package.json')).toString();
5863
}
64+
if (fs.existsSync(CERTS_PATH + 'client-key.pem')) {
65+
clientKey = fs.readFileSync(CERTS_PATH + 'client-key.pem').toString();
66+
clientKey = clientKey
67+
.replace(/(\r\n|\n|\r)/gm, '')
68+
.replace('-----BEGIN PRIVATE KEY-----', '')
69+
.replace('-----END PRIVATE KEY-----', '');
70+
}
71+
if (fs.existsSync(CERTS_PATH + 'client.pem')) {
72+
clientCert = fs.readFileSync(CERTS_PATH + 'client.pem').toString();
73+
clientCert = clientCert
74+
.replace(/(\r\n|\n|\r)/gm, '')
75+
.replace('-----BEGIN CERTIFICATE-----', '')
76+
.replace('-----END CERTIFICATE-----', '');
77+
}
78+
if (fs.existsSync(CERTS_PATH + 'ca.pem')) {
79+
caCert = fs.readFileSync(CERTS_PATH + 'ca.pem').toString();
80+
caCert = caCert
81+
.replace(/(\r\n|\n|\r)/gm, '')
82+
.replace('-----BEGIN CERTIFICATE-----', '')
83+
.replace('-----END CERTIFICATE-----', '');
84+
}
5985
const CONNECT_WALLET_SETTINGS = {
6086
LOCAL_HOST: process.env.LOCAL_HOST || '',
6187
DEVICE_DOMAIN_NAME: process.env.DEVICE_DOMAIN_NAME || '',
6288
TOR_HOST: process.env.APP_CORE_LIGHTNING_REST_HIDDEN_SERVICE || '',
6389
WS_PORT: process.env.APP_CORE_LIGHTNING_WEBSOCKET_PORT || '',
6490
GRPC_PORT: process.env.APP_CORE_LIGHTNING_DAEMON_GRPC_PORT || '',
91+
CLIENT_KEY: clientKey,
92+
CLIENT_CERT: clientCert,
93+
CA_CERT: caCert,
6594
REST_PORT: process.env.APP_CORE_LIGHTNING_REST_PORT || '',
6695
REST_MACAROON: macaroon,
6796
CLN_NODE_IP: process.env.APP_CORE_LIGHTNING_DAEMON_IP || '',

apps/backend/source/models/lightning.ts

-22
This file was deleted.

0 commit comments

Comments
 (0)