Added fiatConversion configuration

Added fiatConversion configuration
pull/260/head
Shahana Farooqui 4 years ago
parent 917feebfa4
commit 2ffc513e77

@ -101,7 +101,7 @@ bitcoindConfigPath=C:/Bitcoin/bitcoin.conf
enableLogging=true
port=3000
lndServerUrl=https://192.168.1.16:8080/v1
currencyUnit=USD
fiatConversion=false
```
For details on all the configuration options refer to [this page](./docs/Application_configurations).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,8 +9,8 @@
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon/favicon-16x16.png">
<link rel="manifest" href="assets/images/favicon/site.webmanifest">
<link rel="stylesheet" href="styles.6cc6a00e43edb14b03cb.css"></head>
<link rel="stylesheet" href="styles.913955e0bafa4525ff05.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.ce2ab010c1e39ff4c366.js" defer></script><script src="polyfills-es5.acd0700da9b9f555b1f8.js" nomodule defer></script><script src="polyfills.69620c10d7f64d0a6eb1.js" defer></script><script src="main.3bfee7545fba40e0d2fa.js" defer></script></body>
<script src="runtime.80956de7b8d3d70e5793.js" defer></script><script src="polyfills-es5.acd0700da9b9f555b1f8.js" nomodule defer></script><script src="polyfills.69620c10d7f64d0a6eb1.js" defer></script><script src="main.b8ed5f83f0d35a4beee7.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"454a80537ee5d2127464",6:"daa73d77ea319342d9f3",7:"d96cecdb0dcbb36efae9"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([]);
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"05df06d0408441a851d7",6:"16bab1d95279b8901fb6",7:"a845cabd9973c1596925"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,7 +9,6 @@ common.node_auth_type = 'DEFAULT';
common.rtl_pass = '';
common.rtl_sso = 0;
common.port = 3000;
common.currency_unit = 'USD';
common.rtl_cookie_path = '';
common.logout_redirect_link = '/login';
common.cookie = '';

@ -71,7 +71,7 @@ connect.setDefaultConfig = () => {
channelBackupPath: channelBackupPath,
enableLogging: "true",
lndServerUrl: "https://localhost:8080/v1",
currencyUnit: "USD"
fiatConversion: false
}
}
]
@ -272,12 +272,18 @@ connect.validateSingleNodeConfig = (config) => {
}
}
if (undefined !== process.env.CURRENCY_UNIT) {
if (process.env.FIAT_CONVERSION) {
common.nodes[0].fiat_conversion = process.env.FIAT_CONVERSION;
} else if (undefined !== config.Settings.fiatConversion) {
common.nodes[0].fiat_conversion = config.Settings.fiatConversion;
} else {
common.nodes[0].fiat_conversion = false;
}
if (process.env.FIAT_CONVERSION && process.env.CURRENCY_UNIT) {
common.nodes[0].currency_unit = process.env.CURRENCY_UNIT;
} else if (undefined !== config.Settings.currencyUnit) {
} else if (config.Settings.fiatConversion && config.Settings.currencyUnit) {
common.nodes[0].currency_unit = config.Settings.currencyUnit;
} else {
common.nodes[0].currency_unit = 'USD';
}
if (undefined !== process.env.PORT) {
@ -328,7 +334,10 @@ connect.validateMultiNodeConfig = (config) => {
common.nodes[idx].index = node.index;
common.nodes[idx].ln_node = node.lnNode;
common.nodes[idx].ln_implementation = node.lnImplementation;
common.nodes[idx].currency_unit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
common.nodes[idx].fiat_conversion = node.Settings.fiatConversion ? node.Settings.fiatConversion : false;
if(common.nodes[idx].fiat_conversion) {
common.nodes[idx].currency_unit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
}
if (undefined !== node.Authentication && undefined !== node.Authentication.lndConfigPath) {
common.nodes[idx].config_path = node.Authentication.lndConfigPath;
@ -475,15 +484,18 @@ connect.logEnvVariables = () => {
logger.info({fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node});
logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port, node});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.currency_unit, node});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT_CONVERSION: ' + node.fiatConversion, node});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + node.currency_unit, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LND_SERVER_URL: ' + node.ln_server_url, node});
});
} else {
if (!common.nodes[0].enable_logging) { return; }
logger.info({fileName: 'Config Setup Variable', msg: 'NODE_SETUP: SINGLE'});
logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.currency_unit});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.nodes[0].currency_unit});
logger.info({fileName: 'Config Setup Variable', msg: 'LND_SERVER_URL: ' + common.nodes[0].ln_server_url});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT_CONVERSION: ' + common.nodes[0].fiat_conversion});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY_UNIT: ' + common.nodes[0].currency_unit});
logger.info({fileName: 'Config Setup Variable', msg: 'RTL_SSO: ' + common.rtl_sso});
logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link});
}

@ -115,7 +115,12 @@ exports.updateUISettings = (req, res, next) => {
node.Settings.userPersona = req.body.updatedSettings.userPersona;
node.Settings.themeMode = req.body.updatedSettings.themeMode;
node.Settings.themeColor = req.body.updatedSettings.themeColor;
node.Settings.currencyUnit = req.body.updatedSettings.currencyUnit;
node.Settings.fiatConversion = req.body.updatedSettings.fiatConversion;
if(req.body.updatedSettings.fiatConversion) {
node.Settings.currencyUnit = req.body.updatedSettings.currencyUnit ? req.body.updatedSettings.currencyUnit : 'USD';
} else {
delete node.Settings.currencyUnit;
}
node.Settings.flgSidenavOpened = true; // req.body.updatedSettings.flgSidenavOpened;
node.Settings.flgSidenavPinned = true; // req.body.updatedSettings.flgSidenavPinned;
node.Settings.menu = 'VERTICAL'; // req.body.updatedSettings.menu;
@ -143,7 +148,10 @@ exports.updateUISettings = (req, res, next) => {
settingsTemp.userPersona = req.body.updatedSettings.userPersona;
settingsTemp.themeMode = req.body.updatedSettings.themeMode;
settingsTemp.themeColor = req.body.updatedSettings.themeColor;
settingsTemp.currencyUnit = req.body.updatedSettings.currencyUnit;
settingsTemp.fiatConversion = req.body.updatedSettings.fiatConversion;
if(req.body.updatedSettings.fiatConversion) {
settingsTemp.currencyUnit = req.body.updatedSettings.currencyUnit ? req.body.updatedSettings.currencyUnit : 'USD';
}
settingsTemp.flgSidenavOpened = true; // req.body.updatedSettings.flgSidenavOpened;
settingsTemp.flgSidenavPinned = true; // req.body.updatedSettings.flgSidenavPinned;
settingsTemp.menu = 'VERTICAL'; // req.body.updatedSettings.menu;

@ -12,7 +12,7 @@ exports.listChannels = (req, res, next) => {
local = (channel.msatoshi_to_us) ? channel.msatoshi_to_us : 0;
remote = (channel.msatoshi_to_them) ? channel.msatoshi_to_them : 0;
total = channel.msatoshi_total ? channel.msatoshi_total : 0;
channel.balancedness = (total === 0) ? 1 : (1 - Math.abs((local-remote)/total)).toFixed(3);
channel.balancedness = (total == 0) ? 1 : (1 - Math.abs((local-remote)/total)).toFixed(3);
})
res.status(200).json(body);
})

@ -29,7 +29,7 @@ exports.getAllChannels = (req, res, next) => {
local = (channel.local_balance) ? +channel.local_balance : 0;
remote = (channel.remote_balance) ? +channel.remote_balance : 0;
total = local + remote;
channel.balancedness = (total === 0) ? 1 : (1 - Math.abs((local-remote)/total)).toFixed(3);
channel.balancedness = (total == 0) ? 1 : (1 - Math.abs((local-remote)/total)).toFixed(3);
return getAliasForChannel(channel);
})
)

@ -31,6 +31,8 @@ lndServerUrl=https://localhost:8080/v1
;Channel backup folder
channelBackupPath=<>
;Set by RTL
fiatConversion=false
;Set by RTL, dafault 'USD' If fiatConversion is true
currencyUnit=USD
[SSO]
@ -62,4 +64,5 @@ RTL_SSO (1 - single sign on via an external cookie, 0 - stand alone RTL authenti
RTL_COOKIE_PATH (Full path of the cookie file including the file name)
LOGOUT_REDIRECT_LINK (URL to re-direct to after logout/timeout from RTL)
CHANNEL_BACKUP_PATH (folder location for saving the channel backup files)
CURRENCY_UNIT (Fiat currency unit for fiat conversion, Default 'USD')
FIAT_CONVERSION (Enable/Disable fiat conversion for the node, Default false)
CURRENCY_UNIT (Fiat currency unit for fiat conversion, Default 'USD' if FIAT_CONVERSION is true)

@ -80,7 +80,7 @@ Ensure that the follow values are correct per your config:
"themeColor": "PURPLE",
"bitcoindConfigPath": "",
"enableLogging": true,
"currencyUnit": "USD",
"fiatConversion": false,
"lnServerUrl": "https://<cl-rest api server ip address>:3001/v1"
}
}

@ -24,6 +24,7 @@
"bitcoindConfigPath": "<Optional: path of bitcoind.conf path if available locally>",
"enableLogging": true,
"currencyUnit": "USD",
"fiatConversion": true,
"lndServerUrl": "<Service url for LND REST APIs for node # 1 e.g. https://192.168.0.1:8080/v1"
}
},
@ -41,7 +42,7 @@
"channelBackupPath": "C:\\RTL\\backup\\node-2",
"bitcoindConfigPath": "",
"enableLogging": true,
"currencyUnit": "GBP",
"fiatConversion": false,
"lnServerUrl": "<Service url for C Lightning REST APIs for node # 2 e.g. https://192.168.0.2:3001/v1"
}
}

@ -13,7 +13,8 @@ bitcoindConfigPath=
enableLogging=true
port=3000
lndServerUrl=https://localhost:8080/v1
currencyUnit=USD
currencyUnit=GBP
fiatConversion=true
[SSO]
rtlSSO=0

@ -13,7 +13,7 @@ import { LoggerService } from './shared/services/logger.service';
import { CommonService } from './shared/services/common.service';
import { SessionService } from './shared/services/session.service';
import { AlertTypeEnum, ScreenSizeEnum, NODE_SETTINGS } from './shared/services/consts-enums-functions';
import { RTLConfiguration, Settings, LightningNode, GetInfoRoot } from './shared/models/RTLconfig';
import { RTLConfiguration, Settings, ConfigSettingsNode, GetInfoRoot } from './shared/models/RTLconfig';
import * as RTLActions from './store/rtl.actions';
import * as fromRTLReducer from './store/rtl.reducers';
@ -25,7 +25,7 @@ import * as fromRTLReducer from './store/rtl.reducers';
})
export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('sideNavigation', { static: false }) sideNavigation: any;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public settings: Settings;
public information: GetInfoRoot = {};
public flgLoading: Array<Boolean | 'error'> = [true]; // 0: Info

@ -62,6 +62,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.unSubs[1]))
.subscribe(data => {
this.transaction.satoshis = parseInt(data[CurrencyUnitEnum.SATS]);
this.selAmountUnit = CurrencyUnitEnum.SATS;
this.confirmSend();
});
} else {

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="selNode.currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="selNode.currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -23,7 +23,7 @@ export interface CLState {
export const initCLState: CLState = {
effectErrorsCl: [],
nodeSettings: { userPersona: UserPersonaEnum.OPERATOR, selCurrencyUnit: 'USD', channelBackupPath: '', satsToBTC: false, currencyUnits: [] },
nodeSettings: { userPersona: UserPersonaEnum.OPERATOR, selCurrencyUnit: 'USD', fiatConversion: false, channelBackupPath: '', satsToBTC: false, currencyUnits: [] },
information: {},
fees: {},
feeRatesPerKB: {},

@ -170,7 +170,7 @@ export class CLLightningInvoicesComponent implements OnInit, OnDestroy {
}
onInvoiceValueChange() {
if(this.invoiceValue > 99) {
if(this.selNode.fiatConversion && this.invoiceValue > 99) {
this.invoiceValueHint = '';
this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2])
.pipe(takeUntil(this.unSubs[1]))

@ -193,7 +193,11 @@ export class CLLightningPaymentsComponent implements OnInit, OnDestroy {
this.commonService.convertCurrency(+this.paymentDecoded.msatoshi, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2])
.pipe(takeUntil(this.unSubs[1]))
.subscribe(data => {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
if(this.selNode.fiatConversion) {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
} else {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.msatoshi ? this.paymentDecoded.msatoshi/1000 : 0) + ' Sats | Memo: ' + this.paymentDecoded.description;
}
});
} else {
this.paymentDecodedHint = 'Zero Amount Invoice | Memo: ' + this.paymentDecoded.description;

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -74,6 +74,7 @@ export class OnChainSendComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.unSubs[1]))
.subscribe(data => {
this.transaction.amount = parseInt(data[CurrencyUnitEnum.SATS]);
this.selAmountUnit = CurrencyUnitEnum.SATS;
this.confirmSend();
});
} else {

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="selNode.currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -177,24 +177,6 @@ export class ChannelOpenTableComponent implements OnInit, OnDestroy {
this.applyFilter();
}
// onGraphLookup(channel:Channel) {
// this.store.dispatch(new RTLActions.ChannelLookup(channel.chan_id));
// this.actions$
// .pipe(
// takeUntil(this.unSubs[3]),
// filter((action) => (action.type === RTLActions.SET_LOOKUP))
// ).subscribe((resLookup: RTLActions.SetLookup) => {
// if(resLookup.type === RTLActions.SET_LOOKUP) {
// console.warn(JSON.parse(JSON.stringify(resLookup.payload)));
// this.store.dispatch(new RTLActions.OpenAlert({ data: {
// lookupResult: JSON.parse(JSON.stringify(resLookup.payload)),
// newlyAdded: false,
// component: ChannelLookupComponent
// }}));
// }
// });
// }
onChannelClose(channelToClose: Channel) {
this.store.dispatch(new RTLActions.OpenConfirmation({ data: {
type: AlertTypeEnum.CONFIRM,

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="selNode.currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -34,7 +34,7 @@ export interface LNDState {
export const initLNDState: LNDState = {
effectErrorsLnd: [],
nodeSettings: { userPersona: UserPersonaEnum.OPERATOR, selCurrencyUnit: 'USD', channelBackupPath: '', satsToBTC: false, currencyUnits: [] },
nodeSettings: { userPersona: UserPersonaEnum.OPERATOR, fiatConversion: false, channelBackupPath: '', satsToBTC: false, currencyUnits: [] },
information: {},
peers: [],
fees: {},

@ -156,7 +156,7 @@ export class LightningInvoicesComponent implements OnInit, OnDestroy {
}
onInvoiceValueChange() {
if(this.invoiceValue > 99) {
if(this.selNode.fiatConversion && this.invoiceValue > 99) {
this.invoiceValueHint = '';
this.commonService.convertCurrency(this.invoiceValue, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2])
.pipe(takeUntil(this.unSubs[1]))

@ -199,7 +199,11 @@ export class LightningPaymentsComponent implements OnInit, OnDestroy {
this.commonService.convertCurrency(+this.paymentDecoded.num_satoshis, CurrencyUnitEnum.SATS, this.selNode.currencyUnits[2])
.pipe(takeUntil(this.unSubs[1]))
.subscribe(data => {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.num_satoshis ? this.paymentDecoded.num_satoshis : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
if(this.selNode.fiatConversion) {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.num_satoshis ? this.paymentDecoded.num_satoshis : 0) + ' Sats (' + data.symbol + this.decimalPipe.transform((data.OTHER ? data.OTHER : 0), CURRENCY_UNIT_FORMATS.OTHER) + ') | Memo: ' + this.paymentDecoded.description;
} else {
this.paymentDecodedHint = 'Sending: ' + this.decimalPipe.transform(this.paymentDecoded.num_satoshis ? this.paymentDecoded.num_satoshis : 0) + ' Sats | Memo: ' + this.paymentDecoded.description;
}
});
} else {
this.paymentDecodedHint = 'Zero Amount Invoice | Memo: ' + this.paymentDecoded.description;

@ -5,7 +5,7 @@
<div fxLayout="column" class="padding-gap-x mb-4">
<mat-card>
<mat-card-content fxLayout="column">
<rtl-currency-unit-converter [values]="balances" [currencyUnits]="currencyUnits"></rtl-currency-unit-converter>
<rtl-currency-unit-converter [values]="balances"></rtl-currency-unit-converter>
</mat-card-content>
</mat-card>
</div>

@ -5,7 +5,7 @@
<div class="cc-data-title">{{value.title}}</div>
<span class="cc-data-value" *ngIf="currencyUnit === currencyUnitEnum.SATS">{{value.dataValue | number}}</span>
<span class="cc-data-value" *ngIf="currencyUnit === currencyUnitEnum.BTC">{{value[currencyUnitEnum.BTC] | number:currencyUnitFormats.BTC}}</span>
<span class="cc-data-value" *ngIf="currencyUnit !== currencyUnitEnum.SATS && currencyUnit !== currencyUnitEnum.BTC">{{value[currencyUnitEnum.OTHER] | number:currencyUnitFormats.OTHER}}</span>
<span class="cc-data-value" *ngIf="fiatConversion && currencyUnit !== currencyUnitEnum.SATS && currencyUnit !== currencyUnitEnum.BTC">{{value[currencyUnitEnum.OTHER] | number:currencyUnitFormats.OTHER}}</span>
</div>
</div>
</mat-tab>

@ -1,43 +1,62 @@
import { Component, Input, OnDestroy } from '@angular/core';
import { Component, Input, OnInit, OnChanges, OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { takeUntil, takeLast, first } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { CurrencyUnitEnum, CURRENCY_UNIT_FORMATS } from '../../services/consts-enums-functions';
import { CommonService } from '../../services/common.service';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@Component({
selector: 'rtl-currency-unit-converter',
templateUrl: './currency-unit-converter.component.html',
styleUrls: ['./currency-unit-converter.component.scss']
})
export class CurrencyUnitConverterComponent implements OnDestroy {
export class CurrencyUnitConverterComponent implements OnInit, OnChanges, OnDestroy {
@Input() values = [];
public currencyUnitEnum = CurrencyUnitEnum;
public currencyUnitFormats = CURRENCY_UNIT_FORMATS;
private _values: Array<any>;
private _currencyUnits = [];
public currencyUnits = [];
public fiatConversion = false;
private unSubs = [new Subject(), new Subject()];
get values(): Array<any> { return this._values; }
get currencyUnits(): Array<any> { return this._currencyUnits; }
@Input() set values(data: Array<any>) {
this._values = data;
if(this._currencyUnits.length > 2 && this._values[0].dataValue >= 0) {
this.getCurrencyValues(this._values);
}
// private _values: Array<any>;
// get values(): Array<any> { return this._values; }
// @Input() set values(data: Array<any>) {
// this._values = data;
// if(this.currencyUnits.length > 1 && this._values[0].dataValue >= 0) {
// this.getCurrencyValues(this._values);
// }
// }
constructor(public commonService: CommonService, private store: Store<fromRTLReducer.RTLState>) {}
ngOnInit() {
this.store.select('root')
.pipe(first())
.subscribe((rtlStore) => {
this.fiatConversion = rtlStore.selNode.settings.fiatConversion;
this.currencyUnits = rtlStore.selNode.settings.currencyUnits;
if(!this.fiatConversion) {
this.currencyUnits.splice(2, 1);
}
if(this.currencyUnits.length > 1 && this.values[0].dataValue >= 0) {
this.getCurrencyValues(this.values);
}
});
}
@Input() set currencyUnits(data: Array<any>) {
this._currencyUnits = data;
if(this._currencyUnits.length > 2 && this._values[0].dataValue >= 0) {
this.getCurrencyValues(this._values);
ngOnChanges() {
if(this.currencyUnits.length > 1 && this.values[0].dataValue >= 0) {
this.getCurrencyValues(this.values);
}
}
constructor(public commonService: CommonService) {}
getCurrencyValues(values) {
values.forEach(value => {
if(value.dataValue > 0) {
this.commonService.convertCurrency(value.dataValue, CurrencyUnitEnum.SATS, this.currencyUnits[2])
.pipe(takeUntil(this.unSubs[0]))
.pipe(takeUntil(this.unSubs[1]))
.subscribe(data => {
value[CurrencyUnitEnum.BTC] = data.BTC;
value[CurrencyUnitEnum.OTHER] = data.OTHER;

@ -4,7 +4,7 @@ import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faQuestion } from '@fortawesome/free-solid-svg-icons';
import { HelpTopic, LightningNode } from '../../models/RTLconfig';
import { HelpTopic, ConfigSettingsNode } from '../../models/RTLconfig';
import { SessionService } from '../../services/session.service';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@ -17,7 +17,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
export class HelpComponent implements OnInit, OnDestroy {
public helpTopics: Array<HelpTopic> = [];
public faQuestion = faQuestion;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public LNPLink = '/lnd/';
public flgLoggedIn = false;
private unSubs = [new Subject(), new Subject(), new Subject(), new Subject()];

@ -10,7 +10,7 @@ import { MENU_DATA } from '../../../models/navMenu';
import { RTLEffects } from '../../../../store/rtl.effects';
import * as RTLActions from '../../../../store/rtl.actions';
import * as fromRTLReducer from '../../../../store/rtl.reducers';
import { GetInfoRoot, LightningNode, RTLConfiguration } from '../../../models/RTLconfig';
import { GetInfoRoot, ConfigSettingsNode, RTLConfiguration } from '../../../models/RTLconfig';
import { AlertTypeEnum } from '../../../services/consts-enums-functions';
@Component({
@ -24,7 +24,7 @@ export class HorizontalNavigationComponent implements OnInit, OnDestroy {
public showLogout = false;
public numPendingChannels = 0;
public appConfig: RTLConfiguration;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public information: GetInfoRoot = {};
private unSubs = [new Subject(), new Subject(), new Subject()];
@ -87,7 +87,7 @@ export class HorizontalNavigationComponent implements OnInit, OnDestroy {
this.store.dispatch(new RTLActions.ShowPubkey());
}
onNodeSelectionChange(selNodeValue: LightningNode) {
onNodeSelectionChange(selNodeValue: ConfigSettingsNode) {
this.selNode = selNodeValue;
this.store.dispatch(new RTLActions.OpenSpinner('Updating Selected Node...'));
this.store.dispatch(new RTLActions.SetSelelectedNode({ lnNode: selNodeValue, isInitialSetup: false }));

@ -9,7 +9,7 @@ import { NestedTreeControl } from '@angular/cdk/tree';
import { MatTreeNestedDataSource, MatTree } from '@angular/material/tree';
import { faEject, faEye } from '@fortawesome/free-solid-svg-icons';
import { RTLConfiguration, LightningNode, Settings, GetInfoRoot } from '../../../models/RTLconfig';
import { RTLConfiguration, ConfigSettingsNode, Settings, GetInfoRoot } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { SessionService } from '../../../services/session.service';
import { GetInfoChain } from '../../../models/lndModels';
@ -31,7 +31,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
faEject = faEject;
faEye = faEye;
public appConfig: RTLConfiguration;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public settings: Settings;
public version = '';
public information: GetInfoRoot = {};
@ -153,7 +153,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
this.ChildNavClicked.emit('showData');
}
onNodeSelectionChange(selNodeValue: LightningNode) {
onNodeSelectionChange(selNodeValue: ConfigSettingsNode) {
this.selNode = selNodeValue;
this.store.dispatch(new RTLActions.OpenSpinner('Updating Selected Node...'));
this.store.dispatch(new RTLActions.SetSelelectedNode({ lnNode: selNodeValue, isInitialSetup: false }));

@ -4,7 +4,7 @@ import { takeUntil, filter } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { GetInfoRoot, LightningNode } from '../../../models/RTLconfig';
import { GetInfoRoot, ConfigSettingsNode } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { SessionService } from '../../../services/session.service';
import { GetInfoChain } from '../../../models/lndModels';
@ -22,7 +22,7 @@ import { AlertTypeEnum } from '../../../services/consts-enums-functions';
styleUrls: ['./top-menu.component.scss']
})
export class TopMenuComponent implements OnInit, OnDestroy {
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public faCodeBranch = faCodeBranch;
public faCog = faCog;
public faLifeRing = faLifeRing;

@ -4,12 +4,16 @@
<fa-icon [icon]="faWrench" class="page-title-img mr-1"></fa-icon>
<span class="page-title">Node Layout</span>
</div>
<div fxFlex="100" class="alert alert-warn">
<fa-icon [icon]="faExclamationTriangle" class="mr-1 alert-icon"></fa-icon>
<span>Fiat conversion calls <strong><a href="https://www.blockchain.com/api/exchange_rates_api" target="blank">https://blockchain.info/ticker</a></strong> API to get conversion rates.</span>
</div>
<div fxFlex="100" class="alert alert-info">
<fa-icon [icon]="faInfoCircle" class="mr-1 alert-icon"></fa-icon>
<span>Application layout will be tailored based upon user persona.</span>
</div>
<div fxLayout="column" fxLayout.gt-sm="row" fxFlex="100" fxLayoutAlign="space-between stretch">
<mat-form-field fxFlex="32" fxLayoutAlign="start end">
<mat-form-field fxFlex="30" fxLayoutAlign="start end">
<mat-label>User Persona</mat-label>
<mat-select [(ngModel)]="selNode.settings.userPersona" tabindex="1" name="userPersona">
<mat-option *ngFor="let userPersona of userPersonas" [value]="userPersona">
@ -17,17 +21,20 @@
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="32" fxLayoutAlign="start end">
<mat-label>Currency Unit</mat-label>
<mat-select [(ngModel)]="selNode.settings.currencyUnit" (selectionChange)="onCurrencyChange($event)" tabindex="1" name="currencyUnit">
<mat-option *ngFor="let currencyUnit of currencyUnits" [value]="currencyUnit.id">
{{currencyUnit.id}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field fxFlex="32" fxLayoutAlign="start end" *ngIf="appConfig.nodes.length && appConfig.nodes.length > 1;else emptyBlock">
<div fxFlex="30" fxLayoutAlign="start center" [matTooltip]="'Calls https://blockchain.info/ticker API to get conversion rates'" [matTooltipPosition]="'below'">
<mat-slide-toggle tabindex="2" color="primary" [(ngModel)]="selNode.settings.fiatConversion" name="fiatConversion">Fiat Conversion</mat-slide-toggle>
<mat-form-field>
<mat-label>Currency Unit</mat-label>
<mat-select [disabled]="!selNode.settings.fiatConversion" [(ngModel)]="selNode.settings.currencyUnit" (selectionChange)="onCurrencyChange($event)" tabindex="3" name="currencyUnit">
<mat-option *ngFor="let currencyUnit of currencyUnits" [value]="currencyUnit.id">
{{currencyUnit.id}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<mat-form-field fxFlex="30" fxLayoutAlign="start end" *ngIf="appConfig.nodes.length && appConfig.nodes.length > 1;else emptyBlock">
<mat-label>Default Node</mat-label>
<mat-select [(ngModel)]="appConfig.defaultNodeIndex" tabindex="1" name="defaultNode">
<mat-select [(ngModel)]="appConfig.defaultNodeIndex" tabindex="4" name="defaultNode">
<mat-option *ngFor="let node of appConfig.nodes" [value]="node.index">
{{node.lnNode}} ({{node.lnImplementation}})
</mat-option>
@ -45,7 +52,7 @@
<div fxFlex.gt-xs="20" fxFlex.gt-md="15" fxLayout="column" fxLayoutAlign="space-between stretch">
<h4>Mode</h4>
<mat-radio-group color="primary" [(ngModel)]="selectedThemeMode" (change)="chooseThemeMode()">
<mat-radio-button *ngFor="let themeMode of themeModes" [value]="themeMode" [ngClass]="{'mr-4': screenSize === screenSizeEnum.XS || screenSize === screenSizeEnum.SM}">{{themeMode.name}}
<mat-radio-button tabindex="5" *ngFor="let themeMode of themeModes" [value]="themeMode" [ngClass]="{'mr-4': screenSize === screenSizeEnum.XS || screenSize === screenSizeEnum.SM}">{{themeMode.name}}
</mat-radio-button>
</mat-radio-group>
</div>
@ -54,7 +61,7 @@
<h4>Themes</h4>
<div fxLayout="row" fxFlex="100" fxLayoutAlign="space-between start">
<span *ngFor="let themeColor of themeColors" fxLayout="row">
<div [class]="themeColor.id | lowercase" [ngClass]="{'skin': true, 'selected-color': selectedThemeColor === themeColor.id}" (click)="changeThemeColor(themeColor.id)"></div>
<div tabindex="9" [class]="themeColor.id | lowercase" [ngClass]="{'skin': true, 'selected-color': selectedThemeColor === themeColor.id}" (click)="changeThemeColor(themeColor.id)"></div>
{{themeColor.name}}
</span>
</div>
@ -64,10 +71,10 @@
</div>
<div fxLayout="row" fxFlex="100" class="mt-2">
<div fxLayout="row" fxFlex="100" fxFlex.gt-sm="30" fxLayoutAlign="space-between stretch">
<button fxFlex="48" fxLayoutAlign="center center" mat-stroked-button color="primary" (click)="onResetSettings()" tabindex="12">Reset</button>
<button fxFlex="48" fxLayoutAlign="center center" mat-flat-button color="primary" (click)="onUpdateSettings()" tabindex="13">Update</button>
<button fxFlex="48" fxLayoutAlign="center center" mat-stroked-button color="primary" (click)="onResetSettings()" tabindex="10">Reset</button>
<button fxFlex="48" fxLayoutAlign="center center" mat-flat-button color="primary" (click)="onUpdateSettings()" tabindex="11">Update</button>
</div>
</div>
</div>
</div>
<ng-template #emptyBlock><div fxLayout="row" fxFlex="32" fxLayoutAlign="start end"></div></ng-template>
<ng-template #emptyBlock><div fxLayout="row" fxFlex="30" fxLayoutAlign="start end"></div></ng-template>

@ -2,10 +2,10 @@ import { Component, OnInit, OnDestroy, Output, EventEmitter } from '@angular/cor
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faWrench, faPaintBrush, faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { faWrench, faPaintBrush, faInfoCircle, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import { CURRENCY_UNITS, UserPersonaEnum, ScreenSizeEnum, FIAT_CURRENCY_UNITS, NODE_SETTINGS } from '../../../services/consts-enums-functions';
import { LightningNode, Settings, RTLConfiguration, GetInfoRoot } from '../../../models/RTLconfig';
import { ConfigSettingsNode, Settings, RTLConfiguration, GetInfoRoot } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { CommonService } from '../../../services/common.service';
@ -18,10 +18,11 @@ import * as fromRTLReducer from '../../../../store/rtl.reducers';
styleUrls: ['./app-settings.component.scss']
})
export class AppSettingsComponent implements OnInit, OnDestroy {
public faExclamationTriangle = faExclamationTriangle;
public faWrench = faWrench;
public faPaintBrush = faPaintBrush;
public faInfoCircle = faInfoCircle;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public information: GetInfoRoot = {};
public userPersonas = [UserPersonaEnum.OPERATOR, UserPersonaEnum.MERCHANT];
public currencyUnits = FIAT_CURRENCY_UNITS;
@ -43,7 +44,7 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
public previousDefaultNode = 0;
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
unsubs: Array<Subject<void>> = [new Subject(), new Subject()];
unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
@Output('done') done: EventEmitter<void> = new EventEmitter();
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store<fromRTLReducer.RTLState>) {
@ -52,7 +53,7 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.store.select('root')
.pipe(takeUntil(this.unsubs[0]))
.pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore) => {
this.appConfig = rtlStore.appConfig;
this.selNode = rtlStore.selNode;
@ -70,6 +71,9 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
this.information = rtlStore.nodeData;
this.smallerCurrencyUnit = (undefined !== this.information && undefined !== this.information.smaller_currency_unit) ? this.information.smaller_currency_unit : 'Sats';
this.currencyUnit = (undefined !== this.information && undefined !== this.information.currency_unit) ? this.information.currency_unit : 'BTC';
if(!this.selNode.settings.fiatConversion) {
this.selNode.settings.currencyUnit = null;
}
this.previousSettings = JSON.parse(JSON.stringify(this.selNode.settings));
this.previousDefaultNode = this.appConfig.defaultNodeIndex;
this.logger.info(rtlStore);
@ -78,8 +82,8 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
onCurrencyChange(event: any) {
this.selNode.settings.currencyUnits = [...CURRENCY_UNITS, event.value];
this.store.dispatch(new RTLActions.SetChildNodeSettings({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: event.value, currencyUnits: this.selNode.settings.currencyUnits}));
this.store.dispatch(new RTLActions.SetChildNodeSettingsCL({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: event.value, currencyUnits: this.selNode.settings.currencyUnits}));
this.store.dispatch(new RTLActions.SetChildNodeSettings({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: event.value, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion}));
this.store.dispatch(new RTLActions.SetChildNodeSettingsCL({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: event.value, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion}));
}
chooseMenuType() {
@ -119,8 +123,8 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
this.logger.info(this.selNode.settings);
this.store.dispatch(new RTLActions.OpenSpinner('Updating Settings...'));
this.store.dispatch(new RTLActions.SaveSettings({settings: this.selNode.settings, defaultNodeIndex: defaultNodeIndex}));
this.store.dispatch(new RTLActions.SetChildNodeSettings({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits}));
this.store.dispatch(new RTLActions.SetChildNodeSettingsCL({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits}));
this.store.dispatch(new RTLActions.SetChildNodeSettings({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion}));
this.store.dispatch(new RTLActions.SetChildNodeSettingsCL({userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, satsToBTC: this.selNode.settings.satsToBTC, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion}));
this.done.emit();
}
@ -135,7 +139,7 @@ export class AppSettingsComponent implements OnInit, OnDestroy {
}
ngOnDestroy() {
this.unsubs.forEach(unsub => {
this.unSubs.forEach(unsub => {
unsub.next();
unsub.complete();
});

@ -4,7 +4,7 @@ import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faTools } from '@fortawesome/free-solid-svg-icons';
import { LightningNode } from '../../models/RTLconfig';
import { ConfigSettingsNode } from '../../models/RTLconfig';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@Component({
@ -16,7 +16,7 @@ export class SettingsComponent implements OnInit, OnDestroy{
public faTools = faTools;
public showLnConfig = false;
public showBitcoind = false;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public lnImplementationStr = '';
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];

@ -6,7 +6,7 @@ import { Store } from '@ngrx/store';
import { faUnlockAlt } from '@fortawesome/free-solid-svg-icons';
import { LightningNode } from '../../models/RTLconfig';
import { ConfigSettingsNode } from '../../models/RTLconfig';
import { LoggerService } from '../../services/logger.service';
import * as fromRTLReducer from '../../../store/rtl.reducers';
import * as RTLActions from '../../../store/rtl.actions';
@ -18,7 +18,7 @@ import * as RTLActions from '../../../store/rtl.actions';
})
export class SigninComponent implements OnInit, OnDestroy {
public faUnlockAlt = faUnlockAlt;
public selNode: LightningNode;
public selNode: ConfigSettingsNode;
public password = '';
public nodeAuthType = '';
public rtlSSO = 0;

@ -19,6 +19,7 @@ export class Settings {
public themeColor: string,
public satsToBTC: boolean,
public currencyUnits: Array<string>,
public fiatConversion: boolean,
public bitcoindConfigPath?: string,
public enableLogging?: boolean,
public lnServerUrl?: string,
@ -35,7 +36,7 @@ export class Authentication {
) { }
}
export class LightningNode {
export class ConfigSettingsNode {
constructor(
public settings: Settings,
public authentication: Authentication,
@ -50,7 +51,7 @@ export class RTLConfiguration {
public defaultNodeIndex: number,
public selectedNodeIndex: number,
public sso: SSO,
public nodes: LightningNode[]
public nodes: ConfigSettingsNode[]
) { }
}
@ -71,6 +72,7 @@ export interface SelNodeChild {
satsToBTC?: boolean;
selCurrencyUnit?: string;
currencyUnits?: string[];
fiatConversion?: boolean;
}
export class HelpTopic {

@ -51,20 +51,43 @@ export class CommonService implements OnInit, OnDestroy {
convertCurrency(value: number, from: string, otherCurrencyUnit: string): Observable<any> {
let latest_date = new Date().valueOf();
if(this.conversionData.data && this.conversionData.last_fetched && (latest_date < (this.conversionData.last_fetched.valueOf() + 300000))) {
return of(this.convert(value, from, otherCurrencyUnit));
if(!otherCurrencyUnit) {
return of(this.convertWithoutFiat(value, from));
} else {
return this.httpClient.get(environment.CONF_API + '/rates')
.pipe(take(1),
map((data: any) => {
this.conversionData.data = data ? JSON.parse(data) : {};
this.conversionData.last_fetched = latest_date;
return this.convert(value, from, otherCurrencyUnit);
}));
if(this.conversionData.data && this.conversionData.last_fetched && (latest_date < (this.conversionData.last_fetched.valueOf() + 300000))) {
return of(this.convertWithFiat(value, from, otherCurrencyUnit));
} else {
return this.httpClient.get(environment.CONF_API + '/rates')
.pipe(take(1),
map((data: any) => {
this.conversionData.data = data ? JSON.parse(data) : {};
this.conversionData.last_fetched = latest_date;
return this.convertWithFiat(value, from, otherCurrencyUnit);
}));
}
}
}
convert(value: number, from: string, otherCurrencyUnit: string) {
convertWithoutFiat(value: number, from: string) {
let returnValue = {};
returnValue[CurrencyUnitEnum.SATS] = 0;
returnValue[CurrencyUnitEnum.BTC] = 0;
switch (from) {
case CurrencyUnitEnum.SATS:
returnValue[CurrencyUnitEnum.SATS] = value;
returnValue[CurrencyUnitEnum.BTC] = value * 0.00000001;
break;
case CurrencyUnitEnum.BTC:
returnValue[CurrencyUnitEnum.SATS] = value * 100000000;
returnValue[CurrencyUnitEnum.BTC] = value;
break;
default:
break;
}
return returnValue;
}
convertWithFiat(value: number, from: string, otherCurrencyUnit: string) {
let returnValue = {unit: otherCurrencyUnit, symbol: this.conversionData.data[otherCurrencyUnit].symbol};
returnValue[CurrencyUnitEnum.SATS] = 0;
returnValue[CurrencyUnitEnum.BTC] = 0;

@ -9,11 +9,11 @@ export function getPaginatorLabel(field: string) {
export const CURRENCY_UNITS = [ 'Sats', 'BTC' ];
export const CURRENCY_UNIT_FORMATS = { Sats: '1.0-0', BTC: '1.6-6', OTHER: '1.2-2'};
export const FIAT_CURRENCY_UNITS = [
{id: 'USD', name: 'United States Dollar'},
{id: 'USD', name: 'USD'},
{id: 'AUD', name: 'AUD'}, {id: 'BRL', name: 'BRL'}, {id: 'CAD', name: 'CAD'},
{id: 'CHF', name: 'CHF'}, {id: 'CLP', name: 'CLP'}, {id: 'CNY', name: 'CNY'},
{id: 'DKK', name: 'DKK'}, {id: 'EUR', name: 'EUR'}, {id: 'GBP', name: 'Pound'},
{id: 'HKD', name: 'HKD'}, {id: 'INR', name: 'Indian Rupee'}, {id: 'ISK', name: 'ISK'},
{id: 'DKK', name: 'DKK'}, {id: 'EUR', name: 'EUR'}, {id: 'GBP', name: 'GBP'},
{id: 'HKD', name: 'HKD'}, {id: 'INR', name: 'INR'}, {id: 'ISK', name: 'ISK'},
{id: 'JPY', name: 'JPY'}, {id: 'KRW', name: 'KRW'}, {id: 'NZD', name: 'NZD'},
{id: 'PLN', name: 'PLN'}, {id: 'RUB', name: 'RUB'}, {id: 'SEK', name: 'SEK'},
{id: 'SGD', name: 'SGD'}, {id: 'THB', name: 'THB'}, {id: 'TWD', name: 'TWD'}

@ -589,6 +589,9 @@
& .alert-icon.ng-fa-icon {
color: $yellow-alert-color;
}
& a {
color: $yellow-alert-color;
}
}
&.alert-danger {

@ -2,7 +2,7 @@ import { Action } from '@ngrx/store';
import { ErrorPayload } from '../shared/models/errorPayload';
import { DialogConfig } from '../shared/models/alertData';
import { RTLConfiguration, Settings, LightningNode, GetInfoRoot, SelNodeChild } from '../shared/models/RTLconfig';
import { RTLConfiguration, Settings, ConfigSettingsNode, GetInfoRoot, SelNodeChild } from '../shared/models/RTLconfig';
import { GetInfoCL, FeesCL, PeerCL, PaymentCL, PayRequestCL, QueryRoutesCL, ChannelCL, FeeRatesCL, ForwardingHistoryResCL, InvoiceCL, ListInvoicesCL, OnChainCL } from '../shared/models/clModels';
import {
GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode,
@ -230,7 +230,7 @@ export class UpdateSelectedNodeOptions implements Action {
export class ResetRootStore implements Action {
readonly type = RESET_ROOT_STORE;
constructor(public payload: LightningNode) {}
constructor(public payload: ConfigSettingsNode) {}
}
export class ResetLNDStore implements Action {
@ -259,7 +259,7 @@ export class SaveSettings implements Action {
export class SetSelelectedNode implements Action {
readonly type = SET_SELECTED_NODE;
constructor(public payload: { lnNode: LightningNode, isInitialSetup: boolean }) {}
constructor(public payload: { lnNode: ConfigSettingsNode, isInitialSetup: boolean }) {}
}
export class SetNodeData implements Action {

@ -13,7 +13,7 @@ import { environment, API_URL } from '../../environments/environment';
import { LoggerService } from '../shared/services/logger.service';
import { SessionService } from '../shared/services/session.service';
import { CommonService } from '../shared/services/common.service';
import { Settings, RTLConfiguration, LightningNode } from '../shared/models/RTLconfig';
import { Settings, RTLConfiguration, ConfigSettingsNode } from '../shared/models/RTLconfig';
import { AuthenticateWith, CURRENCY_UNITS, ScreenSizeEnum } from '../shared/services/consts-enums-functions';
import { SpinnerDialogComponent } from '../shared/components/data-modal/spinner-dialog/spinner-dialog.component';
@ -146,7 +146,7 @@ export class RTLEffects implements OnDestroy {
}),
map((rtlConfig: RTLConfiguration) => {
this.logger.info(rtlConfig);
let searchNode: LightningNode;
let searchNode: ConfigSettingsNode;
rtlConfig.nodes.forEach(node => {
node.settings.currencyUnits = [...CURRENCY_UNITS, node.settings.currencyUnit];
if(+node.index === rtlConfig.selectedNodeIndex) { searchNode = node; }
@ -344,7 +344,12 @@ export class RTLEffects implements OnDestroy {
initializeNode(node: any, isInitialSetup: boolean) {
const landingPage = isInitialSetup ? '' : 'HOME';
let selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit] };
let selNode = {};
if(node.settings.currencyUnit) {
selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit], fiatConversion: node.settings.fiatConversion };
} else {
selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, satsToBTC: node.settings.satsToBTC, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: CURRENCY_UNITS, fiatConversion: node.settings.fiatConversion };
}
this.store.dispatch(new RTLActions.ResetRootStore(node));
this.store.dispatch(new RTLActions.ResetLNDStore(selNode));
this.store.dispatch(new RTLActions.ResetCLStore(selNode));

@ -1,6 +1,6 @@
import { ActionReducerMap } from '@ngrx/store';
import { ErrorPayload } from '../shared/models/errorPayload';
import { RTLConfiguration, LightningNode, GetInfoRoot } from '../shared/models/RTLconfig';
import { RTLConfiguration, ConfigSettingsNode, GetInfoRoot } from '../shared/models/RTLconfig';
import * as fromCL from '../clightning/store/cl.reducers';
import * as fromLND from '../lnd/store/lnd.reducers';
@ -8,12 +8,12 @@ import * as RTLActions from './rtl.actions';
export interface RootState {
effectErrorsRoot: ErrorPayload[];
selNode: LightningNode;
selNode: ConfigSettingsNode;
appConfig: RTLConfiguration;
nodeData: GetInfoRoot;
}
const initNodeSettings = { userPersona: 'OPERATOR', flgSidenavOpened: true, flgSidenavPinned: true, menu: 'VERTICAL', menuType: 'REGULAR', fontSize: 'MEDIUM', themeMode: 'DAY', themeColor: 'PURPLE', satsToBTC: false, channelBackupPath: '', selCurrencyUnit: 'USD', currencyUnits: ['Sats', 'BTC', 'USD'] };
const initNodeSettings = { userPersona: 'OPERATOR', flgSidenavOpened: true, flgSidenavPinned: true, menu: 'VERTICAL', menuType: 'REGULAR', fontSize: 'MEDIUM', themeMode: 'DAY', themeColor: 'PURPLE', satsToBTC: false, channelBackupPath: '', selCurrencyUnit: 'USD', fiatConversion: false, currencyUnits: ['Sats', 'BTC', 'USD'] };
const initNodeAuthentication = { nodeAuthType: 'CUSTOM', configPath: '', bitcoindConfigPath: '' };
const initRootState: RootState = {

Loading…
Cancel
Save