Turn off LN if Macaroon is missing

This commit is contained in:
softsimon 2023-03-21 15:50:33 +09:00
parent 758e4d4f4c
commit d337bf3ee2
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -10,22 +10,22 @@ class LndApi implements AbstractLightningApi {
axiosConfig: AxiosRequestConfig = {};
constructor() {
if (config.LIGHTNING.ENABLED) {
try {
const macaroon = fs.readFileSync(config.LND.MACAROON_PATH).toString('hex');
this.axiosConfig = {
headers: {
'Grpc-Metadata-macaroon': macaroon
},
httpsAgent: new Agent({
ca: fs.readFileSync(config.LND.TLS_CERT_PATH)
}),
timeout: config.LND.TIMEOUT
};
} catch (e) {
logger.err(`Could not initialize LND Macaroon/TLS Cert. Disabling LIGHTNING. ` + (e instanceof Error ? e.message : e));
config.LIGHTNING.ENABLED = false;
}
if (!config.LIGHTNING.ENABLED) {
return;
}
try {
this.axiosConfig = {
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(config.LND.MACAROON_PATH).toString('hex'),
},
httpsAgent: new Agent({
ca: fs.readFileSync(config.LND.TLS_CERT_PATH)
}),
timeout: config.LND.TIMEOUT
};
} catch (e) {
logger.err(`Could not initialize LND Macaroon/TLS Cert. Disabling LIGHTNING. ` + (e instanceof Error ? e.message : e));
config.LIGHTNING.ENABLED = false;
}
}