Merge pull request #3490 from mempool/simon/auto-disable-ln-on-macaroon-fail
Auto disable LN on macaroon fail
This commit is contained in:
commit
e2fda99578
@ -4,21 +4,29 @@ import * as fs from 'fs';
|
|||||||
import { AbstractLightningApi } from '../lightning-api-abstract-factory';
|
import { AbstractLightningApi } from '../lightning-api-abstract-factory';
|
||||||
import { ILightningApi } from '../lightning-api.interface';
|
import { ILightningApi } from '../lightning-api.interface';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
|
import logger from '../../../logger';
|
||||||
|
|
||||||
class LndApi implements AbstractLightningApi {
|
class LndApi implements AbstractLightningApi {
|
||||||
axiosConfig: AxiosRequestConfig = {};
|
axiosConfig: AxiosRequestConfig = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (config.LIGHTNING.ENABLED) {
|
if (!config.LIGHTNING.ENABLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
this.axiosConfig = {
|
this.axiosConfig = {
|
||||||
headers: {
|
headers: {
|
||||||
'Grpc-Metadata-macaroon': fs.readFileSync(config.LND.MACAROON_PATH).toString('hex')
|
'Grpc-Metadata-macaroon': fs.readFileSync(config.LND.MACAROON_PATH).toString('hex'),
|
||||||
},
|
},
|
||||||
httpsAgent: new Agent({
|
httpsAgent: new Agent({
|
||||||
ca: fs.readFileSync(config.LND.TLS_CERT_PATH)
|
ca: fs.readFileSync(config.LND.TLS_CERT_PATH)
|
||||||
}),
|
}),
|
||||||
timeout: config.LND.TIMEOUT
|
timeout: config.LND.TIMEOUT
|
||||||
};
|
};
|
||||||
|
} catch (e) {
|
||||||
|
config.LIGHTNING.ENABLED = false;
|
||||||
|
logger.updateNetwork();
|
||||||
|
logger.err(`Could not initialize LND Macaroon/TLS Cert. Disabling LIGHTNING. ` + (e instanceof Error ? e.message : e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ class Logger {
|
|||||||
this.network = this.getNetwork();
|
this.network = this.getNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public updateNetwork(): void {
|
||||||
|
this.network = this.getNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
private addprio(prio): void {
|
private addprio(prio): void {
|
||||||
this[prio] = (function(_this) {
|
this[prio] = (function(_this) {
|
||||||
return function(msg, tag?: string) {
|
return function(msg, tag?: string) {
|
||||||
|
@ -10,6 +10,8 @@ cp /etc/nginx/nginx.conf /patch/nginx.conf
|
|||||||
sed -i "s/__MEMPOOL_FRONTEND_HTTP_PORT__/${__MEMPOOL_FRONTEND_HTTP_PORT__}/g" /patch/nginx.conf
|
sed -i "s/__MEMPOOL_FRONTEND_HTTP_PORT__/${__MEMPOOL_FRONTEND_HTTP_PORT__}/g" /patch/nginx.conf
|
||||||
cat /patch/nginx.conf > /etc/nginx/nginx.conf
|
cat /patch/nginx.conf > /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
[ "${APP_LIGHTNING_NODE_PORT}" = "9735" ] && LIGHTNING=true
|
||||||
|
|
||||||
# Runtime overrides - read env vars defined in docker compose
|
# Runtime overrides - read env vars defined in docker compose
|
||||||
|
|
||||||
__TESTNET_ENABLED__=${TESTNET_ENABLED:=false}
|
__TESTNET_ENABLED__=${TESTNET_ENABLED:=false}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user