Turn off LN if Macaroon is missing
This commit is contained in:
		
							parent
							
								
									758e4d4f4c
								
							
						
					
					
						commit
						d337bf3ee2
					
				@ -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;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user