Turn off LN if Macaroon is missing
This commit is contained in:
		
							parent
							
								
									758e4d4f4c
								
							
						
					
					
						commit
						d337bf3ee2
					
				@ -10,12 +10,13 @@ class LndApi implements AbstractLightningApi {
 | 
			
		||||
  axiosConfig: AxiosRequestConfig = {};
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    if (config.LIGHTNING.ENABLED) {
 | 
			
		||||
    if (!config.LIGHTNING.ENABLED) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        const macaroon = fs.readFileSync(config.LND.MACAROON_PATH).toString('hex');
 | 
			
		||||
      this.axiosConfig = {
 | 
			
		||||
        headers: {
 | 
			
		||||
            'Grpc-Metadata-macaroon': macaroon
 | 
			
		||||
          'Grpc-Metadata-macaroon': fs.readFileSync(config.LND.MACAROON_PATH).toString('hex'),
 | 
			
		||||
        },
 | 
			
		||||
        httpsAgent: new Agent({
 | 
			
		||||
          ca: fs.readFileSync(config.LND.TLS_CERT_PATH)
 | 
			
		||||
@ -27,7 +28,6 @@ class LndApi implements AbstractLightningApi {
 | 
			
		||||
      config.LIGHTNING.ENABLED = false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async $getNetworkInfo(): Promise<ILightningApi.NetworkInfo> {
 | 
			
		||||
    return axios.get<ILightningApi.NetworkInfo>(config.LND.REST_API_URL + '/v1/graph/info', this.axiosConfig)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user