Default lndconf & macaroon path and remove leading zeros

Default lndconf & macaroon path and remove leading zeros
pull/105/head
ShahanaFarooqui 5 years ago
parent e8f4e07b0b
commit 9703094f57

@ -1,4 +1,6 @@
var os = require('os');
var fs = require('fs');
var platform = require('os').platform();
var crypto = require('crypto');
var clArgs = require('optimist').argv;
var ini = require('ini');
@ -9,9 +11,27 @@ var logger = require('./controllers/logger');
var connect = {};
const setDefaultConfig = () => {
var homeDir = os.userInfo().homedir;
var macaroonPath = '';
var lndConfigPath = '';
var bitcoindConfigPath = '';
switch (platform) {
case 'win32':
macaroonPath = homeDir + '\\AppData\\Local\\Lnd\\data\\chain\\bitcoin\\testnet';
lndConfigPath = homeDir + '\\AppData\\Local\\Lnd\\lnd.conf';
break;
case 'darwin':
macaroonPath = homeDir + '/Library/Application Support/Lnd/data/chain/bitcoin/testnet';
lndConfigPath = homeDir + '/Library/Application Support/Lnd/lnd.conf';
break;
case 'linux':
macaroonPath = homeDir + '/.lnd/data/chain/bitcoin/testnet';
lndConfigPath = homeDir + '/.lnd/lnd.conf';
break;
default:
macaroonPath = '';
lndConfigPath = '';
break;
}
return {
Authentication: {
macaroonPath: macaroonPath,
@ -27,7 +47,6 @@ const setDefaultConfig = () => {
theme: 'dark-blue',
satsToBTC: false,
lndServerUrl: 'https://localhost:8080/v1',
bitcoindConfigPath: bitcoindConfigPath,
enableLogging: false,
port: 3000
},
@ -138,7 +157,7 @@ const validateConfigFile = (config) => {
let exists = fs.existsSync(common.log_file);
if (exists) {
fs.writeFile(common.log_file, '', () => { });
} else if (!exists && config.Authentication.enableLogging) {
} else if ((!exists && config.Authentication.enableLogging) || (!exists && config.Settings.enableLogging)) {
try {
var dirname = path.dirname(common.log_file);
createDirectory(dirname);
@ -146,7 +165,7 @@ const validateConfigFile = (config) => {
createStream.end();
}
catch (err) {
console.error('Something went wrong: \n' + err);
console.error('Something went wrong while creating log file: \n' + err);
}
}
}
@ -214,7 +233,7 @@ const readCookie = (cookieFile) => {
common.cookie = fs.readFileSync(cookieFile, 'utf-8');
}
catch(err) {
console.error('Something went wrong: \n' + err);
console.error('Something went wrong while reading cookie: \n' + err);
throw new Error(err);
}
}
@ -262,10 +281,11 @@ connect.configFileExists = () => {
var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
setMacaroonPath(clArgs, config)
validateConfigFile(config);
logEnvVariables();
logEnvVariables();
// throw new Error('Please change default settings of macaroonPath and lndConfigPath in RTL.conf and restart the server');
}
catch(err) {
console.error('Something went wrong: \n' + err);
console.error('Something went wrong while configuring the server: \n' + err);
throw new Error(err);
}
}

@ -4,7 +4,7 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --base-href /rtl/",
"start": "ng serve --base-href /rtl/ --open",
"build": "ng build --prod --base-href /rtl/",
"serve": "ng serve",
"prebuild": "node ./prebuild",

@ -4,10 +4,10 @@
"LNNode": "LND Testnet # 1",
"LNImplementation": "LND",
"Authentication": {
"macaroonPath": "/Users/suheb/Downloads",
"macaroonPath": "/Users/<user>/",
"nodeAuthType": "CUSTOM",
"lndConfigPath": "",
"rtlPass": "xxx"
"rtlPass": ""
},
"Settings": {
"flgSidenavOpened": "true",
@ -32,17 +32,17 @@
"LNNode": "LND Mainnet # 1",
"LNImplementation": "LND",
"Authentication": {
"macaroonPath": "/Users/suheb/Downloads",
"macaroonPath": "/Users/<user>/",
"nodeAuthType": "CUSTOM",
"lndConfigPath": "",
"rtlPass": "xxx"
"rtlPass": ""
},
"Settings": {
"flgSidenavOpened": "true",
"flgSidenavPinned": "true",
"menu": "Vertical",
"menuType": "Regular",
"theme": "dark-blue",
"theme": "dark-green",
"satsToBTC": "false",
"bitcoindConfigPath": "",
"enableLogging": "true",

@ -49,8 +49,7 @@
[ngClass]="{'mat-elevation-z8 overflow-auto error-border': flgLoading[0]==='error','mat-elevation-z8 overflow-auto': true}">
<ng-container matColumnDef="chan_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Chan Id</th>
<td mat-cell *matCellDef="let rPeer" class="ellipsis-parent"><span
class="ellipsis-child">{{rPeer.chan_id}}</span></td>
<td mat-cell *matCellDef="let rPeer" class="ellipsis-parent"><span class="ellipsis-child">{{rPeer.chan_id}}</span></td>
</ng-container>
<ng-container matColumnDef="alias">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Alias</th>

@ -33,7 +33,7 @@
</ng-container>
<ng-container matColumnDef="block_hash">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Block Hash </th>
<td mat-cell *matCellDef="let trans"> {{trans.block_hash | slice:0:10}}...</td>
<td mat-cell *matCellDef="let trans" class="ellipsis-parent"><span class="ellipsis-child">{{trans.block_hash | removeleadingzeros}}</span></td>
</ng-container>
<ng-container matColumnDef="block_height">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Block Height </th>
@ -41,7 +41,7 @@
</ng-container>
<ng-container matColumnDef="tx_hash">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Txn Hash </th>
<td mat-cell *matCellDef="let trans"><div>{{trans.tx_hash | slice:0:10}}...</div></td>
<td mat-cell *matCellDef="let trans" class="ellipsis-parent"><span class="ellipsis-child">{{trans.tx_hash}}</span></td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Amount </th>

@ -17,3 +17,16 @@
table {
width:100%;
}
.ellipsis-parent {
min-width: 20px;
display: flex;
padding: 13px 0 13px 12px;
}
.ellipsis-child {
max-width:97%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'removeleadingzeros'
})
export class RemoveLeadingZerosPipe implements PipeTransform {
transform(value: string, args?: any): string {
return value.replace(/^[0]+/g, '');
}
}

@ -15,6 +15,7 @@ import { NotFoundComponent } from './components/not-found/not-found.component';
import { SettingsNavComponent } from './components/settings-nav/settings-nav.component';
import { ClipboardDirective } from './directive/clipboard.directive';
import { SsoFailedComponent } from './components/sso-failed/sso-failed.component';
import { RemoveLeadingZerosPipe } from './pipes/remove-leading-zero.pipe';
@NgModule({
imports: [
@ -82,7 +83,8 @@ import { SsoFailedComponent } from './components/sso-failed/sso-failed.component
NotFoundComponent,
SettingsNavComponent,
ClipboardDirective,
QRCodeModule
QRCodeModule,
RemoveLeadingZerosPipe
],
declarations: [
AlertMessageComponent,
@ -91,7 +93,8 @@ import { SsoFailedComponent } from './components/sso-failed/sso-failed.component
NotFoundComponent,
SettingsNavComponent,
ClipboardDirective,
SsoFailedComponent
SsoFailedComponent,
RemoveLeadingZerosPipe
],
entryComponents: [
AlertMessageComponent,

Loading…
Cancel
Save