Skip to content

Commit da15112

Browse files
Connect wallet and protocol updates
1 parent b84cc95 commit da15112

26 files changed

+96
-69
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- APP_CORE_LIGHTNING_REST_HIDDEN_SERVICE: REST hidden service url (optional; for connect wallet screen)
5555
- LOCAL_HOST: Docker setup variable (optional; for connect wallet screen)
5656
- APP_MODE: Mode for logging and other settings (optional; valid values: production/development/testing)
57+
- APP_PROTOCOL: Protocol on which the application will be served (optional; valid values: http/https)
5758
- CORE_LIGHTNING_PATH: Path for core lightning (optional; required for entrypoint.sh)
5859
```
5960

apps/backend/dist/controllers/shared.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SharedController {
3737
}
3838
const CONNECT_WALLET_SETTINGS = {
3939
LOCAL_HOST: process.env.LOCAL_HOST || '',
40+
DEVICE_DOMAIN_NAME: process.env.DEVICE_DOMAIN_NAME || '',
4041
TOR_HOST: process.env.APP_CORE_LIGHTNING_REST_HIDDEN_SERVICE || '',
4142
WS_PORT: process.env.APP_CORE_LIGHTNING_WEBSOCKET_PORT || '',
4243
GRPC_PORT: process.env.APP_CORE_LIGHTNING_DAEMON_GRPC_PORT || '',

apps/backend/dist/server.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ let directoryName = dirname(fileURLToPath(import.meta.url));
1717
let routes = [];
1818
const app = express();
1919
const server = http.createServer(app);
20-
const LIGHTNING_PORT = APP_CONSTANTS.APP_MODE === Environment.PRODUCTION
21-
? normalizePort(process.env.APP_CORE_LIGHTNING_PORT || '2103')
22-
: 4300;
23-
const APP_CORE_LIGHTNING_DAEMON_IP = process.env.APP_CORE_LIGHTNING_IP || 'localhost';
20+
const LIGHTNING_PORT = normalizePort(process.env.APP_CORE_LIGHTNING_PORT || '2103');
21+
const APP_CORE_LIGHTNING_IP = process.env.APP_CORE_LIGHTNING_IP || 'localhost';
22+
const APP_PROTOCOL = process.env.APP_PROTOCOL || 'http';
2423
function normalizePort(val) {
2524
var port = parseInt(val, 10);
2625
if (isNaN(port)) {
@@ -43,7 +42,9 @@ app.use((req, res, next) => {
4342
});
4443
const corsOptions = {
4544
methods: 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
46-
origin: 'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT,
45+
origin: APP_CONSTANTS.APP_MODE === Environment.PRODUCTION
46+
? APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT
47+
: APP_PROTOCOL + '://localhost:4300',
4748
credentials: true,
4849
allowedHeaders: 'Content-Type, X-XSRF-TOKEN, XSRF-TOKEN',
4950
};
@@ -64,21 +65,24 @@ const throwApiError = (err) => {
6465
logger.error('Server error: ' + err);
6566
switch (err.code) {
6667
case 'EACCES':
67-
return new APIError('http://' +
68-
APP_CORE_LIGHTNING_DAEMON_IP +
68+
return new APIError(APP_PROTOCOL +
69+
'://' +
70+
APP_CORE_LIGHTNING_IP +
6971
':' +
7072
LIGHTNING_PORT +
71-
' requires elevated privileges', 'http://' +
72-
APP_CORE_LIGHTNING_DAEMON_IP +
73+
' requires elevated privileges', APP_PROTOCOL +
74+
'://' +
75+
APP_CORE_LIGHTNING_IP +
7376
':' +
7477
LIGHTNING_PORT +
75-
' requires elevated privileges', HttpStatusCode.ACCESS_DENIED, 'http://' +
76-
APP_CORE_LIGHTNING_DAEMON_IP +
78+
' requires elevated privileges', HttpStatusCode.ACCESS_DENIED, APP_PROTOCOL +
79+
'://' +
80+
APP_CORE_LIGHTNING_IP +
7781
':' +
7882
LIGHTNING_PORT +
7983
' requires elevated privileges');
8084
case 'EADDRINUSE':
81-
return new APIError('http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use', 'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use', HttpStatusCode.ADDR_IN_USE, 'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use');
85+
return new APIError(APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use', APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use', HttpStatusCode.ADDR_IN_USE, APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use');
8286
case 'ECONNREFUSED':
8387
return new APIError('Server is down/locked', 'Server is down/locked', HttpStatusCode.UNAUTHORIZED, 'Server is down/locked');
8488
case 'EBADCSRFTOKEN':
@@ -88,5 +92,5 @@ const throwApiError = (err) => {
8892
}
8993
};
9094
server.on('error', throwApiError);
91-
server.on('listening', () => logger.warn('Server running at http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT));
92-
server.listen({ port: LIGHTNING_PORT, host: APP_CORE_LIGHTNING_DAEMON_IP });
95+
server.on('listening', () => logger.warn('Server running at ' + APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT));
96+
server.listen({ port: LIGHTNING_PORT, host: APP_CORE_LIGHTNING_IP });

apps/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cln-application-backend",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Core lightning application backend",
55
"private": true,
66
"license": "MIT",

apps/backend/source/controllers/shared.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SharedController {
4646
}
4747
const CONNECT_WALLET_SETTINGS = {
4848
LOCAL_HOST: process.env.LOCAL_HOST || '',
49+
DEVICE_DOMAIN_NAME: process.env.DEVICE_DOMAIN_NAME || '',
4950
TOR_HOST: process.env.APP_CORE_LIGHTNING_REST_HIDDEN_SERVICE || '',
5051
WS_PORT: process.env.APP_CORE_LIGHTNING_WEBSOCKET_PORT || '',
5152
GRPC_PORT: process.env.APP_CORE_LIGHTNING_DAEMON_GRPC_PORT || '',

apps/backend/source/server.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ let routes: Array<CommonRoutesConfig> = [];
2222
const app: express.Application = express();
2323
const server: http.Server = http.createServer(app);
2424

25-
const LIGHTNING_PORT =
26-
APP_CONSTANTS.APP_MODE === Environment.PRODUCTION
27-
? normalizePort(process.env.APP_CORE_LIGHTNING_PORT || '2103')
28-
: 4300;
29-
const APP_CORE_LIGHTNING_DAEMON_IP = process.env.APP_CORE_LIGHTNING_IP || 'localhost';
25+
const LIGHTNING_PORT = normalizePort(process.env.APP_CORE_LIGHTNING_PORT || '2103');
26+
const APP_CORE_LIGHTNING_IP = process.env.APP_CORE_LIGHTNING_IP || 'localhost';
27+
const APP_PROTOCOL = process.env.APP_PROTOCOL || 'http';
3028

3129
function normalizePort(val: string) {
3230
var port = parseInt(val, 10);
@@ -54,7 +52,10 @@ app.use((req, res, next) => {
5452
});
5553
const corsOptions = {
5654
methods: 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
57-
origin: 'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT,
55+
origin:
56+
APP_CONSTANTS.APP_MODE === Environment.PRODUCTION
57+
? APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT
58+
: APP_PROTOCOL + '://localhost:4300',
5859
credentials: true,
5960
allowedHeaders: 'Content-Type, X-XSRF-TOKEN, XSRF-TOKEN',
6061
};
@@ -81,29 +82,32 @@ const throwApiError = (err: any) => {
8182
switch (err.code) {
8283
case 'EACCES':
8384
return new APIError(
84-
'http://' +
85-
APP_CORE_LIGHTNING_DAEMON_IP +
85+
APP_PROTOCOL +
86+
'://' +
87+
APP_CORE_LIGHTNING_IP +
8688
':' +
8789
LIGHTNING_PORT +
8890
' requires elevated privileges',
89-
'http://' +
90-
APP_CORE_LIGHTNING_DAEMON_IP +
91+
APP_PROTOCOL +
92+
'://' +
93+
APP_CORE_LIGHTNING_IP +
9194
':' +
9295
LIGHTNING_PORT +
9396
' requires elevated privileges',
9497
HttpStatusCode.ACCESS_DENIED,
95-
'http://' +
96-
APP_CORE_LIGHTNING_DAEMON_IP +
98+
APP_PROTOCOL +
99+
'://' +
100+
APP_CORE_LIGHTNING_IP +
97101
':' +
98102
LIGHTNING_PORT +
99103
' requires elevated privileges',
100104
);
101105
case 'EADDRINUSE':
102106
return new APIError(
103-
'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use',
104-
'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use',
107+
APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use',
108+
APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use',
105109
HttpStatusCode.ADDR_IN_USE,
106-
'http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT + ' is already in use',
110+
APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT + ' is already in use',
107111
);
108112
case 'ECONNREFUSED':
109113
return new APIError(
@@ -131,6 +135,8 @@ const throwApiError = (err: any) => {
131135

132136
server.on('error', throwApiError);
133137
server.on('listening', () =>
134-
logger.warn('Server running at http://' + APP_CORE_LIGHTNING_DAEMON_IP + ':' + LIGHTNING_PORT),
138+
logger.warn(
139+
'Server running at ' + APP_PROTOCOL + '://' + APP_CORE_LIGHTNING_IP + ':' + LIGHTNING_PORT,
140+
),
135141
);
136-
server.listen({ port: LIGHTNING_PORT, host: APP_CORE_LIGHTNING_DAEMON_IP });
142+
server.listen({ port: LIGHTNING_PORT, host: APP_CORE_LIGHTNING_IP });
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"files": {
3-
"main.css": "/static/css/main.39d05f2d.css",
4-
"main.js": "/static/js/main.212bf1ad.js",
3+
"main.css": "/static/css/main.fa3c1194.css",
4+
"main.js": "/static/js/main.60ee4b12.js",
55
"static/media/Inter-Bold.ttf": "/static/media/Inter-Bold.88fa7ae373b07b41ecce.ttf",
66
"static/media/Inter-SemiBold.ttf": "/static/media/Inter-SemiBold.4d56bb21f2399db8ad48.ttf",
77
"static/media/Inter-Medium.ttf": "/static/media/Inter-Medium.6dcbc9bed1ec438907ee.ttf",
88
"static/media/Inter-Thin.ttf": "/static/media/Inter-Thin.f341ca512063c66296d1.ttf",
99
"index.html": "/index.html",
1010
"static/media/radio-button.svg": "/static/media/radio-button.69aa1495d8439f869898.svg",
11-
"main.39d05f2d.css.map": "/static/css/main.39d05f2d.css.map",
12-
"main.212bf1ad.js.map": "/static/js/main.212bf1ad.js.map"
11+
"main.fa3c1194.css.map": "/static/css/main.fa3c1194.css.map",
12+
"main.60ee4b12.js.map": "/static/js/main.60ee4b12.js.map"
1313
},
1414
"entrypoints": [
15-
"static/css/main.39d05f2d.css",
16-
"static/js/main.212bf1ad.js"
15+
"static/css/main.fa3c1194.css",
16+
"static/js/main.60ee4b12.js"
1717
]
1818
}

apps/frontend/build/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./images/cln-favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="color-scheme" content="light dark"><meta name="description" content="Core lightning application"/><link rel="apple-touch-icon" href="./images/cln-logo-dark.png"/><title>Core Lightning</title><script defer="defer" src="/static/js/main.212bf1ad.js"></script><link href="/static/css/main.39d05f2d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./images/cln-favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="color-scheme" content="light dark"><meta name="description" content="Core lightning application"/><link rel="apple-touch-icon" href="./images/cln-logo-dark.png"/><title>Core Lightning</title><script defer="defer" src="/static/js/main.60ee4b12.js"></script><link href="/static/css/main.fa3c1194.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

apps/frontend/build/static/css/main.39d05f2d.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/frontend/build/static/css/main.39d05f2d.css renamed to apps/frontend/build/static/css/main.fa3c1194.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)