Compare commits

...

4 Commits

Author SHA1 Message Date
ShahanaFarooqui 907b7dee31 Default node update 2 weeks ago
ShahanaFarooqui f67fedce2e Unified config models 2 weeks ago
ShahanaFarooqui 804b8fea03 application and settings case change 2 weeks ago
ShahanaFarooqui 7bcc6b359f Update Application Settings 2 weeks ago

@ -11,7 +11,7 @@ export const listPeerChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeerchannels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeerchannels';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels });
return Promise.all(body.channels?.map((channel) => {
@ -33,7 +33,7 @@ export const openChannel = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fundchannel';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fundchannel';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Options', data: options.body });
request.post(options).then((body) => {
@ -50,7 +50,7 @@ export const setChannelFee = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/setchannel';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/setchannel';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy Options', data: options.body });
request.post(options).then((body) => {
@ -68,7 +68,7 @@ export const closeChannel = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/close';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/close';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Closing Channel', data: options.url });
request.post(options).then((body) => {
@ -86,7 +86,7 @@ export const listForwards = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listforwards';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listforwards';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + status, data: body });
@ -103,7 +103,7 @@ export const funderUpdatePolicy = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/funderupdate';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/funderupdate';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body });
request.post(options).then((body) => {

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getinfo';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from Core Lightning server url ' + options.url });
if (!options.headers || !options.headers.rune) {

@ -10,7 +10,7 @@ export const deleteExpiredInvoice = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/delexpiredinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/delexpiredinvoice';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoices Deleted', data: body });
@ -26,7 +26,7 @@ export const listInvoices = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listinvoices';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listinvoices';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url });
request.post(options).then((body) => {
@ -43,7 +43,7 @@ export const addInvoice = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoice';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Created', data: body });

@ -10,7 +10,7 @@ export const getRoute = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getroute';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getroute';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body });
@ -29,7 +29,7 @@ export const listChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listchannels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listchannels';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Channel Lookup Finished', data: body });
@ -46,7 +46,7 @@ export const feeRates = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/feerates';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/feerates';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Fee Rates Received for ' + style, data: body });
@ -64,7 +64,7 @@ export const listNodes = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listnodes';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listnodes';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
request.post(options).then((body) => {
@ -80,7 +80,7 @@ export const listNodes = (req, res, next) => {
});
};
export const getAlias = (selNode, peer, id) => {
options.url = selNode.settings.lnServerUrl + '/v1/listnodes';
options.url = selNode.Settings.lnServerUrl + '/v1/listnodes';
if (!peer[id]) {
logger.log({ selectedNode: selNode, level: 'ERROR', fileName: 'Network', msg: 'Empty Peer ID' });
peer.alias = '';

@ -34,7 +34,7 @@ export const listOffers = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listoffers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listoffers';
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Offers', msg: 'Offers List URL', data: options.url });
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offers List Received', data: body });
@ -50,7 +50,7 @@ export const createOffer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/offer';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/offer';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offer Created', data: body });
@ -66,7 +66,7 @@ export const fetchOfferInvoice = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fetchinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fetchinvoice';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Offers', msg: 'Offer Invoice Body', data: options.body });
request.post(options).then((body) => {
@ -83,7 +83,7 @@ export const disableOffer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/disableOffer';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/disableOffer';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offer Disabled', data: body });

@ -10,7 +10,7 @@ export const getNewAddress = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/newaddr';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/newaddr';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated', data: body });
@ -26,7 +26,7 @@ export const onChainWithdraw = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/withdraw';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/withdraw';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'OnChain', msg: 'OnChain Withdraw Options', data: options.body });
request.post(options).then((body) => {
@ -43,7 +43,7 @@ export const getUTXOs = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listfunds';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listfunds';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Funds List Received', data: body });
// Local Remote Balance Calculation

@ -8,7 +8,7 @@ const logger = Logger;
const common = Common;
const databaseService = Database;
export const getMemo = (selNode, payment) => {
options.url = selNode.settings.lnServerUrl + '/v1/decode';
options.url = selNode.Settings.lnServerUrl + '/v1/decode';
options.body = { string: payment.bolt11 };
return request.post(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: res });
@ -81,7 +81,7 @@ export const listPayments = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listsendpays';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listsendpays';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body.payments });
body.payments = body.payments && body.payments.length && body.payments.length > 0 ? groupBy(body.payments) : [];
@ -103,7 +103,7 @@ export const postPayment = (req, res, next) => {
const options_body = JSON.parse(JSON.stringify(req.body));
if (paymentType === 'KEYSEND') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Keysend Payment..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/keysend';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/keysend';
delete options_body.uiMessage;
delete options_body.fromDialog;
delete options_body.paymentType;
@ -144,7 +144,7 @@ export const postPayment = (req, res, next) => {
delete options_body.pubkey;
delete options_body.saveToDB;
options.body = options_body;
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/pay';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/pay';
}
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Sent', data: body });

@ -11,7 +11,7 @@ export const getPeers = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeers';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers;
@ -30,12 +30,12 @@ export const postPeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/connect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/connect';
options.body = req.body;
request.post(options).then((connectRes) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peer Connected', data: connectRes });
const listOptions = common.getOptions(req);
listOptions.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeers';
listOptions.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeers';
request.post(listOptions).then((listPeersRes) => {
const peers = listPeersRes && listPeersRes.peers ? common.newestOnTop(listPeersRes.peers, 'id', connectRes.id) : [];
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peers List after Connect Received', data: peers });
@ -55,7 +55,7 @@ export const deletePeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/disconnect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/disconnect';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnected', data: body });

@ -10,7 +10,7 @@ export const decodePayment = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/decode';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/decode';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
@ -26,7 +26,7 @@ export const signMessage = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/signmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/signmessage';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Message Signed', data: body });
@ -42,7 +42,7 @@ export const verifyMessage = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/checkmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/checkmessage';
options.body = req.body;
request.post(options, (error, response, body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Message Verified', data: body });
@ -58,7 +58,7 @@ export const listConfigs = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listconfigs';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listconfigs';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Utility', msg: 'List Configs Received', data: body });
res.status(200).json(body);

@ -27,14 +27,14 @@ export class CLWebSocketClient {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists) {
if (selectedNode.settings.lnServerUrl) {
if (selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode, reConnect: true, webSocketClient: null };
this.connectWithClient(newWebSocketClient);
this.webSocketClients.push(newWebSocketClient);
}
}
else {
if ((!clientExists.webSocketClient || !clientExists.webSocketClient.connected) && selectedNode.settings.lnServerUrl) {
if ((!clientExists.webSocketClient || !clientExists.webSocketClient.connected) && selectedNode.Settings.lnServerUrl) {
clientExists.reConnect = true;
this.connectWithClient(clientExists);
}
@ -47,11 +47,11 @@ export class CLWebSocketClient {
this.connectWithClient = (clWsClt) => {
this.logger.log({ selectedNode: clWsClt.selectedNode, level: 'INFO', fileName: 'CLWebSocket', msg: 'Connecting to the Core Lightning\'s Websocket Server..' });
try {
if (!clWsClt.selectedNode.authentication.runeValue) {
clWsClt.selectedNode.authentication.runeValue = this.common.getRuneValue(clWsClt.selectedNode.authentication.runePath);
if (!clWsClt.selectedNode.Authentication.runeValue) {
clWsClt.selectedNode.Authentication.runeValue = this.common.getRuneValue(clWsClt.selectedNode.Authentication.runePath);
}
clWsClt.webSocketClient = socketIOClient(clWsClt.selectedNode.settings.lnServerUrl, {
extraHeaders: { rune: clWsClt.selectedNode.authentication.runeValue },
clWsClt.webSocketClient = socketIOClient(clWsClt.selectedNode.Settings.lnServerUrl, {
extraHeaders: { rune: clWsClt.selectedNode.Authentication.runeValue },
transports: ['websocket'],
secure: true,
rejectUnauthorized: false

@ -27,7 +27,7 @@ export const simplifyAllChannels = (selNode, channels) => {
});
});
channelNodeIds = channelNodeIds.substring(1);
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: channelNodeIds };
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Channels', msg: 'Node Ids to find alias', data: channelNodeIds });
return request.post(options).then((nodes) => {
@ -47,7 +47,7 @@ export const getChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/channels';
options.form = {};
if (req.query && req.query.nodeId) {
options.form = req.query;
@ -83,7 +83,7 @@ export const getChannelStats = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/channelstats';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/channelstats';
const today = new Date(Date.now());
const tillToday = (Math.round(today.getTime() / 1000)).toString();
const fromLastMonth = (Math.round(new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime() / 1000)).toString();
@ -105,7 +105,7 @@ export const openChannel = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/open';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/open';
options.form = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Params', data: options.form });
request.post(options).then((body) => {
@ -122,7 +122,7 @@ export const updateChannelRelayFee = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/updaterelayfee';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/updaterelayfee';
options.form = req.query;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Update Relay Fee Params', data: options.form });
request.post(options).then((body) => {
@ -140,11 +140,11 @@ export const closeChannel = (req, res, next) => {
}
if (req.query.force !== 'true') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Closing Channel..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/close';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/close';
}
else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Force Closing Channel..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/forceclose';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/forceclose';
}
options.form = { channelId: req.query.channelId };
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Close URL', data: options.url });

@ -99,7 +99,7 @@ export const getFees = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/audit';
const today = new Date(Date.now());
const tillToday = (Math.round(today.getTime() / 1000)).toString();
const fromLastMonth = (Math.round(new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime() / 1000)).toString();
@ -127,7 +127,7 @@ export const getPayments = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/audit';
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
options.form = { from: 0, to: tillToday };
if (common.read_dummy_data) {

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getinfo';
options.form = {};
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from Eclair server url ' + options.url });

@ -39,7 +39,7 @@ export const getInvoice = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/getinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getinvoice';
options.form = { paymentHash: req.params.paymentHash };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Found', data: body });
@ -55,8 +55,8 @@ export const getInvoice = (req, res, next) => {
};
export const listPendingInvoicesRequestCall = (selectedNode) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'List Pending Invoices..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/listpendinginvoices';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/listpendinginvoices';
options.form = { from: 0, to: (Math.round(new Date(Date.now()).getTime() / 1000)).toString() };
return new Promise((resolve, reject) => {
request.post(options).then((pendingInvoicesResponse) => {
@ -76,16 +76,16 @@ export const listInvoices = (req, res, next) => {
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
options.form = { from: 0, to: tillToday };
const options1 = JSON.parse(JSON.stringify(options));
options1.url = req.session.selectedNode.settings.lnServerUrl + '/listinvoices';
options1.url = req.session.selectedNode.Settings.lnServerUrl + '/listinvoices';
options1.form = { from: 0, to: tillToday };
const options2 = JSON.parse(JSON.stringify(options));
options2.url = req.session.selectedNode.settings.lnServerUrl + '/listpendinginvoices';
options2.url = req.session.selectedNode.Settings.lnServerUrl + '/listpendinginvoices';
options2.form = { from: 0, to: tillToday };
if (common.read_dummy_data) {
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then((body) => {
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.Settings.lnServerUrl, invoice))).
then((values) => res.status(200).json(invoices));
});
}
@ -96,7 +96,7 @@ export const listInvoices = (req, res, next) => {
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
if (invoices && invoices.length > 0) {
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.Settings.lnServerUrl, invoice))).
then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Sorted Invoices List Received', data: invoices });
return res.status(200).json(invoices);
@ -119,8 +119,8 @@ export const listInvoices = (req, res, next) => {
};
export const createInvoiceRequestCall = (selectedNode, description, amount) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/createinvoice';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/createinvoice';
options.form = { description: description, amountMsat: amount };
return new Promise((resolve, reject) => {
request.post(options).then((invResponse) => {

@ -10,7 +10,7 @@ export const getNodes = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/nodes';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: req.params.id };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Node Lookup Finished', data: body });
@ -22,8 +22,8 @@ export const getNodes = (req, res, next) => {
};
export const findRouteBetweenNodesRequestCall = (selectedNode, amountMsat, sourceNodeId, targetNodeId, ignoreNodeIds = [], format = 'shortChannelId') => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Network', msg: 'Find Route Between Nodes..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/findroutebetweennodes';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/findroutebetweennodes';
options.form = { amountMsat: amountMsat, sourceNodeId: sourceNodeId, targetNodeId: targetNodeId, ignoreNodeIds: ignoreNodeIds, format: format };
return new Promise((resolve, reject) => {
request.post(options).then((body) => {

@ -21,7 +21,7 @@ export const getNewAddress = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/getnewaddress';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getnewaddress';
options.form = {};
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated', data: body });
@ -37,7 +37,7 @@ export const getBalance = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/onchainbalance';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/onchainbalance';
options.form = {};
if (common.read_dummy_data) {
common.getDummyData('OnChainBalance', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(arrangeBalances(data)); });
@ -59,7 +59,7 @@ export const getTransactions = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/onchaintransactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/onchaintransactions';
options.form = {
count: req.query.count,
skip: req.query.skip
@ -80,7 +80,7 @@ export const sendFunds = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/sendonchain';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/sendonchain';
options.form = { address: address, amountSatoshis: amount, confirmationTarget: blocks };
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Onchain', msg: 'Send Funds Options', data: options.form });
request.post(options).then((body) => {

@ -5,7 +5,7 @@ let options = null;
const logger = Logger;
const common = Common;
export const getSentInfoFromPaymentRequest = (selNode, payment) => {
options.url = selNode.settings.lnServerUrl + '/getsentinfo';
options.url = selNode.Settings.lnServerUrl + '/getsentinfo';
options.form = { paymentHash: payment };
return request.post(options).then((body) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Sent Information Received', data: body });
@ -21,7 +21,7 @@ export const getSentInfoFromPaymentRequest = (selNode, payment) => {
}).catch((err) => err);
};
export const getQueryNodes = (selNode, nodeIds) => {
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: nodeIds?.reduce((acc, curr) => acc + ',' + curr) };
return request.post(options).then((nodes) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Query Nodes Received', data: nodes });
@ -34,7 +34,7 @@ export const decodePayment = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/parseinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/parseinvoice';
options.form = { invoice: req.params.invoice };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
@ -53,7 +53,7 @@ export const postPayment = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/payinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/payinvoice';
options.form = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment Options', data: options.form });
request.post(options).then((body) => {
@ -70,7 +70,7 @@ export const queryPaymentRoute = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/findroutetonode';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/findroutetonode';
options.form = {
nodeId: req.query.nodeId,
amountMsat: req.query.amountMsat
@ -129,8 +129,8 @@ export const getSentPaymentsInformation = (req, res, next) => {
};
export const sendPaymentToRouteRequestCall = (selectedNode, shortChannelIds, invoice, amountMsat) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/sendtoroute';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/sendtoroute';
options.form = { shortChannelIds: shortChannelIds, amountMsat: amountMsat, invoice: invoice };
return new Promise((resolve, reject) => {
logger.log({ selectedNode: selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment To Route Options', data: options.form });

@ -5,7 +5,7 @@ let options = null;
const logger = Logger;
const common = Common;
export const getFilteredNodes = (selNode, peersNodeIds) => {
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: peersNodeIds };
return request.post(options).then((nodes) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Peers', msg: 'Filtered Nodes Received', data: nodes });
@ -18,7 +18,7 @@ export const getPeers = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/peers';
options.form = {};
if (common.read_dummy_data) {
common.getDummyData('Peers', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(data); });
@ -58,7 +58,7 @@ export const connectPeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/connect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/connect';
options.form = {};
if (req.query) {
options.form = req.query;
@ -74,7 +74,7 @@ export const connectPeer = (req, res, next) => {
const err = common.handleError({ statusCode: 500, message: 'Connect Peer Error', error: body }, 'Peers', body, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.message, error: err.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/peers';
options.form = {};
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List after Connect', data: body });
@ -112,7 +112,7 @@ export const deletePeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/disconnect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/disconnect';
options.form = {};
if (req.params.nodeId) {
options.form = { nodeId: req.params.nodeId };

@ -28,14 +28,14 @@ export class ECLWebSocketClient {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists) {
if (selectedNode.settings.lnServerUrl) {
if (selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode, reConnect: true, webSocketClient: null };
this.connectWithClient(newWebSocketClient);
this.webSocketClients.push(newWebSocketClient);
}
}
else {
if ((!clientExists.webSocketClient || clientExists.webSocketClient.readyState !== WebSocket.OPEN) && selectedNode.settings.lnServerUrl) {
if ((!clientExists.webSocketClient || clientExists.webSocketClient.readyState !== WebSocket.OPEN) && selectedNode.Settings.lnServerUrl) {
clientExists.reConnect = true;
this.connectWithClient(clientExists);
}
@ -47,9 +47,9 @@ export class ECLWebSocketClient {
};
this.connectWithClient = (eclWsClt) => {
this.logger.log({ selectedNode: eclWsClt.selectedNode, level: 'INFO', fileName: 'ECLWebSocket', msg: 'Connecting to the Eclair\'s Websocket Server..' });
const UpdatedLNServerURL = (eclWsClt.selectedNode.settings.lnServerUrl)?.replace(/^http/, 'ws');
const UpdatedLNServerURL = (eclWsClt.selectedNode.Settings.lnServerUrl)?.replace(/^http/, 'ws');
const firstSubStrIndex = (UpdatedLNServerURL.indexOf('//') + 2);
const WS_LINK = UpdatedLNServerURL.slice(0, firstSubStrIndex) + ':' + eclWsClt.selectedNode.authentication.lnApiPassword + '@' + UpdatedLNServerURL.slice(firstSubStrIndex) + '/ws';
const WS_LINK = UpdatedLNServerURL.slice(0, firstSubStrIndex) + ':' + eclWsClt.selectedNode.Authentication.lnApiPassword + '@' + UpdatedLNServerURL.slice(firstSubStrIndex) + '/ws';
eclWsClt.webSocketClient = new WebSocket(WS_LINK);
eclWsClt.webSocketClient.onopen = () => {
this.logger.log({ selectedNode: eclWsClt.selectedNode, level: 'INFO', fileName: 'ECLWebSocket', msg: 'Connected to the Eclair\'s Websocket Server..' });

@ -10,7 +10,7 @@ export const getBlockchainBalance = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/balance/blockchain';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/balance/blockchain';
options.qs = req.query;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Balance', msg: 'Request params', data: req.params });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Balance', msg: 'Request Query', data: req.query });

@ -6,7 +6,7 @@ const logger = Logger;
const common = Common;
export const getAliasForChannel = (selNode, channel) => {
const pubkey = (channel.remote_pubkey) ? channel.remote_pubkey : (channel.remote_node_pub) ? channel.remote_node_pub : '';
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + pubkey;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + pubkey;
return request(options).then((aliasBody) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Channels', msg: 'Alias Received', data: aliasBody.node.alias });
channel.remote_alias = aliasBody.node.alias && aliasBody.node.alias !== '' ? aliasBody.node.alias : aliasBody.node.pub_key.slice(0, 20);
@ -22,7 +22,7 @@ export const getAllChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels';
options.qs = req.query;
let local = 0;
let remote = 0;
@ -60,7 +60,7 @@ export const getPendingChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/pending';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/pending';
options.qs = req.query;
request(options).then((body) => {
if (!body.total_limbo_balance) {
@ -98,7 +98,7 @@ export const getClosedChannels = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/closed';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/closed';
options.qs = req.query;
request(options).then((body) => {
if (body.channels && body.channels.length > 0) {
@ -129,7 +129,7 @@ export const postChannel = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels';
options.form = {
node_pubkey_string: node_pubkey,
local_funding_amount: local_funding_amount,
@ -162,7 +162,7 @@ export const postTransactions = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/transaction-stream';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/transaction-stream';
options.form = { payment_request: paymentReq };
if (paymentAmount) {
options.form.amt = paymentAmount;
@ -208,7 +208,7 @@ export const closeChannel = (req, res, next) => {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
const channelpoint = req.params.channelPoint?.replace(':', '/');
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/' + channelpoint + '?force=' + req.query.force;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/' + channelpoint + '?force=' + req.query.force;
if (req.query.target_conf) {
options.url = options.url + '&target_conf=' + req.query.target_conf;
}
@ -232,7 +232,7 @@ export const postChanPolicy = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/chanpolicy';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/chanpolicy';
if (chanPoint === 'all') {
options.form = JSON.stringify({
global: true,

@ -39,15 +39,15 @@ export const getBackup = (req, res, next) => {
let channel_backup_file = '';
let message = '';
if (req.params.channelPoint === 'ALL') {
channel_backup_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-all.bak';
channel_backup_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-all.bak';
message = 'All Channels Backup Successful.';
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup';
}
else {
channel_backup_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_backup_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
message = 'Channel Backup Successful.';
const channelpoint = req.params.channelPoint?.replace(':', '/');
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/' + channelpoint;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/' + channelpoint;
const exists = fs.existsSync(channel_backup_file);
if (exists) {
fs.writeFile(channel_backup_file, '', () => { });
@ -86,13 +86,13 @@ export const postBackupVerify = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/verify';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/verify';
let channel_verify_file = '';
let message = '';
let verify_backup = '';
if (req.params.channelPoint === 'ALL') {
message = 'All Channels Verify Successful.';
channel_verify_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-all.bak';
channel_verify_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-all.bak';
const exists = fs.existsSync(channel_verify_file);
if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');
@ -116,7 +116,7 @@ export const postBackupVerify = (req, res, next) => {
}
else {
message = 'Channel Verify Successful.';
channel_verify_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_verify_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
const exists = fs.existsSync(channel_verify_file);
if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');
@ -146,13 +146,13 @@ export const postRestore = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/restore';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/restore';
let channel_restore_file = '';
let message = '';
let restore_backup = '';
if (req.params.channelPoint === 'ALL') {
message = 'All Channels Restore Successful.';
channel_restore_file = req.session.selectedNode.settings.channelBackupPath + sep + 'restore' + sep;
channel_restore_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'restore' + sep;
const exists = fs.existsSync(channel_restore_file + 'channel-all.bak');
const downloaded_exists = fs.existsSync(channel_restore_file + 'backup-channel-all.bak');
if (exists) {
@ -188,7 +188,7 @@ export const postRestore = (req, res, next) => {
}
else {
message = 'Channel Restore Successful.';
channel_restore_file = req.session.selectedNode.settings.channelBackupPath + sep + 'restore' + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_restore_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'restore' + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
const exists = fs.existsSync(channel_restore_file);
if (exists) {
restore_backup = fs.readFileSync(channel_restore_file, 'utf-8');
@ -208,7 +208,7 @@ export const postRestore = (req, res, next) => {
channel_restore_file = channel_restore_file + 'channel-all.bak';
}
fs.rename(channel_restore_file, channel_restore_file + '.restored', () => {
getFilesList(req.session.selectedNode.settings.channelBackupPath, (getFilesListRes) => {
getFilesList(req.session.selectedNode.Settings.channelBackupPath, (getFilesListRes) => {
if (getFilesListRes.error) {
const errMsg = getFilesListRes.error;
const err = common.handleError({ statusCode: 500, message: 'Restore Channel Error', error: errMsg }, 'ChannelBackup', errMsg, req.session.selectedNode);
@ -228,7 +228,7 @@ export const postRestore = (req, res, next) => {
}
};
export const getRestoreList = (req, res, next) => {
getFilesList(req.session.selectedNode.settings.channelBackupPath, (getFilesListRes) => {
getFilesList(req.session.selectedNode.Settings.channelBackupPath, (getFilesListRes) => {
if (getFilesListRes.error) {
return res.status(getFilesListRes.statusCode).json(getFilesListRes);
}

@ -11,7 +11,7 @@ export const getFees = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fees';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fees';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Fees', msg: 'Fee Received', data: body });
const today = new Date(Date.now());

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getinfo';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from LND server url ' + options.url });
if (!options.headers || !options.headers['Grpc-Metadata-macaroon']) {

@ -5,7 +5,7 @@ let options = null;
const logger = Logger;
const common = Common;
export const getAliasFromPubkey = (selNode, pubkey) => {
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + pubkey;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + pubkey;
return request(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Graph', msg: 'Alias Received', data: res.node.alias });
return res.node.alias;
@ -18,7 +18,7 @@ export const getDescribeGraph = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph';
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Network Graph Received', data: body });
res.status(200).json(body);
@ -33,7 +33,7 @@ export const getGraphInfo = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/info';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/info';
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Information Received', data: body });
res.status(200).json(body);
@ -48,7 +48,7 @@ export const getGraphNode = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/node/' + req.params.pubKey;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/node/' + req.params.pubKey;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Node Information Received', data: body });
res.status(200).json(body);
@ -63,7 +63,7 @@ export const getGraphEdge = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Edge Information Received', data: body });
res.status(200).json(body);
@ -78,7 +78,7 @@ export const getQueryRoutes = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/routes/' + req.params.destPubkey + '/' + req.params.amount;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/routes/' + req.params.destPubkey + '/' + req.params.amount;
if (req.query.outgoing_chan_id) {
options.url = options.url + '?outgoing_chan_id=' + req.query.outgoing_chan_id;
}
@ -116,7 +116,7 @@ export const getRemoteFeePolicy = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Graph', msg: 'Edge Info Received', data: body });
let remoteNodeFee = {};

@ -12,7 +12,7 @@ export const invoiceLookup = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/invoices/lookup';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/invoices/lookup';
if (req.query.payment_addr) {
options.url = options.url + '?payment_addr=' + req.query.payment_addr;
}
@ -36,7 +36,7 @@ export const listInvoices = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices?num_max_invoices=' + req.query.num_max_invoices + '&index_offset=' + req.query.index_offset +
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices?num_max_invoices=' + req.query.num_max_invoices + '&index_offset=' + req.query.index_offset +
'&reversed=' + req.query.reversed;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
@ -60,7 +60,7 @@ export const addInvoice = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices';
options.form = JSON.stringify(req.body);
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Added', data: body });

@ -11,7 +11,7 @@ export const signMessage = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/signmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/signmessage';
options.form = JSON.stringify({
msg: Buffer.from(message).toString('base64')
});
@ -30,7 +30,7 @@ export const verifyMessage = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/verifymessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/verifymessage';
options.form = JSON.stringify({
msg: Buffer.from(message).toString('base64'),
signature: signature

@ -10,7 +10,7 @@ export const getNewAddress = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/newaddress?type=' + req.query.type;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/newaddress?type=' + req.query.type;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'NewAddress', msg: 'New Address Generated', data: body });
res.status(200).json(body);

@ -5,7 +5,7 @@ let options = null;
const logger = Logger;
const common = Common;
export const decodePaymentFromPaymentRequest = (selNode, payment) => {
options.url = selNode.settings.lnServerUrl + '/v1/payreq/' + payment;
options.url = selNode.Settings.lnServerUrl + '/v1/payreq/' + payment;
return request(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'PayReq', msg: 'Description Received', data: res.description });
return res;
@ -17,7 +17,7 @@ export const decodePayment = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payreq/' + req.params.payRequest;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payreq/' + req.params.payRequest;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'PayRequest', msg: 'Payment Decoded', data: body });
res.status(200).json(body);
@ -56,7 +56,7 @@ export const getPayments = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payments?max_payments=' + req.query.max_payments + '&index_offset=' + req.query.index_offset + '&reversed=' + req.query.reversed;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payments?max_payments=' + req.query.max_payments + '&index_offset=' + req.query.index_offset + '&reversed=' + req.query.reversed;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body });
res.status(200).json(body);
@ -69,8 +69,8 @@ export const getAllLightningTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Getting All Lightning Transactions..' });
const options1 = JSON.parse(JSON.stringify(common.getOptions(req)));
const options2 = JSON.parse(JSON.stringify(common.getOptions(req)));
// options1.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payments?max_payments=100000&index_offset=0&reversed=true';
options2.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices?num_max_invoices=100000&index_offset=0&reversed=true';
// options1.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payments?max_payments=100000&index_offset=0&reversed=true';
options2.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices?num_max_invoices=100000&index_offset=0&reversed=true';
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'All Payments Options', data: options1 });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'All Invoices Options', data: options2 });
// return Promise.all([request(options1), request(options2)]).then((values) => {
@ -88,7 +88,7 @@ export const paymentLookup = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/router/track/' + req.params.paymentHash;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/router/track/' + req.params.paymentHash;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Information Received for ' + req.params.paymentHash, data: body });
res.status(200).json(body.result || body);

@ -5,7 +5,7 @@ let options = null;
const logger = Logger;
const common = Common;
export const getAliasForPeers = (selNode, peer) => {
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + peer.pub_key;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + peer.pub_key;
return request(options).then((aliasBody) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Peers', msg: 'Alias Received', data: aliasBody.node.alias });
peer.alias = aliasBody.node.alias;
@ -21,7 +21,7 @@ export const getPeers = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers;
@ -41,14 +41,14 @@ export const postPeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
options.form = JSON.stringify({
addr: { host: host, pubkey: pubkey },
perm: perm
});
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peer Connected', data: body });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
request(options).then((body) => {
const peers = (!body.peers) ? [] : body.peers;
return Promise.all(peers?.map((peer) => getAliasForPeers(req.session.selectedNode, peer))).then((values) => {
@ -76,7 +76,7 @@ export const deletePeer = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers/' + req.params.peerPubKey;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers/' + req.params.peerPubKey;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnect Pubkey', data: req.params.peerPubKey });
request.delete(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconneted', data: body });

@ -27,7 +27,7 @@ export const getAllForwardingEvents = (req, start, end, offset, caller, callback
return callback({ message: err.message, error: err.error, statusCode: err.statusCode });
}
options = common.getOptions(req);
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/switch';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/switch';
options.form = {};
if (start) {
options.form.start_time = start;

@ -10,7 +10,7 @@ export const getTransactions = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/transactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/transactions';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Transactions', msg: 'Transactions List Received', data: body });
res.status(200).json(body.transactions);
@ -26,7 +26,7 @@ export const postTransactions = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/transactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/transactions';
options.form = {
amount: amount,
addr: address,

@ -12,10 +12,10 @@ export const genSeed = (req, res, next) => {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
if (req.params.passphrase) {
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/genseed?aezeed_passphrase=' + Buffer.from(atob(req.params.passphrase)).toString('base64');
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/genseed?aezeed_passphrase=' + Buffer.from(atob(req.params.passphrase)).toString('base64');
}
else {
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/genseed';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/genseed';
}
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Seed Generated', data: body });
@ -35,7 +35,7 @@ export const operateWallet = (req, res, next) => {
options.method = 'POST';
if (!req.params.operation || req.params.operation === 'unlockwallet') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Unlocking Wallet..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/unlockwallet';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/unlockwallet';
options.form = JSON.stringify({
wallet_password: Buffer.from(atob(wallet_password)).toString('base64')
});
@ -43,7 +43,7 @@ export const operateWallet = (req, res, next) => {
}
else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Initializing Wallet..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/initwallet';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/initwallet';
if (aezeed_passphrase && aezeed_passphrase !== '') {
options.form = JSON.stringify({
wallet_password: Buffer.from(atob(wallet_password)).toString('base64'),
@ -104,7 +104,7 @@ export const getUTXOs = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos';
if (common.isVersionCompatible(req.session.selectedNode.lnVersion, '0.14.0')) {
options.form = JSON.stringify({ max_confs: req.query.max_confs });
}
@ -126,7 +126,7 @@ export const bumpFee = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/bumpfee';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/bumpfee';
options.form = {};
options.form.outpoint = {
txid_str: txid,
@ -153,7 +153,7 @@ export const labelTransaction = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/tx/label';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/tx/label';
options.form = JSON.parse(JSON.stringify(options.form));
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Wallet', msg: 'Label Transaction Options', data: options.form });
request.post(options).then((body) => {
@ -171,7 +171,7 @@ export const leaseUTXO = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos/lease';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos/lease';
options.form = {};
options.form.id = txid;
options.form.outpoint = {
@ -195,7 +195,7 @@ export const releaseUTXO = (req, res, next) => {
if (options.error) {
return res.status(options.statusCode).json({ message: options.message, error: options.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos/release';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos/release';
options.form = {};
options.form.id = txid;
options.form.outpoint = {

@ -13,7 +13,7 @@ export class LNDWebSocketClient {
this.connect = (selectedNode) => {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists && selectedNode.settings.lnServerUrl) {
if (!clientExists && selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode };
this.webSocketClients.push(newWebSocketClient);
}
@ -25,7 +25,7 @@ export class LNDWebSocketClient {
this.fetchUnpaidInvoices = (selectedNode) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Getting Unpaid Invoices..' });
const options = this.setOptionsForSelNode(selectedNode);
options.url = selectedNode.settings.lnServerUrl + '/v1/invoices?pending_only=true';
options.url = selectedNode.Settings.lnServerUrl + '/v1/invoices?pending_only=true';
return request(options).then((body) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Unpaid Invoices Received', data: body });
if (body.invoices && body.invoices.length > 0) {
@ -44,7 +44,7 @@ export class LNDWebSocketClient {
this.subscribeToInvoice = (options, selectedNode, rHash) => {
rHash = rHash?.replace(/\+/g, '-')?.replace(/[/]/g, '_');
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Subscribing to Invoice ' + rHash + ' ..' });
options.url = selectedNode.settings.lnServerUrl + '/v2/invoices/subscribe/' + rHash;
options.url = selectedNode.Settings.lnServerUrl + '/v2/invoices/subscribe/' + rHash;
request(options).then((msg) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Invoice Information Received for ' + rHash });
if (typeof msg === 'string') {
@ -67,7 +67,7 @@ export class LNDWebSocketClient {
};
this.subscribeToPayment = (options, selectedNode, paymentHash) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Subscribing to Payment ' + paymentHash + ' ..' });
options.url = selectedNode.settings.lnServerUrl + '/v2/router/track/' + paymentHash;
options.url = selectedNode.Settings.lnServerUrl + '/v2/router/track/' + paymentHash;
request(options).then((msg) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Payment Information Received for ' + paymentHash });
msg['type'] = 'payment';
@ -84,7 +84,7 @@ export class LNDWebSocketClient {
this.setOptionsForSelNode = (selectedNode) => {
const options = { url: '', rejectUnauthorized: false, json: true, form: null };
try {
options['headers'] = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(selectedNode.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
options['headers'] = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(selectedNode.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
}
catch (err) {
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: 'WebSocketClient', msg: 'Set Options Error', error: JSON.stringify(err) });

@ -8,7 +8,7 @@ import { Database } from '../../utils/database.js';
import { Logger } from '../../utils/logger.js';
import { Common } from '../../utils/common.js';
import { WSServer } from '../../utils/webSocketServer.js';
import { NodeAuthentication, SSO } from '../../models/config.model.js';
import { Authentication, SSO } from '../../models/config.model.js';
const options = { url: '' };
const logger = Logger;
const common = Common;
@ -23,7 +23,7 @@ export const maskPasswords = (obj) => {
keys[keys[i]] = maskPasswords(obj[keys[i]]);
}
if (typeof keys[i] === 'string' &&
(keys[i].toLowerCase().includes('password') || keys[i].toLowerCase().includes('multipass') ||
((keys[i].toLowerCase().includes('password') && keys[i] !== 'allowPasswordUpdate') || keys[i].toLowerCase().includes('multipass') ||
keys[i].toLowerCase().includes('rpcpass') || keys[i].toLowerCase().includes('rpcpassword') ||
keys[i].toLowerCase().includes('rpcuser'))) {
obj[keys[i]] = '*'.repeat(20);
@ -32,6 +32,39 @@ export const maskPasswords = (obj) => {
}
return obj;
};
export const removeSecureData = (config) => {
delete config.rtlConfFilePath;
delete config.rtlPass;
delete config.multiPass;
delete config.multiPassHashed;
delete config.secret2FA;
config.nodes.map((node) => {
delete node.Authentication.macaroonPath;
delete node.Authentication.runePath;
delete node.Authentication.lnApiPassword;
return node;
});
return config;
};
export const addSecureData = (config) => {
config.SSO.rtlCookiePath = common.appConfig.SSO.rtlCookiePath;
config.multiPass = common.appConfig.multiPass;
config.multiPassHashed = common.appConfig.multiPassHashed;
config.secret2FA = common.appConfig.secret2FA;
config.nodes.map((node, i) => {
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.macaroonPath) {
node.Authentication.macaroonPath = common.appConfig.nodes[i].Authentication.macaroonPath;
}
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.runePath) {
node.Authentication.runePath = common.appConfig.nodes[i].Authentication.runePath;
}
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.lnApiPassword) {
node.Authentication.lnApiPassword = common.appConfig.nodes[i].Authentication.lnApiPassword;
}
return node;
});
return config;
};
export const getCurrencyRates = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting Currency Rates..' });
options.url = 'https://blockchain.info/ticker';
@ -46,7 +79,7 @@ export const getCurrencyRates = (req, res, next) => {
};
export const getFile = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting File..' });
const file = req.query.path ? req.query.path : (req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.query.channel?.replace(':', '-') + '.bak');
const file = req.query.path ? req.query.path : (req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.query.channel?.replace(':', '-') + '.bak');
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'RTLConf', msg: 'Channel Point', data: req.query.channel });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'RTLConf', msg: 'File Path', data: file });
fs.readFile(file, 'utf8', (errRes, data) => {
@ -64,7 +97,7 @@ export const getFile = (req, res, next) => {
}
});
};
export const getRTLConfig = (req, res, next) => {
export const getApplicationSettings = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
const confFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
fs.readFile(confFile, 'utf8', (errRes, data) => {
@ -74,39 +107,26 @@ export const getRTLConfig = (req, res, next) => {
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
else {
const appConfData = JSON.parse(data);
delete appConfData.rtlConfFilePath;
delete appConfData.rtlPass;
delete appConfData.multiPass;
delete appConfData.multiPassHashed;
delete appConfData.rtlSecret2fa;
const appConfData = removeSecureData(JSON.parse(data));
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
appConfData.enable2FA = common.appConfig.enable2FA;
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
appConfData.nodes.map((node) => {
node.authentication = node.Authentication;
node.settings = node.Settings;
delete node.Authentication;
delete node.Settings;
delete node.authentication.macaroonPath;
delete node.authentication.runePath;
delete node.authentication.lnApiPassword;
return node;
});
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
jwt.verify(token, common.secret_key, (err, user) => {
if (err) {
// Delete sensitive data for initial response (without security token)
// Delete unnecessary data for initial response (without security token)
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
appConfData.SSO = new SSO();
appConfData.secret2fa = '';
appConfData.secret2FA = '';
appConfData.dbDirectoryPath = '';
appConfData.nodes[selNodeIdx].authentication = new NodeAuthentication();
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
appConfData.nodes[selNodeIdx].Authentication = new Authentication();
delete appConfData.nodes[selNodeIdx].Settings.bitcoindConfigPath;
delete appConfData.nodes[selNodeIdx].Settings.lnServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.swapServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.boltzServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.enableOffers;
delete appConfData.nodes[selNodeIdx].Settings.enablePeerswap;
delete appConfData.nodes[selNodeIdx].Settings.channelBackupPath;
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
}
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
@ -138,10 +158,10 @@ export const getConfig = (req, res, next) => {
let fileFormat = 'INI';
switch (req.params.nodeType) {
case 'ln':
confFile = req.session.selectedNode.authentication.configPath;
confFile = req.session.selectedNode.Authentication.configPath;
break;
case 'bitcoind':
confFile = req.session.selectedNode.settings.bitcoindConfigPath;
confFile = req.session.selectedNode.Settings.bitcoindConfigPath;
break;
case 'rtl':
fileFormat = 'JSON';
@ -184,40 +204,21 @@ export const getConfig = (req, res, next) => {
});
};
export const updateNodeSettings = (req, res, next) => {
const { updatedSettings } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating UI Settings..' });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Node Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
if (node && node.Settings) {
node.Settings.userPersona = updatedSettings.userPersona;
node.Settings.themeMode = updatedSettings.themeMode;
node.Settings.themeColor = updatedSettings.themeColor;
node.Settings.unannouncedChannels = updatedSettings.unannouncedChannels;
node.Settings.fiatConversion = updatedSettings.fiatConversion;
if (updatedSettings.fiatConversion) {
node.Settings.currencyUnit = updatedSettings.currencyUnit ? updatedSettings.currencyUnit : 'USD';
}
else {
delete node.Settings.currencyUnit;
}
const selectedNode = common.findNode(req.session.selectedNode.index);
selectedNode.settings.userPersona = updatedSettings.userPersona;
selectedNode.settings.themeMode = updatedSettings.themeMode;
selectedNode.settings.themeColor = updatedSettings.themeColor;
selectedNode.settings.unannouncedChannels = updatedSettings.unannouncedChannels;
selectedNode.settings.fiatConversion = updatedSettings.fiatConversion;
if (updatedSettings.fiatConversion) {
selectedNode.settings.currencyUnit = updatedSettings.currencyUnit ? updatedSettings.currencyUnit : 'USD';
}
else {
delete selectedNode.settings.currencyUnit;
}
common.replaceNode(req, selectedNode);
node.Settings = req.body;
}
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'UI Settings Updated', data: maskPasswords(config) });
const selectedNode = common.findNode(req.session.selectedNode.index);
if (selectedNode && selectedNode.Settings) {
selectedNode.Settings = req.body;
common.replaceNode(req, selectedNode);
}
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Node Settings Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Node Settings Updated Successfully' });
}
catch (errRes) {
@ -227,15 +228,16 @@ export const updateNodeSettings = (req, res, next) => {
}
};
export const updateApplicationSettings = (req, res, next) => {
const { defaultNodeIndex } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Default Node..' });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Application Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
config.defaultNodeIndex = defaultNodeIndex;
try {
const config = addSecureData(req.body);
delete config.selectedNodeIndex;
delete config.enable2FA;
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Default Node Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Default Node Updated Successfully' });
common.appConfig = config;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Application Settings Updated', data: maskPasswords(common.appConfig) });
res.status(201).json(removeSecureData(config));
}
catch (errRes) {
const errMsg = 'Update Default Node Error';
@ -243,109 +245,3 @@ export const updateApplicationSettings = (req, res, next) => {
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const update2FASettings = (req, res, next) => {
const { secret2fa } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating 2FA Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
if (secret2fa && secret2fa.trim() !== '') {
config.secret2fa = secret2fa;
}
else {
delete config.secret2fa;
}
const message = secret2fa.trim() === '' ? 'Two factor authentication disabled successfully.' : 'Two factor authentication enabled successfully.';
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
common.appConfig.rtlSecret2fa = config.secret2fa;
common.appConfig.enable2FA = !!config.secret2fa;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: message });
res.status(201).json({ message: message });
}
catch (errRes) {
const errMsg = 'Update 2FA Settings Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const updateSSO = (req, res, next) => {
const { SSO } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating SSO Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
delete config.SSO;
config.SSO = SSO;
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'SSO Setting Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'SSO Updated Successfully' });
}
catch (errRes) {
const errMsg = 'Update SSO Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const updateServiceSettings = (req, res, next) => {
const { service, settings } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Service Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const selectedNode = common.findNode(req.session.selectedNode.index);
config.nodes.forEach((node) => {
if (node.index === req.session.selectedNode.index) {
switch (service) {
case 'LOOP':
if (settings.enable) {
node.Settings.swapServerUrl = settings.serverUrl;
node.Authentication.swapMacaroonPath = settings.macaroonPath;
selectedNode.settings.swapServerUrl = settings.serverUrl;
selectedNode.authentication.swapMacaroonPath = settings.macaroonPath;
}
else {
delete node.Settings.swapServerUrl;
delete node.Authentication.swapMacaroonPath;
delete selectedNode.settings.swapServerUrl;
delete selectedNode.authentication.swapMacaroonPath;
}
break;
case 'BOLTZ':
if (settings.enable) {
node.Settings.boltzServerUrl = settings.serverUrl;
node.Authentication.boltzMacaroonPath = settings.macaroonPath;
selectedNode.settings.boltzServerUrl = settings.serverUrl;
selectedNode.authentication.boltzMacaroonPath = settings.macaroonPath;
}
else {
delete node.Settings.boltzServerUrl;
delete node.Authentication.boltzMacaroonPath;
delete selectedNode.settings.boltzServerUrl;
delete selectedNode.authentication.boltzMacaroonPath;
}
break;
case 'OFFERS':
node.Settings.enableOffers = settings.enableOffers;
selectedNode.settings.enableOffers = settings.enableOffers;
break;
case 'PEERSWAP':
node.Settings.enablePeerswap = settings.enablePeerswap;
selectedNode.settings.enablePeerswap = settings.enablePeerswap;
break;
default:
break;
}
common.replaceNode(req, selectedNode);
}
return node;
});
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Service Settings Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Service Settings Updated Successfully' });
}
catch (errRes) {
const errMsg = 'Update Service Settings Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};

@ -44,7 +44,7 @@ const handleMultipleFailedAttemptsError = (failed, currentTime, errMsg) => {
};
}
};
export const verifyToken = (twoFAToken) => !!(common.appConfig.rtlSecret2fa && common.appConfig.rtlSecret2fa !== '' && otplib.authenticator.check(twoFAToken, common.appConfig.rtlSecret2fa));
export const verifyToken = (twoFAToken) => !!(common.appConfig.secret2FA && common.appConfig.secret2FA !== '' && otplib.authenticator.check(twoFAToken, common.appConfig.secret2FA));
export const authenticateUser = (req, res, next) => {
const { authenticateWith, authenticationValue, twoFAToken } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..' });

@ -1,4 +1,12 @@
export class NodeSettings {
export class SSO {
constructor(rtlSso, rtlCookiePath, logoutRedirectLink, cookieValue) {
this.rtlSso = rtlSso;
this.rtlCookiePath = rtlCookiePath;
this.logoutRedirectLink = logoutRedirectLink;
this.cookieValue = cookieValue;
}
}
export class Settings {
constructor(lnServerUrl, swapServerUrl, boltzServerUrl, bitcoindConfigPath, channelBackupPath, logLevel, logFile, userPersona, themeMode, themeColor, unannouncedChannels, fiatConversion, currencyUnit, enableOffers, enablePeerswap) {
this.lnServerUrl = lnServerUrl;
this.swapServerUrl = swapServerUrl;
@ -17,7 +25,7 @@ export class NodeSettings {
this.enablePeerswap = enablePeerswap;
}
}
export class NodeAuthentication {
export class Authentication {
constructor(options, configPath, macaroonPath, macaroonValue, runePath, runeValue, lnApiPassword, swapMacaroonPath, boltzMacaroonPath) {
this.options = options;
this.configPath = configPath;
@ -30,29 +38,8 @@ export class NodeAuthentication {
this.boltzMacaroonPath = boltzMacaroonPath;
}
}
export class SelectedNode {
constructor(logLevel, logFile, index, lnNode, lnImplementation, lnVersion, apiVersion, settings, authentication) {
this.logLevel = logLevel;
this.logFile = logFile;
this.index = index;
this.lnNode = lnNode;
this.lnImplementation = lnImplementation;
this.lnVersion = lnVersion;
this.apiVersion = apiVersion;
this.settings = settings;
this.authentication = authentication;
}
}
export class SSO {
constructor(rtlSso, rtlCookiePath, logoutRedirectLink, cookieValue) {
this.rtlSso = rtlSso;
this.rtlCookiePath = rtlCookiePath;
this.logoutRedirectLink = logoutRedirectLink;
this.cookieValue = cookieValue;
}
}
export class ApplicationConfig {
constructor(defaultNodeIndex, selectedNodeIndex, dbDirectoryPath, rtlConfFilePath, rtlPass, multiPass, multiPassHashed, allowPasswordUpdate, enable2FA, rtlSecret2fa, SSO, nodes) {
constructor(defaultNodeIndex, selectedNodeIndex, dbDirectoryPath, rtlConfFilePath, rtlPass, multiPass, multiPassHashed, allowPasswordUpdate, enable2FA, secret2FA, SSO, nodes) {
this.defaultNodeIndex = defaultNodeIndex;
this.selectedNodeIndex = selectedNodeIndex;
this.dbDirectoryPath = dbDirectoryPath;
@ -62,11 +49,23 @@ export class ApplicationConfig {
this.multiPassHashed = multiPassHashed;
this.allowPasswordUpdate = allowPasswordUpdate;
this.enable2FA = enable2FA;
this.rtlSecret2fa = rtlSecret2fa;
this.secret2FA = secret2FA;
this.SSO = SSO;
this.nodes = nodes;
}
}
export class SelectedNode {
constructor(logLevel, logFile, index, lnNode, lnImplementation, lnVersion, Settings, Authentication) {
this.logLevel = logLevel;
this.logFile = logFile;
this.index = index;
this.lnNode = lnNode;
this.lnImplementation = lnImplementation;
this.lnVersion = lnVersion;
this.Settings = Settings;
this.Authentication = Authentication;
}
}
export class LogJSONObj {
constructor(level, msg, data, error, fileName, selectedNode) {
this.level = level;

@ -1,10 +1,10 @@
import exprs from 'express';
const { Router } = exprs;
import { isAuthenticated } from '../../utils/authCheck.js';
import { getRTLConfig, updateNodeSettings, getConfig, getFile, updateSelectedNode, updateApplicationSettings, getCurrencyRates } from '../../controllers/shared/RTLConf.js';
import { updateNodeSettings, getConfig, getFile, updateSelectedNode, updateApplicationSettings, getCurrencyRates, getApplicationSettings } from '../../controllers/shared/RTLConf.js';
const router = Router();
router.get('/', getApplicationSettings);
router.get('/rates', getCurrencyRates);
router.get('/rtlconf', getRTLConfig);
router.get('/file', isAuthenticated, getFile);
router.get('/updateSelNode/:currNodeIndex/:prevNodeIndex', updateSelectedNode);
router.get('/config/:nodeType', isAuthenticated, getConfig);

@ -10,7 +10,7 @@ export class CommonService {
this.nodes = [];
this.selectedNode = null;
this.ssoInit = { rtlSso: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
this.appConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, rtlSecret2fa: '', SSO: this.ssoInit, nodes: [] };
this.appConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
this.port = 3000;
this.host = '';
this.secret_key = crypto.randomBytes(64).toString('hex');
@ -23,15 +23,15 @@ export class CommonService {
];
this.setSwapServerOptions = (req) => {
const swapOptions = {
baseUrl: req.session.selectedNode.settings.swapServerUrl,
baseUrl: req.session.selectedNode.Settings.swapServerUrl,
uri: '',
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': '' }
};
if (req.session.selectedNode.authentication.swapMacaroonPath) {
if (req.session.selectedNode.Authentication.swapMacaroonPath) {
try {
swapOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.swapMacaroonPath, 'loop.macaroon')).toString('hex') };
swapOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.swapMacaroonPath, 'loop.macaroon')).toString('hex') };
}
catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Loop macaroon Error', error: err });
@ -42,14 +42,14 @@ export class CommonService {
};
this.getBoltzServerOptions = (req) => {
const boltzOptions = {
url: req.session.selectedNode.settings.boltzServerUrl,
url: req.session.selectedNode.Settings.boltzServerUrl,
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': '' }
};
if (req.session.selectedNode.authentication.boltzMacaroonPath) {
if (req.session.selectedNode.Authentication.boltzMacaroonPath) {
try {
boltzOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.boltzMacaroonPath, 'admin.macaroon')).toString('hex') };
boltzOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.boltzMacaroonPath, 'admin.macaroon')).toString('hex') };
}
catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Boltz macaroon Error', error: err });
@ -59,12 +59,12 @@ export class CommonService {
return boltzOptions;
};
this.getOptions = (req) => {
if (req.session.selectedNode && req.session.selectedNode.authentication.options) {
req.session.selectedNode.authentication.options.method = (req.session.selectedNode.lnImplementation && req.session.selectedNode.lnImplementation.toUpperCase() === 'LND') ? 'GET' : 'POST';
delete req.session.selectedNode.authentication.options.form;
delete req.session.selectedNode.authentication.options.body;
req.session.selectedNode.authentication.options.qs = {};
return req.session.selectedNode.authentication.options;
if (req.session.selectedNode && req.session.selectedNode.Authentication.options) {
req.session.selectedNode.Authentication.options.method = (req.session.selectedNode.lnImplementation && req.session.selectedNode.lnImplementation.toUpperCase() === 'LND') ? 'GET' : 'POST';
delete req.session.selectedNode.Authentication.options.form;
delete req.session.selectedNode.Authentication.options.body;
req.session.selectedNode.Authentication.options.qs = {};
return req.session.selectedNode.Authentication.options;
}
return this.handleError({ statusCode: 401, message: 'Session expired after a day\'s inactivity' }, 'Session Expired', 'Session Expiry Error', this.selectedNode);
};
@ -72,7 +72,7 @@ export class CommonService {
if (!req.session.selectedNode) {
req.session.selectedNode = {};
}
req.session.selectedNode.authentication.options = {
req.session.selectedNode.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -83,30 +83,30 @@ export class CommonService {
switch (req.session.selectedNode.lnImplementation.toUpperCase()) {
case 'CLN':
try {
if (!req.session.selectedNode.authentication.runeValue) {
req.session.selectedNode.authentication.runeValue = this.getRuneValue(req.session.selectedNode.authentication.runePath);
if (!req.session.selectedNode.Authentication.runeValue) {
req.session.selectedNode.Authentication.runeValue = this.getRuneValue(req.session.selectedNode.Authentication.runePath);
}
req.session.selectedNode.authentication.options.headers = { rune: req.session.selectedNode.authentication.runeValue };
req.session.selectedNode.Authentication.options.headers = { rune: req.session.selectedNode.Authentication.runeValue };
}
catch (err) {
throw new Error(err);
}
break;
case 'ECL':
req.session.selectedNode.authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + req.session.selectedNode.authentication.lnApiPassword).toString('base64') };
req.session.selectedNode.Authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + req.session.selectedNode.Authentication.lnApiPassword).toString('base64') };
break;
default:
req.session.selectedNode.authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
req.session.selectedNode.Authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
break;
}
}
if (req.session.selectedNode) {
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Updated Node Options for ' + req.session.selectedNode.lnNode, data: req.session.selectedNode.authentication.options });
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Updated Node Options for ' + req.session.selectedNode.lnNode, data: req.session.selectedNode.Authentication.options });
}
return { status: 200, message: 'Updated Successfully' };
}
catch (err) {
req.session.selectedNode.authentication.options = {
req.session.selectedNode.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -128,12 +128,12 @@ export class CommonService {
}
};
this.setOptions = (req) => {
if (this.nodes[0].authentication.options && this.nodes[0].authentication.options.headers) {
if (this.nodes[0].Authentication.options && this.nodes[0].Authentication.options.headers) {
return;
}
if (this.nodes && this.nodes.length > 0) {
this.nodes.forEach((node) => {
node.authentication.options = {
node.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -144,34 +144,34 @@ export class CommonService {
switch (node.lnImplementation.toUpperCase()) {
case 'CLN':
try {
if (!node.authentication.runeValue) {
node.authentication.runeValue = this.getRuneValue(node.authentication.runePath);
if (!node.Authentication.runeValue) {
node.Authentication.runeValue = this.getRuneValue(node.Authentication.runePath);
}
node.authentication.options.headers = { rune: node.authentication.runeValue };
node.Authentication.options.headers = { rune: node.Authentication.runeValue };
}
catch (err) {
throw new Error(err);
}
break;
case 'ECL':
node.authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + node.authentication.lnApiPassword).toString('base64') };
node.Authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + node.Authentication.lnApiPassword).toString('base64') };
break;
default:
node.authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(node.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
node.Authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(node.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
break;
}
}
}
catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Common Set Options Error', error: err });
node.authentication.options = {
node.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
form: ''
};
}
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Set Node Options for ' + node.lnNode, data: node.authentication.options });
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Set Node Options for ' + node.lnNode, data: node.Authentication.options });
});
this.updateSelectedNodeOptions(req);
}
@ -411,12 +411,12 @@ export class CommonService {
}
};
this.getAllNodeAllChannelBackup = (node) => {
const channel_backup_file = node.settings.channelBackupPath + sep + 'channel-all.bak';
const channel_backup_file = node.Settings.channelBackupPath + sep + 'channel-all.bak';
const options = {
url: node.settings.lnServerUrl + '/v1/channels/backup',
url: node.Settings.lnServerUrl + '/v1/channels/backup',
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': fs.readFileSync(node.authentication.macaroonPath + '/admin.macaroon').toString('hex') }
headers: { 'Grpc-Metadata-macaroon': fs.readFileSync(node.Authentication.macaroonPath + '/admin.macaroon').toString('hex') }
};
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Getting Channel Backup for Node ' + node.lnNode + '..' });
request(options).then((body) => {
@ -478,9 +478,9 @@ export class CommonService {
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'INDEX: ' + selNode.index });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN NODE: ' + selNode.lnNode });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + selNode.lnImplementation });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + selNode.settings.fiatConversion });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + selNode.settings.currencyUnit });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + selNode.settings.lnServerUrl });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + selNode.Settings.fiatConversion });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + selNode.Settings.currencyUnit });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + selNode.Settings.lnServerUrl });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + this.appConfig.SSO.logoutRedirectLink + '\r\n' });
}
};

@ -117,20 +117,19 @@ export class ConfigService {
this.validateNodeConfig = (config) => {
if ((process?.env?.RTL_SSO && +process?.env?.RTL_SSO === 0) || (typeof process?.env?.RTL_SSO === 'undefined' && +config.SSO.rtlSSO === 0)) {
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
this.common.appConfig.rtlPass = this.hash.update(process?.env?.APP_PASSWORD).digest('hex');
config.rtlPass = this.hash.update(process?.env?.APP_PASSWORD).digest('hex');
this.common.appConfig.allowPasswordUpdate = false;
}
else if (config.multiPassHashed && config.multiPassHashed !== '') {
this.common.appConfig.rtlPass = config.multiPassHashed;
config.rtlPass = config.multiPassHashed;
}
else if (config.multiPass && config.multiPass !== '') {
this.common.appConfig.rtlPass = this.common.replacePasswordWithHash(this.hash.update(config.multiPass).digest('hex'));
config.rtlPass = this.common.replacePasswordWithHash(this.hash.update(config.multiPass).digest('hex'));
}
else {
this.errMsg = this.errMsg + '\nNode Authentication can be set with multiPass only. Please set multiPass in RTL-Config.json';
}
this.common.appConfig.rtlSecret2fa = config.secret2fa;
this.common.appConfig.enable2FA = !!config.secret2fa;
config.enable2FA = !!config.secret2FA;
}
else {
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
@ -139,10 +138,10 @@ export class ConfigService {
}
this.common.port = (process?.env?.PORT) ? this.normalizePort(process?.env?.PORT) : (config.port) ? this.normalizePort(config.port) : 3000;
this.common.host = (process?.env?.HOST) ? process?.env?.HOST : (config.host) ? config.host : null;
this.common.appConfig.dbDirectoryPath = (process?.env?.DB_DIRECTORY_PATH) ? process?.env?.DB_DIRECTORY_PATH : (config.dbDirectoryPath) ? config.dbDirectoryPath : join(dirname(fileURLToPath(import.meta.url)), '..', '..');
config.dbDirectoryPath = (process?.env?.DB_DIRECTORY_PATH) ? process?.env?.DB_DIRECTORY_PATH : (config.dbDirectoryPath) ? config.dbDirectoryPath : join(dirname(fileURLToPath(import.meta.url)), '..', '..');
if (config.nodes && config.nodes.length > 0) {
config.nodes.forEach((node, idx) => {
this.common.nodes[idx] = { settings: {}, authentication: {} };
this.common.nodes[idx] = { Settings: {}, Authentication: {} };
this.common.nodes[idx].index = node.index;
this.common.nodes[idx].lnNode = node.lnNode;
this.common.nodes[idx].lnImplementation = (process?.env?.lnImplementation) ? process?.env?.lnImplementation : node.lnImplementation ? node.lnImplementation : 'LND';
@ -152,10 +151,10 @@ export class ConfigService {
switch (this.common.nodes[idx].lnImplementation) {
case 'CLN':
if (process?.env?.RUNE_PATH && process?.env?.RUNE_PATH.trim() !== '') {
this.common.nodes[idx].authentication.runePath = process?.env?.RUNE_PATH;
this.common.nodes[idx].Authentication.runePath = process?.env?.RUNE_PATH;
}
else if (node.Authentication && node.Authentication.runePath && node.Authentication.runePath.trim() !== '') {
this.common.nodes[idx].authentication.runePath = node.Authentication.runePath;
this.common.nodes[idx].Authentication.runePath = node.Authentication.runePath;
}
else {
this.errMsg = 'Please set rune path for node index ' + node.index + ' in RTL-Config.json!';
@ -163,21 +162,21 @@ export class ConfigService {
break;
case 'ECL':
if (process?.env?.LN_API_PASSWORD) {
this.common.nodes[idx].authentication.lnApiPassword = process?.env?.LN_API_PASSWORD;
this.common.nodes[idx].Authentication.lnApiPassword = process?.env?.LN_API_PASSWORD;
}
else if (node.Authentication && node.Authentication.lnApiPassword) {
this.common.nodes[idx].authentication.lnApiPassword = node.Authentication.lnApiPassword;
this.common.nodes[idx].Authentication.lnApiPassword = node.Authentication.lnApiPassword;
}
else {
this.common.nodes[idx].authentication.lnApiPassword = '';
this.common.nodes[idx].Authentication.lnApiPassword = '';
}
break;
default:
if (process?.env?.MACAROON_PATH && process?.env?.MACAROON_PATH.trim() !== '') {
this.common.nodes[idx].authentication.macaroonPath = process?.env?.MACAROON_PATH;
this.common.nodes[idx].Authentication.macaroonPath = process?.env?.MACAROON_PATH;
}
else if (node.Authentication && node.Authentication.macaroonPath && node.Authentication.macaroonPath.trim() !== '') {
this.common.nodes[idx].authentication.macaroonPath = node.Authentication.macaroonPath;
this.common.nodes[idx].Authentication.macaroonPath = node.Authentication.macaroonPath;
}
else {
this.errMsg = 'Please set macaroon path for node index ' + node.index + ' in RTL-Config.json!';
@ -185,100 +184,100 @@ export class ConfigService {
break;
}
if (process?.env?.CONFIG_PATH) {
this.common.nodes[idx].authentication.configPath = process?.env?.CONFIG_PATH;
this.common.nodes[idx].Authentication.configPath = process?.env?.CONFIG_PATH;
}
else if (node.Authentication && node.Authentication.configPath) {
this.common.nodes[idx].authentication.configPath = node.Authentication.configPath;
this.common.nodes[idx].Authentication.configPath = node.Authentication.configPath;
}
else {
this.common.nodes[idx].authentication.configPath = '';
this.common.nodes[idx].Authentication.configPath = '';
}
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].authentication.lnApiPassword === '' && this.common.nodes[idx].authentication.configPath !== '') {
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].Authentication.lnApiPassword === '' && this.common.nodes[idx].Authentication.configPath !== '') {
try {
const exists = fs.existsSync(this.common.nodes[idx].authentication.configPath || '');
const exists = fs.existsSync(this.common.nodes[idx].Authentication.configPath || '');
if (exists) {
try {
const configFile = fs.readFileSync((this.common.nodes[idx].authentication.configPath || ''), 'utf-8');
const configFile = fs.readFileSync((this.common.nodes[idx].Authentication.configPath || ''), 'utf-8');
const iniParsed = ini.parse(configFile);
this.common.nodes[idx].authentication.lnApiPassword = iniParsed['eclair.api.password'] ? iniParsed['eclair.api.password'] : parseHocon(configFile).eclair.api.password;
this.common.nodes[idx].Authentication.lnApiPassword = iniParsed['eclair.api.password'] ? iniParsed['eclair.api.password'] : parseHocon(configFile).eclair.api.password;
}
catch (err) {
this.errMsg = this.errMsg + '\nSomething went wrong while reading config file: \n' + err;
}
}
else {
this.errMsg = this.errMsg + '\nInvalid config path: ' + this.common.nodes[idx].authentication.configPath;
this.errMsg = this.errMsg + '\nInvalid config path: ' + this.common.nodes[idx].Authentication.configPath;
}
}
catch (err) {
this.errMsg = this.errMsg + '\nUnable to read config file: \n' + err;
}
}
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].authentication.lnApiPassword === '') {
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].Authentication.lnApiPassword === '') {
this.errMsg = this.errMsg + '\nPlease set config path Or api password for node index ' + node.index + ' in RTL-Config.json! It is mandatory for Eclair authentication!';
}
if (process?.env?.LN_SERVER_URL && process?.env?.LN_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = process?.env?.LN_SERVER_URL.endsWith('/v1') ? process?.env?.LN_SERVER_URL.slice(0, -3) : process?.env?.LN_SERVER_URL;
this.common.nodes[idx].Settings.lnServerUrl = process?.env?.LN_SERVER_URL.endsWith('/v1') ? process?.env?.LN_SERVER_URL.slice(0, -3) : process?.env?.LN_SERVER_URL;
}
else if (process?.env?.LND_SERVER_URL && process?.env?.LND_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = process?.env?.LND_SERVER_URL.endsWith('/v1') ? process?.env?.LND_SERVER_URL.slice(0, -3) : process?.env?.LND_SERVER_URL;
this.common.nodes[idx].Settings.lnServerUrl = process?.env?.LND_SERVER_URL.endsWith('/v1') ? process?.env?.LND_SERVER_URL.slice(0, -3) : process?.env?.LND_SERVER_URL;
}
else if (node.Settings.lnServerUrl && node.Settings.lnServerUrl.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = node.Settings.lnServerUrl.endsWith('/v1') ? node.Settings.lnServerUrl.slice(0, -3) : node.Settings.lnServerUrl;
this.common.nodes[idx].Settings.lnServerUrl = node.Settings.lnServerUrl.endsWith('/v1') ? node.Settings.lnServerUrl.slice(0, -3) : node.Settings.lnServerUrl;
}
else if (node.Settings.lndServerUrl && node.Settings.lndServerUrl.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = node.Settings.lndServerUrl.endsWith('/v1') ? node.Settings.lndServerUrl.slice(0, -3) : node.Settings.lndServerUrl;
this.common.nodes[idx].Settings.lnServerUrl = node.Settings.lndServerUrl.endsWith('/v1') ? node.Settings.lndServerUrl.slice(0, -3) : node.Settings.lndServerUrl;
}
else {
this.errMsg = this.errMsg + '\nPlease set LN Server URL for node index ' + node.index + ' in RTL-Config.json!';
}
this.common.nodes[idx].settings.userPersona = node.Settings.userPersona ? node.Settings.userPersona : 'MERCHANT';
this.common.nodes[idx].settings.themeMode = node.Settings.themeMode ? node.Settings.themeMode : 'DAY';
this.common.nodes[idx].settings.themeColor = node.Settings.themeColor ? node.Settings.themeColor : 'PURPLE';
this.common.nodes[idx].settings.unannouncedChannels = node.Settings.unannouncedChannels ? !!node.Settings.unannouncedChannels : false;
this.common.nodes[idx].settings.logLevel = node.Settings.logLevel ? node.Settings.logLevel : 'ERROR';
this.common.nodes[idx].settings.fiatConversion = node.Settings.fiatConversion ? !!node.Settings.fiatConversion : false;
if (this.common.nodes[idx].settings.fiatConversion) {
this.common.nodes[idx].settings.currencyUnit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
this.common.nodes[idx].Settings.userPersona = node.Settings.userPersona ? node.Settings.userPersona : 'MERCHANT';
this.common.nodes[idx].Settings.themeMode = node.Settings.themeMode ? node.Settings.themeMode : 'DAY';
this.common.nodes[idx].Settings.themeColor = node.Settings.themeColor ? node.Settings.themeColor : 'PURPLE';
this.common.nodes[idx].Settings.unannouncedChannels = node.Settings.unannouncedChannels ? !!node.Settings.unannouncedChannels : false;
this.common.nodes[idx].Settings.logLevel = node.Settings.logLevel ? node.Settings.logLevel : 'ERROR';
this.common.nodes[idx].Settings.fiatConversion = node.Settings.fiatConversion ? !!node.Settings.fiatConversion : false;
if (this.common.nodes[idx].Settings.fiatConversion) {
this.common.nodes[idx].Settings.currencyUnit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
}
if (process?.env?.SWAP_SERVER_URL && process?.env?.SWAP_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.swapServerUrl = process?.env?.SWAP_SERVER_URL.endsWith('/v1') ? process?.env?.SWAP_SERVER_URL.slice(0, -3) : process?.env?.SWAP_SERVER_URL;
this.common.nodes[idx].authentication.swapMacaroonPath = process?.env?.SWAP_MACAROON_PATH;
this.common.nodes[idx].Settings.swapServerUrl = process?.env?.SWAP_SERVER_URL.endsWith('/v1') ? process?.env?.SWAP_SERVER_URL.slice(0, -3) : process?.env?.SWAP_SERVER_URL;
this.common.nodes[idx].Authentication.swapMacaroonPath = process?.env?.SWAP_MACAROON_PATH;
}
else if (node.Settings.swapServerUrl && node.Settings.swapServerUrl.trim() !== '') {
this.common.nodes[idx].settings.swapServerUrl = node.Settings.swapServerUrl.endsWith('/v1') ? node.Settings.swapServerUrl.slice(0, -3) : node.Settings.swapServerUrl;
this.common.nodes[idx].authentication.swapMacaroonPath = node.Authentication.swapMacaroonPath ? node.Authentication.swapMacaroonPath : '';
this.common.nodes[idx].Settings.swapServerUrl = node.Settings.swapServerUrl.endsWith('/v1') ? node.Settings.swapServerUrl.slice(0, -3) : node.Settings.swapServerUrl;
this.common.nodes[idx].Authentication.swapMacaroonPath = node.Authentication.swapMacaroonPath ? node.Authentication.swapMacaroonPath : '';
}
else {
this.common.nodes[idx].settings.swapServerUrl = '';
this.common.nodes[idx].authentication.swapMacaroonPath = '';
this.common.nodes[idx].Settings.swapServerUrl = '';
this.common.nodes[idx].Authentication.swapMacaroonPath = '';
}
if (process?.env?.BOLTZ_SERVER_URL && process?.env?.BOLTZ_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.boltzServerUrl = process?.env?.BOLTZ_SERVER_URL.endsWith('/v1') ? process?.env?.BOLTZ_SERVER_URL.slice(0, -3) : process?.env?.BOLTZ_SERVER_URL;
this.common.nodes[idx].authentication.boltzMacaroonPath = process?.env?.BOLTZ_MACAROON_PATH;
this.common.nodes[idx].Settings.boltzServerUrl = process?.env?.BOLTZ_SERVER_URL.endsWith('/v1') ? process?.env?.BOLTZ_SERVER_URL.slice(0, -3) : process?.env?.BOLTZ_SERVER_URL;
this.common.nodes[idx].Authentication.boltzMacaroonPath = process?.env?.BOLTZ_MACAROON_PATH;
}
else if (node.Settings.boltzServerUrl && node.Settings.boltzServerUrl.trim() !== '') {
this.common.nodes[idx].settings.boltzServerUrl = node.Settings.boltzServerUrl.endsWith('/v1') ? node.Settings.boltzServerUrl.slice(0, -3) : node.Settings.boltzServerUrl;
this.common.nodes[idx].authentication.boltzMacaroonPath = node.Authentication.boltzMacaroonPath ? node.Authentication.boltzMacaroonPath : '';
this.common.nodes[idx].Settings.boltzServerUrl = node.Settings.boltzServerUrl.endsWith('/v1') ? node.Settings.boltzServerUrl.slice(0, -3) : node.Settings.boltzServerUrl;
this.common.nodes[idx].Authentication.boltzMacaroonPath = node.Authentication.boltzMacaroonPath ? node.Authentication.boltzMacaroonPath : '';
}
else {
this.common.nodes[idx].settings.boltzServerUrl = '';
this.common.nodes[idx].authentication.boltzMacaroonPath = '';
this.common.nodes[idx].Settings.boltzServerUrl = '';
this.common.nodes[idx].Authentication.boltzMacaroonPath = '';
}
this.common.nodes[idx].settings.enableOffers = process?.env?.ENABLE_OFFERS ? process?.env?.ENABLE_OFFERS : (node.Settings.enableOffers) ? node.Settings.enableOffers : false;
this.common.nodes[idx].settings.enablePeerswap = process?.env?.ENABLE_PEERSWAP ? process?.env?.ENABLE_PEERSWAP : (node.Settings.enablePeerswap) ? node.Settings.enablePeerswap : false;
this.common.nodes[idx].settings.bitcoindConfigPath = process?.env?.BITCOIND_CONFIG_PATH ? process?.env?.BITCOIND_CONFIG_PATH : (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
this.common.nodes[idx].settings.channelBackupPath = process?.env?.CHANNEL_BACKUP_PATH ? process?.env?.CHANNEL_BACKUP_PATH : (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : this.common.appConfig.rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node.index;
this.common.nodes[idx].Settings.enableOffers = process?.env?.ENABLE_OFFERS ? process?.env?.ENABLE_OFFERS : (node.Settings.enableOffers) ? node.Settings.enableOffers : false;
this.common.nodes[idx].Settings.enablePeerswap = process?.env?.ENABLE_PEERSWAP ? process?.env?.ENABLE_PEERSWAP : (node.Settings.enablePeerswap) ? node.Settings.enablePeerswap : false;
this.common.nodes[idx].Settings.bitcoindConfigPath = process?.env?.BITCOIND_CONFIG_PATH ? process?.env?.BITCOIND_CONFIG_PATH : (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
this.common.nodes[idx].Settings.channelBackupPath = process?.env?.CHANNEL_BACKUP_PATH ? process?.env?.CHANNEL_BACKUP_PATH : (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : this.common.appConfig.rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node.index;
try {
this.common.createDirectory(this.common.nodes[idx].settings.channelBackupPath);
const exists = fs.existsSync(this.common.nodes[idx].settings.channelBackupPath + sep + 'channel-all.bak');
this.common.createDirectory(this.common.nodes[idx].Settings.channelBackupPath);
const exists = fs.existsSync(this.common.nodes[idx].Settings.channelBackupPath + sep + 'channel-all.bak');
if (!exists) {
try {
if (this.common.nodes[idx].lnImplementation === 'LND') {
this.common.getAllNodeAllChannelBackup(this.common.nodes[idx]);
}
else {
const createStream = fs.createWriteStream(this.common.nodes[idx].settings.channelBackupPath + sep + 'channel-all.bak');
const createStream = fs.createWriteStream(this.common.nodes[idx].Settings.channelBackupPath + sep + 'channel-all.bak');
createStream.end();
}
}
@ -290,9 +289,9 @@ export class ConfigService {
catch (err) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while creating the backup directory: \n' + err });
}
this.common.nodes[idx].settings.logFile = this.common.appConfig.rtlConfFilePath + '/logs/RTL-Node-' + node.index + '.log';
this.common.nodes[idx].Settings.logFile = config.rtlConfFilePath + '/logs/RTL-Node-' + node.index + '.log';
this.logger.log({ selectedNode: this.common.selectedNode, level: 'INFO', fileName: 'Config', msg: 'Node Config: ' + JSON.stringify(this.common.nodes[idx]) });
const log_file = this.common.nodes[idx].settings.logFile;
const log_file = this.common.nodes[idx].Settings.logFile;
if (fs.existsSync(log_file || '')) {
fs.writeFile((log_file || ''), '', () => { });
}
@ -316,28 +315,28 @@ export class ConfigService {
};
this.setSSOParams = (config) => {
if (process?.env?.RTL_SSO) {
this.common.appConfig.SSO.rtlSso = +process?.env?.RTL_SSO;
config.SSO.rtlSso = +process?.env?.RTL_SSO;
}
else if (config.SSO && config.SSO.rtlSSO) {
this.common.appConfig.SSO.rtlSso = config.SSO.rtlSSO;
config.SSO.rtlSso = config.SSO.rtlSSO;
}
if (process?.env?.RTL_COOKIE_PATH) {
this.common.appConfig.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
config.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
}
else if (config.SSO && config.SSO.rtlCookiePath) {
this.common.appConfig.SSO.rtlCookiePath = config.SSO.rtlCookiePath;
config.SSO.rtlCookiePath = config.SSO.rtlCookiePath;
}
else {
this.common.appConfig.SSO.rtlCookiePath = '';
config.SSO.rtlCookiePath = '';
}
if (process?.env?.LOGOUT_REDIRECT_LINK) {
this.common.appConfig.SSO.logoutRedirectLink = process?.env?.LOGOUT_REDIRECT_LINK;
config.SSO.logoutRedirectLink = process?.env?.LOGOUT_REDIRECT_LINK;
}
else if (config.SSO && config.SSO.logoutRedirectLink) {
this.common.appConfig.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
}
if (+this.common.appConfig.SSO.rtlSso) {
if (!this.common.appConfig.SSO.rtlCookiePath || this.common.appConfig.SSO.rtlCookiePath.trim() === '') {
if (+config.SSO.rtlSso) {
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
}
else {
@ -361,9 +360,11 @@ export class ConfigService {
fs.writeFileSync(confFileFullPath, JSON.stringify(this.setDefaultConfig()));
}
const config = JSON.parse(fs.readFileSync(confFileFullPath, 'utf-8'));
config.rtlConfFilePath = this.common.appConfig.rtlConfFilePath;
this.updateLogByLevel();
this.validateNodeConfig(config);
this.setSelectedNode(config);
this.common.appConfig = config;
}
catch (err) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while configuring the node server: \n' + err });

@ -16,15 +16,15 @@ export class LoggerService {
msgStr = msgStr + '.\r\n';
}
console.error(msgStr);
if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
break;
case 'WARN':
msgStr = prepMsgData(msgJSON, msgStr);
if (!msgJSON.selectedNode || msgJSON.selectedNode.settings.logLevel === 'WARN' || msgJSON.selectedNode.settings.logLevel === 'INFO' || msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (!msgJSON.selectedNode || msgJSON.selectedNode.Settings.logLevel === 'WARN' || msgJSON.selectedNode.Settings.logLevel === 'INFO' || msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;
@ -32,18 +32,18 @@ export class LoggerService {
if (!msgJSON.selectedNode && msgJSON.fileName === 'RTL') {
console.log(msgStr + '.\r\n');
}
else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'INFO') {
else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'INFO') {
msgStr = msgStr + '.\r\n';
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
msgStr = prepMsgData(msgJSON, msgStr);
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;
@ -51,11 +51,11 @@ export class LoggerService {
if (!msgJSON.selectedNode) {
console.log(msgStr + '.\r\n');
}
else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
msgStr = prepMsgData(msgJSON, msgStr);
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;

@ -11,7 +11,7 @@ export const listPeerChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Peer Channels..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeerchannels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeerchannels';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels });
return Promise.all(body.channels?.map((channel) => {
@ -32,7 +32,7 @@ export const openChannel = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fundchannel';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fundchannel';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Options', data: options.body });
request.post(options).then((body) => {
@ -48,7 +48,7 @@ export const setChannelFee = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Setting Channel Fee..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/setchannel';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/setchannel';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy Options', data: options.body });
request.post(options).then((body) => {
@ -65,7 +65,7 @@ export const closeChannel = (req, res, next) => {
req.setTimeout(60000 * 10); // timeout 10 mins
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/close';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/close';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Closing Channel', data: options.url });
request.post(options).then((body) => {
@ -82,7 +82,7 @@ export const listForwards = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Channel List Forwards..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listforwards';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listforwards';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + status, data: body });
@ -98,7 +98,7 @@ export const funderUpdatePolicy = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting or Updating Funder Policy..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/funderupdate';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/funderupdate';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body });
request.post(options).then((body) => {

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
common.setOptions(req);
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getinfo';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from Core Lightning server url ' + options.url });
if (!options.headers || !options.headers.rune) {

@ -9,7 +9,7 @@ export const deleteExpiredInvoice = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Deleting Expired Invoices..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/delexpiredinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/delexpiredinvoice';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoices Deleted', data: body });
@ -24,7 +24,7 @@ export const listInvoices = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Getting Invoices..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listinvoices';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listinvoices';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url });
request.post(options).then((body) => {
@ -40,7 +40,7 @@ export const addInvoice = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoice';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Created', data: body });

@ -11,7 +11,7 @@ export const getRoute = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Getting Network Routes..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getroute';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getroute';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body });
@ -29,7 +29,7 @@ export const listChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Channel Lookup..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listchannels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listchannels';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Channel Lookup Finished', data: body });
@ -45,7 +45,7 @@ export const feeRates = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Getting Network Fee Rates..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/feerates';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/feerates';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Fee Rates Received for ' + style, data: body });
@ -62,7 +62,7 @@ export const listNodes = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listnodes';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listnodes';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
request.post(options).then((body) => {
@ -79,7 +79,7 @@ export const listNodes = (req, res, next) => {
};
export const getAlias = (selNode: SelectedNode, peer: any, id: string) => {
options.url = selNode.settings.lnServerUrl + '/v1/listnodes';
options.url = selNode.Settings.lnServerUrl + '/v1/listnodes';
if (!peer[id]) {
logger.log({ selectedNode: selNode, level: 'ERROR', fileName: 'Network', msg: 'Empty Peer ID' });
peer.alias = '';

@ -36,7 +36,7 @@ export const listOffers = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Getting Offers..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listoffers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listoffers';
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Offers', msg: 'Offers List URL', data: options.url });
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offers List Received', data: body });
@ -51,7 +51,7 @@ export const createOffer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Creating Offer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/offer';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/offer';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offer Created', data: body });
@ -66,7 +66,7 @@ export const fetchOfferInvoice = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Getting Offer Invoice..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fetchinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fetchinvoice';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Offers', msg: 'Offer Invoice Body', data: options.body });
request.post(options).then((body) => {
@ -82,7 +82,7 @@ export const disableOffer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Disabling Offer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/disableOffer';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/disableOffer';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Offers', msg: 'Offer Disabled', data: body });

@ -9,7 +9,7 @@ export const getNewAddress = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Generating New Address..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/newaddr';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/newaddr';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated', data: body });
@ -24,7 +24,7 @@ export const onChainWithdraw = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Withdrawing from On Chain..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/withdraw';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/withdraw';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'OnChain', msg: 'OnChain Withdraw Options', data: options.body });
request.post(options).then((body) => {
@ -40,7 +40,7 @@ export const getUTXOs = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Listing Funds..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listfunds';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listfunds';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Funds List Received', data: body });
// Local Remote Balance Calculation

@ -11,7 +11,7 @@ const common: CommonService = Common;
const databaseService: DatabaseService = Database;
export const getMemo = (selNode: SelectedNode, payment: any) => {
options.url = selNode.settings.lnServerUrl + '/v1/decode';
options.url = selNode.Settings.lnServerUrl + '/v1/decode';
options.body = { string: payment.bolt11 };
return request.post(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: res });
@ -74,7 +74,7 @@ export const listPayments = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'List Payments..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listsendpays';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listsendpays';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body.payments });
body.payments = body.payments && body.payments.length && body.payments.length > 0 ? groupBy(body.payments) : [];
@ -95,7 +95,7 @@ export const postPayment = (req, res, next) => {
const options_body = JSON.parse(JSON.stringify(req.body));
if (paymentType === 'KEYSEND') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Keysend Payment..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/keysend';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/keysend';
delete options_body.uiMessage;
delete options_body.fromDialog;
delete options_body.paymentType;
@ -134,7 +134,7 @@ export const postPayment = (req, res, next) => {
delete options_body.pubkey;
delete options_body.saveToDB;
options.body = options_body;
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/pay';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/pay';
}
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Sent', data: body });

@ -11,7 +11,7 @@ export const getPeers = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'List Peers..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeers';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers;
@ -29,12 +29,12 @@ export const postPeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Connecting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/connect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/connect';
options.body = req.body;
request.post(options).then((connectRes) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peer Connected', data: connectRes });
const listOptions = common.getOptions(req);
listOptions.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listpeers';
listOptions.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listpeers';
request.post(listOptions).then((listPeersRes) => {
const peers = listPeersRes && listPeersRes.peers ? common.newestOnTop(listPeersRes.peers, 'id', connectRes.id) : [];
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peers List after Connect Received', data: peers });
@ -53,7 +53,7 @@ export const deletePeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Disconnecting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/disconnect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/disconnect';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnected', data: body });

@ -10,7 +10,7 @@ export const decodePayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/decode';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/decode';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
@ -25,7 +25,7 @@ export const signMessage = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Signing Message..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/signmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/signmessage';
options.body = req.body;
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Message Signed', data: body });
@ -40,7 +40,7 @@ export const verifyMessage = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Verifying Message..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/checkmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/checkmessage';
options.body = req.body;
request.post(options, (error, response, body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Message Verified', data: body });
@ -55,7 +55,7 @@ export const listConfigs = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Utility', msg: 'List Configs..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/listconfigs';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/listconfigs';
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Utility', msg: 'List Configs Received', data: body });
res.status(200).json(body);

@ -38,13 +38,13 @@ export class CLWebSocketClient {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists) {
if (selectedNode.settings.lnServerUrl) {
if (selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode, reConnect: true, webSocketClient: null };
this.connectWithClient(newWebSocketClient);
this.webSocketClients.push(newWebSocketClient);
}
} else {
if ((!clientExists.webSocketClient || !clientExists.webSocketClient.connected) && selectedNode.settings.lnServerUrl) {
if ((!clientExists.webSocketClient || !clientExists.webSocketClient.connected) && selectedNode.Settings.lnServerUrl) {
clientExists.reConnect = true;
this.connectWithClient(clientExists);
}
@ -57,11 +57,11 @@ export class CLWebSocketClient {
public connectWithClient = (clWsClt) => {
this.logger.log({ selectedNode: clWsClt.selectedNode, level: 'INFO', fileName: 'CLWebSocket', msg: 'Connecting to the Core Lightning\'s Websocket Server..' });
try {
if (!clWsClt.selectedNode.authentication.runeValue) {
clWsClt.selectedNode.authentication.runeValue = this.common.getRuneValue(clWsClt.selectedNode.authentication.runePath);
if (!clWsClt.selectedNode.Authentication.runeValue) {
clWsClt.selectedNode.Authentication.runeValue = this.common.getRuneValue(clWsClt.selectedNode.Authentication.runePath);
}
clWsClt.webSocketClient = socketIOClient(clWsClt.selectedNode.settings.lnServerUrl, {
extraHeaders: { rune: clWsClt.selectedNode.authentication.runeValue },
clWsClt.webSocketClient = socketIOClient(clWsClt.selectedNode.Settings.lnServerUrl, {
extraHeaders: { rune: clWsClt.selectedNode.Authentication.runeValue },
transports: ['websocket'],
secure: true,
rejectUnauthorized: false

@ -30,7 +30,7 @@ export const simplifyAllChannels = (selNode: SelectedNode, channels) => {
});
});
channelNodeIds = channelNodeIds.substring(1);
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: channelNodeIds };
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Channels', msg: 'Node Ids to find alias', data: channelNodeIds });
return request.post(options).then((nodes) => {
@ -49,7 +49,7 @@ export const getChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'List Channels..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/channels';
options.form = {};
if (req.query && req.query.nodeId) {
options.form = req.query;
@ -82,7 +82,7 @@ export const getChannelStats = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Channel States..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/channelstats';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/channelstats';
const today = new Date(Date.now());
const tillToday = (Math.round(today.getTime() / 1000)).toString();
const fromLastMonth = (Math.round(new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime() / 1000)).toString();
@ -103,7 +103,7 @@ export const openChannel = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/open';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/open';
options.form = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Params', data: options.form });
request.post(options).then((body) => {
@ -119,7 +119,7 @@ export const updateChannelRelayFee = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Updating Channel Relay Fee..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/updaterelayfee';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/updaterelayfee';
options.form = req.query;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Update Relay Fee Params', data: options.form });
request.post(options).then((body) => {
@ -136,10 +136,10 @@ export const closeChannel = (req, res, next) => {
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
if (req.query.force !== 'true') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Closing Channel..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/close';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/close';
} else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Force Closing Channel..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/forceclose';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/forceclose';
}
options.form = { channelId: req.query.channelId };
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Close URL', data: options.url });

@ -84,7 +84,7 @@ export const getFees = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Fees', msg: 'Getting Fees..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/audit';
const today = new Date(Date.now());
const tillToday = (Math.round(today.getTime() / 1000)).toString();
const fromLastMonth = (Math.round(new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime() / 1000)).toString();
@ -110,7 +110,7 @@ export const getPayments = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Fees', msg: 'Getting Payments..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/audit';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/audit';
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
options.form = { from: 0, to: tillToday };
if (common.read_dummy_data) {

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
common.setOptions(req);
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getinfo';
options.form = {};
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from Eclair server url ' + options.url });

@ -37,7 +37,7 @@ export const getInvoice = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Invoice..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/getinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getinvoice';
options.form = { paymentHash: req.params.paymentHash };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Found', data: body });
@ -54,8 +54,8 @@ export const getInvoice = (req, res, next) => {
export const listPendingInvoicesRequestCall = (selectedNode: SelectedNode) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'List Pending Invoices..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/listpendinginvoices';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/listpendinginvoices';
options.form = { from: 0, to: (Math.round(new Date(Date.now()).getTime() / 1000)).toString() };
return new Promise((resolve, reject) => {
request.post(options).then((pendingInvoicesResponse) => {
@ -74,16 +74,16 @@ export const listInvoices = (req, res, next) => {
const tillToday = (Math.round(new Date(Date.now()).getTime() / 1000)).toString();
options.form = { from: 0, to: tillToday };
const options1 = JSON.parse(JSON.stringify(options));
options1.url = req.session.selectedNode.settings.lnServerUrl + '/listinvoices';
options1.url = req.session.selectedNode.Settings.lnServerUrl + '/listinvoices';
options1.form = { from: 0, to: tillToday };
const options2 = JSON.parse(JSON.stringify(options));
options2.url = req.session.selectedNode.settings.lnServerUrl + '/listpendinginvoices';
options2.url = req.session.selectedNode.Settings.lnServerUrl + '/listpendinginvoices';
options2.form = { from: 0, to: tillToday };
if (common.read_dummy_data) {
return common.getDummyData('Invoices', req.session.selectedNode.lnImplementation).then((body) => {
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.Settings.lnServerUrl, invoice))).
then((values) => res.status(200).json(invoices));
});
} else {
@ -93,7 +93,7 @@ export const listInvoices = (req, res, next) => {
const invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
if (invoices && invoices.length > 0) {
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.settings.lnServerUrl, invoice))).
return Promise.all(invoices?.map((invoice) => getReceivedPaymentInfo(req.session.selectedNode.Settings.lnServerUrl, invoice))).
then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Sorted Invoices List Received', data: invoices });
return res.status(200).json(invoices);
@ -116,8 +116,8 @@ export const listInvoices = (req, res, next) => {
export const createInvoiceRequestCall = (selectedNode: SelectedNode, description: string, amount: number) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/createinvoice';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/createinvoice';
options.form = { description: description, amountMsat: amount };
return new Promise((resolve, reject) => {
request.post(options).then((invResponse) => {

@ -10,7 +10,7 @@ export const getNodes = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Node Lookup..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/nodes';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: req.params.id };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Node Lookup Finished', data: body });
@ -23,8 +23,8 @@ export const getNodes = (req, res, next) => {
export const findRouteBetweenNodesRequestCall = (selectedNode: SelectedNode, amountMsat: number, sourceNodeId: string, targetNodeId: string, ignoreNodeIds: string[] = [], format: string = 'shortChannelId') => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Network', msg: 'Find Route Between Nodes..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/findroutebetweennodes';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/findroutebetweennodes';
options.form = { amountMsat: amountMsat, sourceNodeId: sourceNodeId, targetNodeId: targetNodeId, ignoreNodeIds: ignoreNodeIds, format: format };
return new Promise((resolve, reject) => {
request.post(options).then((body) => {

@ -17,7 +17,7 @@ export const getNewAddress = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Generating New Address..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/getnewaddress';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/getnewaddress';
options.form = {};
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated', data: body });
@ -32,7 +32,7 @@ export const getBalance = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Getting On Chain Balance..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/onchainbalance';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/onchainbalance';
options.form = {};
if (common.read_dummy_data) {
common.getDummyData('OnChainBalance', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(arrangeBalances(data)); });
@ -52,7 +52,7 @@ export const getTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Getting On Chain Transactions..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/onchaintransactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/onchaintransactions';
options.form = {
count: req.query.count,
skip: req.query.skip
@ -72,7 +72,7 @@ export const sendFunds = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'OnChain', msg: 'Sending On Chain Funds..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/sendonchain';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/sendonchain';
options.form = { address: address, amountSatoshis: amount, confirmationTarget: blocks };
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Onchain', msg: 'Send Funds Options', data: options.form });
request.post(options).then((body) => {

@ -7,7 +7,7 @@ const logger: LoggerService = Logger;
const common: CommonService = Common;
export const getSentInfoFromPaymentRequest = (selNode: SelectedNode, payment) => {
options.url = selNode.settings.lnServerUrl + '/getsentinfo';
options.url = selNode.Settings.lnServerUrl + '/getsentinfo';
options.form = { paymentHash: payment };
return request.post(options).then((body) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Sent Information Received', data: body });
@ -20,7 +20,7 @@ export const getSentInfoFromPaymentRequest = (selNode: SelectedNode, payment) =>
};
export const getQueryNodes = (selNode: SelectedNode, nodeIds) => {
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: nodeIds?.reduce((acc, curr) => acc + ',' + curr) };
return request.post(options).then((nodes) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Query Nodes Received', data: nodes });
@ -32,7 +32,7 @@ export const decodePayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/parseinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/parseinvoice';
options.form = { invoice: req.params.invoice };
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
@ -48,7 +48,7 @@ export const postPayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Paying Invoice..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/payinvoice';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/payinvoice';
options.form = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment Options', data: options.form });
request.post(options).then((body) => {
@ -64,7 +64,7 @@ export const queryPaymentRoute = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Querying Payment Route..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/findroutetonode';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/findroutetonode';
options.form = {
nodeId: req.query.nodeId,
amountMsat: req.query.amountMsat
@ -121,8 +121,8 @@ export const getSentPaymentsInformation = (req, res, next) => {
export const sendPaymentToRouteRequestCall = (selectedNode: SelectedNode, shortChannelIds: string, invoice: string, amountMsat: number) => {
logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..' });
options = selectedNode.authentication.options;
options.url = selectedNode.settings.lnServerUrl + '/sendtoroute';
options = selectedNode.Authentication.options;
options.url = selectedNode.Settings.lnServerUrl + '/sendtoroute';
options.form = { shortChannelIds: shortChannelIds, amountMsat: amountMsat, invoice: invoice };
return new Promise((resolve, reject) => {
logger.log({ selectedNode: selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment To Route Options', data: options.form });

@ -7,7 +7,7 @@ const logger: LoggerService = Logger;
const common: CommonService = Common;
export const getFilteredNodes = (selNode: SelectedNode, peersNodeIds) => {
options.url = selNode.settings.lnServerUrl + '/nodes';
options.url = selNode.Settings.lnServerUrl + '/nodes';
options.form = { nodeIds: peersNodeIds };
return request.post(options).then((nodes) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Peers', msg: 'Filtered Nodes Received', data: nodes });
@ -19,7 +19,7 @@ export const getPeers = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Getting Peers..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/peers';
options.form = {};
if (common.read_dummy_data) {
common.getDummyData('Peers', req.session.selectedNode.lnImplementation).then((data) => { res.status(200).json(data); });
@ -56,7 +56,7 @@ export const connectPeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Conneting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/connect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/connect';
options.form = {};
if (req.query) {
options.form = req.query;
@ -71,7 +71,7 @@ export const connectPeer = (req, res, next) => {
const err = common.handleError({ statusCode: 500, message: 'Connect Peer Error', error: body }, 'Peers', body, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.message, error: err.error });
}
options.url = req.session.selectedNode.settings.lnServerUrl + '/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/peers';
options.form = {};
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List after Connect', data: body });
@ -107,7 +107,7 @@ export const deletePeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Disconneting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/disconnect';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/disconnect';
options.form = {};
if (req.params.nodeId) {
options.form = { nodeId: req.params.nodeId };

@ -40,13 +40,13 @@ export class ECLWebSocketClient {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists) {
if (selectedNode.settings.lnServerUrl) {
if (selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode, reConnect: true, webSocketClient: null };
this.connectWithClient(newWebSocketClient);
this.webSocketClients.push(newWebSocketClient);
}
} else {
if ((!clientExists.webSocketClient || clientExists.webSocketClient.readyState !== WebSocket.OPEN) && selectedNode.settings.lnServerUrl) {
if ((!clientExists.webSocketClient || clientExists.webSocketClient.readyState !== WebSocket.OPEN) && selectedNode.Settings.lnServerUrl) {
clientExists.reConnect = true;
this.connectWithClient(clientExists);
}
@ -58,9 +58,9 @@ export class ECLWebSocketClient {
public connectWithClient = (eclWsClt) => {
this.logger.log({ selectedNode: eclWsClt.selectedNode, level: 'INFO', fileName: 'ECLWebSocket', msg: 'Connecting to the Eclair\'s Websocket Server..' });
const UpdatedLNServerURL = (eclWsClt.selectedNode.settings.lnServerUrl)?.replace(/^http/, 'ws');
const UpdatedLNServerURL = (eclWsClt.selectedNode.Settings.lnServerUrl)?.replace(/^http/, 'ws');
const firstSubStrIndex = (UpdatedLNServerURL.indexOf('//') + 2);
const WS_LINK = UpdatedLNServerURL.slice(0, firstSubStrIndex) + ':' + eclWsClt.selectedNode.authentication.lnApiPassword + '@' + UpdatedLNServerURL.slice(firstSubStrIndex) + '/ws';
const WS_LINK = UpdatedLNServerURL.slice(0, firstSubStrIndex) + ':' + eclWsClt.selectedNode.Authentication.lnApiPassword + '@' + UpdatedLNServerURL.slice(firstSubStrIndex) + '/ws';
eclWsClt.webSocketClient = new WebSocket(WS_LINK);
eclWsClt.webSocketClient.onopen = () => {
this.logger.log({ selectedNode: eclWsClt.selectedNode, level: 'INFO', fileName: 'ECLWebSocket', msg: 'Connected to the Eclair\'s Websocket Server..' });

@ -9,7 +9,7 @@ export const getBlockchainBalance = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Balance', msg: 'Getting Balance..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/balance/blockchain';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/balance/blockchain';
options.qs = req.query;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Balance', msg: 'Request params', data: req.params });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Balance', msg: 'Request Query', data: req.query });

@ -8,7 +8,7 @@ const common: CommonService = Common;
export const getAliasForChannel = (selNode: SelectedNode, channel) => {
const pubkey = (channel.remote_pubkey) ? channel.remote_pubkey : (channel.remote_node_pub) ? channel.remote_node_pub : '';
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + pubkey;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + pubkey;
return request(options).then((aliasBody) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Channels', msg: 'Alias Received', data: aliasBody.node.alias });
channel.remote_alias = aliasBody.node.alias && aliasBody.node.alias !== '' ? aliasBody.node.alias : aliasBody.node.pub_key.slice(0, 20);
@ -23,7 +23,7 @@ export const getAllChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Channels..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels';
options.qs = req.query;
let local = 0;
let remote = 0;
@ -61,7 +61,7 @@ export const getPendingChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Pending Channels..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/pending';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/pending';
options.qs = req.query;
request(options).then((body) => {
if (!body.total_limbo_balance) {
@ -98,7 +98,7 @@ export const getClosedChannels = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Getting Closed Channels..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/closed';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/closed';
options.qs = req.query;
request(options).then((body) => {
if (body.channels && body.channels.length > 0) {
@ -129,7 +129,7 @@ export const postChannel = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels';
options.form = {
node_pubkey_string: node_pubkey,
local_funding_amount: local_funding_amount,
@ -160,7 +160,7 @@ export const postTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Sending Payment..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/transaction-stream';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/transaction-stream';
options.form = { payment_request: paymentReq };
if (paymentAmount) {
options.form.amt = paymentAmount;
@ -196,7 +196,7 @@ export const closeChannel = (req, res, next) => {
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
const channelpoint = req.params.channelPoint?.replace(':', '/');
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/' + channelpoint + '?force=' + req.query.force;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/' + channelpoint + '?force=' + req.query.force;
if (req.query.target_conf) { options.url = options.url + '&target_conf=' + req.query.target_conf; }
if (req.query.sat_per_byte) { options.url = options.url + '&sat_per_byte=' + req.query.sat_per_byte; }
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Closing Channel Options URL', data: options.url });
@ -214,7 +214,7 @@ export const postChanPolicy = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Updating Channel Policy..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/chanpolicy';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/chanpolicy';
if (chanPoint === 'all') {
options.form = JSON.stringify({
global: true,

@ -39,14 +39,14 @@ export const getBackup = (req, res, next) => {
let channel_backup_file = '';
let message = '';
if (req.params.channelPoint === 'ALL') {
channel_backup_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-all.bak';
channel_backup_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-all.bak';
message = 'All Channels Backup Successful.';
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup';
} else {
channel_backup_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_backup_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
message = 'Channel Backup Successful.';
const channelpoint = req.params.channelPoint?.replace(':', '/');
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/' + channelpoint;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/' + channelpoint;
const exists = fs.existsSync(channel_backup_file);
if (exists) {
fs.writeFile(channel_backup_file, '', () => { });
@ -81,13 +81,13 @@ export const postBackupVerify = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'ChannelBackup', msg: 'Verifying Channel Backup..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/verify';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/verify';
let channel_verify_file = '';
let message = '';
let verify_backup = '';
if (req.params.channelPoint === 'ALL') {
message = 'All Channels Verify Successful.';
channel_verify_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-all.bak';
channel_verify_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-all.bak';
const exists = fs.existsSync(channel_verify_file);
if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');
@ -108,7 +108,7 @@ export const postBackupVerify = (req, res, next) => {
}
} else {
message = 'Channel Verify Successful.';
channel_verify_file = req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_verify_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
const exists = fs.existsSync(channel_verify_file);
if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');
@ -136,13 +136,13 @@ export const postRestore = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'ChannelBackup', msg: 'Restoring Channel Backup..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/channels/backup/restore';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/channels/backup/restore';
let channel_restore_file = '';
let message = '';
let restore_backup = '';
if (req.params.channelPoint === 'ALL') {
message = 'All Channels Restore Successful.';
channel_restore_file = req.session.selectedNode.settings.channelBackupPath + sep + 'restore' + sep;
channel_restore_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'restore' + sep;
const exists = fs.existsSync(channel_restore_file + 'channel-all.bak');
const downloaded_exists = fs.existsSync(channel_restore_file + 'backup-channel-all.bak');
if (exists) {
@ -173,7 +173,7 @@ export const postRestore = (req, res, next) => {
}
} else {
message = 'Channel Restore Successful.';
channel_restore_file = req.session.selectedNode.settings.channelBackupPath + sep + 'restore' + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
channel_restore_file = req.session.selectedNode.Settings.channelBackupPath + sep + 'restore' + sep + 'channel-' + req.params.channelPoint?.replace(':', '-') + '.bak';
const exists = fs.existsSync(channel_restore_file);
if (exists) {
restore_backup = fs.readFileSync(channel_restore_file, 'utf-8');
@ -190,7 +190,7 @@ export const postRestore = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'ChannelBackup', msg: 'Channel Restored', data: body });
if (req.params.channelPoint === 'ALL') { channel_restore_file = channel_restore_file + 'channel-all.bak'; }
fs.rename(channel_restore_file, channel_restore_file + '.restored', () => {
getFilesList(req.session.selectedNode.settings.channelBackupPath, (getFilesListRes) => {
getFilesList(req.session.selectedNode.Settings.channelBackupPath, (getFilesListRes) => {
if (getFilesListRes.error) {
const errMsg = getFilesListRes.error;
const err = common.handleError({ statusCode: 500, message: 'Restore Channel Error', error: errMsg }, 'ChannelBackup', errMsg, req.session.selectedNode);
@ -210,7 +210,7 @@ export const postRestore = (req, res, next) => {
};
export const getRestoreList = (req, res, next) => {
getFilesList(req.session.selectedNode.settings.channelBackupPath, (getFilesListRes) => {
getFilesList(req.session.selectedNode.Settings.channelBackupPath, (getFilesListRes) => {
if (getFilesListRes.error) {
return res.status(getFilesListRes.statusCode).json(getFilesListRes);
} else {

@ -10,7 +10,7 @@ export const getFees = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Fees', msg: 'Getting Fees..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/fees';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/fees';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Fees', msg: 'Fee Received', data: body });
const today = new Date(Date.now());

@ -16,7 +16,7 @@ export const getInfo = (req, res, next) => {
common.setOptions(req);
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/getinfo';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/getinfo';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Selected Node ' + req.session.selectedNode.lnNode });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Calling Info from LND server url ' + options.url });
if (!options.headers || !options.headers['Grpc-Metadata-macaroon']) {

@ -7,7 +7,7 @@ const logger: LoggerService = Logger;
const common: CommonService = Common;
export const getAliasFromPubkey = (selNode: SelectedNode, pubkey) => {
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + pubkey;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + pubkey;
return request(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Graph', msg: 'Alias Received', data: res.node.alias });
return res.node.alias;
@ -19,7 +19,7 @@ export const getDescribeGraph = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Network Graph..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph';
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Network Graph Received', data: body });
res.status(200).json(body);
@ -33,7 +33,7 @@ export const getGraphInfo = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Information..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/info';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/info';
request.get(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Information Received', data: body });
res.status(200).json(body);
@ -47,7 +47,7 @@ export const getGraphNode = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Node Information..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/node/' + req.params.pubKey;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/node/' + req.params.pubKey;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Node Information Received', data: body });
res.status(200).json(body);
@ -61,7 +61,7 @@ export const getGraphEdge = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Edge Information..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Graph Edge Information Received', data: body });
res.status(200).json(body);
@ -75,7 +75,7 @@ export const getQueryRoutes = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Routes..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/routes/' + req.params.destPubkey + '/' + req.params.amount;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/routes/' + req.params.destPubkey + '/' + req.params.amount;
if (req.query.outgoing_chan_id) {
options.url = options.url + '?outgoing_chan_id=' + req.query.outgoing_chan_id;
}
@ -111,7 +111,7 @@ export const getRemoteFeePolicy = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Graph', msg: 'Getting Remote Fee Policy..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Graph', msg: 'Edge Info Received', data: body });
let remoteNodeFee = {};

@ -12,7 +12,7 @@ export const invoiceLookup = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Getting Invoice Information..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/invoices/lookup';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/invoices/lookup';
if (req.query.payment_addr) {
options.url = options.url + '?payment_addr=' + req.query.payment_addr;
} else {
@ -34,7 +34,7 @@ export const listInvoices = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Getting List Invoices..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices?num_max_invoices=' + req.query.num_max_invoices + '&index_offset=' + req.query.index_offset +
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices?num_max_invoices=' + req.query.num_max_invoices + '&index_offset=' + req.query.index_offset +
'&reversed=' + req.query.reversed;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
@ -57,7 +57,7 @@ export const addInvoice = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Adding Invoice..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices';
options.form = JSON.stringify(req.body);
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Invoice', msg: 'Invoice Added', data: body });

@ -10,7 +10,7 @@ export const signMessage = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Signing Message..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/signmessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/signmessage';
options.form = JSON.stringify({
msg: Buffer.from(message).toString('base64')
});
@ -28,7 +28,7 @@ export const verifyMessage = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Message', msg: 'Verifying Message..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/verifymessage';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/verifymessage';
options.form = JSON.stringify({
msg: Buffer.from(message).toString('base64'),
signature: signature

@ -9,7 +9,7 @@ export const getNewAddress = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'NewAddress', msg: 'Getting New Address..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/newaddress?type=' + req.query.type;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/newaddress?type=' + req.query.type;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'NewAddress', msg: 'New Address Generated', data: body });
res.status(200).json(body);

@ -8,7 +8,7 @@ const logger: LoggerService = Logger;
const common: CommonService = Common;
export const decodePaymentFromPaymentRequest = (selNode: SelectedNode, payment) => {
options.url = selNode.settings.lnServerUrl + '/v1/payreq/' + payment;
options.url = selNode.Settings.lnServerUrl + '/v1/payreq/' + payment;
return request(options).then((res) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'PayReq', msg: 'Description Received', data: res.description });
return res;
@ -19,7 +19,7 @@ export const decodePayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'PayRequest', msg: 'Decoding Payment..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payreq/' + req.params.payRequest;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payreq/' + req.params.payRequest;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'PayRequest', msg: 'Payment Decoded', data: body });
res.status(200).json(body);
@ -55,7 +55,7 @@ export const getPayments = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Getting Payments List..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payments?max_payments=' + req.query.max_payments + '&index_offset=' + req.query.index_offset + '&reversed=' + req.query.reversed;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payments?max_payments=' + req.query.max_payments + '&index_offset=' + req.query.index_offset + '&reversed=' + req.query.reversed;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body });
res.status(200).json(body);
@ -69,8 +69,8 @@ export const getAllLightningTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Getting All Lightning Transactions..' });
const options1 = JSON.parse(JSON.stringify(common.getOptions(req)));
const options2 = JSON.parse(JSON.stringify(common.getOptions(req)));
// options1.url = req.session.selectedNode.settings.lnServerUrl + '/v1/payments?max_payments=100000&index_offset=0&reversed=true';
options2.url = req.session.selectedNode.settings.lnServerUrl + '/v1/invoices?num_max_invoices=100000&index_offset=0&reversed=true';
// options1.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/payments?max_payments=100000&index_offset=0&reversed=true';
options2.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/invoices?num_max_invoices=100000&index_offset=0&reversed=true';
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'All Payments Options', data: options1 });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Payments', msg: 'All Invoices Options', data: options2 });
// return Promise.all([request(options1), request(options2)]).then((values) => {
@ -87,7 +87,7 @@ export const paymentLookup = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Looking up Payment..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/router/track/' + req.params.paymentHash;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/router/track/' + req.params.paymentHash;
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Information Received for ' + req.params.paymentHash, data: body });
res.status(200).json(body.result || body);

@ -7,7 +7,7 @@ const logger: LoggerService = Logger;
const common: CommonService = Common;
export const getAliasForPeers = (selNode: SelectedNode, peer) => {
options.url = selNode.settings.lnServerUrl + '/v1/graph/node/' + peer.pub_key;
options.url = selNode.Settings.lnServerUrl + '/v1/graph/node/' + peer.pub_key;
return request(options).then((aliasBody) => {
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Peers', msg: 'Alias Received', data: aliasBody.node.alias });
peer.alias = aliasBody.node.alias;
@ -22,7 +22,7 @@ export const getPeers = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Getting Peers..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers;
@ -41,14 +41,14 @@ export const postPeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Connecting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
options.form = JSON.stringify({
addr: { host: host, pubkey: pubkey },
perm: perm
});
request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peer Connected', data: body });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers';
request(options).then((body) => {
const peers = (!body.peers) ? [] : body.peers;
return Promise.all(peers?.map((peer) => getAliasForPeers(req.session.selectedNode, peer))).then((values) => {
@ -75,7 +75,7 @@ export const deletePeer = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Disconnecting Peer..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/peers/' + req.params.peerPubKey;
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/peers/' + req.params.peerPubKey;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnect Pubkey', data: req.params.peerPubKey });
request.delete(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peer Disconneted', data: body });

@ -25,7 +25,7 @@ export const getAllForwardingEvents = (req, start, end, offset, caller, callback
const err = common.handleError({ message: 'Session Expired after a day\'s inactivity.', statusCode: 401 }, 'Balance', 'Get Balance Error', req.session.selectedNode);
return callback({ message: err.message, error: err.error, statusCode: err.statusCode });
} options = common.getOptions(req);
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/switch';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/switch';
options.form = {};
if (start) { options.form.start_time = start; }
if (end) { options.form.end_time = end; }

@ -9,7 +9,7 @@ export const getTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Transactions', msg: 'Getting Transactions..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/transactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/transactions';
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Transactions', msg: 'Transactions List Received', data: body });
res.status(200).json(body.transactions);
@ -24,7 +24,7 @@ export const postTransactions = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Transactions', msg: 'Sending Transaction..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/transactions';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/transactions';
options.form = {
amount: amount,
addr: address,

@ -11,9 +11,9 @@ export const genSeed = (req, res, next) => {
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
if (req.params.passphrase) {
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/genseed?aezeed_passphrase=' + Buffer.from(atob(req.params.passphrase)).toString('base64');
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/genseed?aezeed_passphrase=' + Buffer.from(atob(req.params.passphrase)).toString('base64');
} else {
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/genseed';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/genseed';
}
request(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Seed Generated', data: body });
@ -32,14 +32,14 @@ export const operateWallet = (req, res, next) => {
options.method = 'POST';
if (!req.params.operation || req.params.operation === 'unlockwallet') {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Unlocking Wallet..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/unlockwallet';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/unlockwallet';
options.form = JSON.stringify({
wallet_password: Buffer.from(atob(wallet_password)).toString('base64')
});
err_message = 'Unlocking wallet failed! Verify that lnd is running and the wallet is locked!';
} else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Initializing Wallet..' });
options.url = req.session.selectedNode.settings.lnServerUrl + '/v1/initwallet';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v1/initwallet';
if (aezeed_passphrase && aezeed_passphrase !== '') {
options.form = JSON.stringify({
wallet_password: Buffer.from(atob(wallet_password)).toString('base64'),
@ -94,7 +94,7 @@ export const getUTXOs = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Getting UTXOs..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos';
if (common.isVersionCompatible(req.session.selectedNode.lnVersion, '0.14.0')) {
options.form = JSON.stringify({ max_confs: req.query.max_confs });
} else {
@ -114,7 +114,7 @@ export const bumpFee = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Bumping Fee..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/bumpfee';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/bumpfee';
options.form = {};
options.form.outpoint = {
txid_str: txid,
@ -139,7 +139,7 @@ export const labelTransaction = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Labelling Transaction..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/tx/label';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/tx/label';
options.form = JSON.parse(JSON.stringify(options.form));
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Wallet', msg: 'Label Transaction Options', data: options.form });
request.post(options).then((body) => {
@ -156,7 +156,7 @@ export const leaseUTXO = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Leasing UTXO..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos/lease';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos/lease';
options.form = {};
options.form.id = txid;
options.form.outpoint = {
@ -179,7 +179,7 @@ export const releaseUTXO = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Wallet', msg: 'Releasing UTXO..' });
options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.settings.lnServerUrl + '/v2/wallet/utxos/release';
options.url = req.session.selectedNode.Settings.lnServerUrl + '/v2/wallet/utxos/release';
options.form = {};
options.form.id = txid;
options.form.outpoint = {

@ -26,7 +26,7 @@ export class LNDWebSocketClient {
public connect = (selectedNode: SelectedNode) => {
try {
const clientExists = this.webSocketClients.find((wsc) => wsc.selectedNode.index === selectedNode.index);
if (!clientExists && selectedNode.settings.lnServerUrl) {
if (!clientExists && selectedNode.Settings.lnServerUrl) {
const newWebSocketClient = { selectedNode: selectedNode };
this.webSocketClients.push(newWebSocketClient);
}
@ -38,7 +38,7 @@ export class LNDWebSocketClient {
public fetchUnpaidInvoices = (selectedNode: SelectedNode) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Getting Unpaid Invoices..' });
const options = this.setOptionsForSelNode(selectedNode);
options.url = selectedNode.settings.lnServerUrl + '/v1/invoices?pending_only=true';
options.url = selectedNode.Settings.lnServerUrl + '/v1/invoices?pending_only=true';
return request(options).then((body) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Unpaid Invoices Received', data: body });
if (body.invoices && body.invoices.length > 0) {
@ -58,7 +58,7 @@ export class LNDWebSocketClient {
public subscribeToInvoice = (options: any, selectedNode: SelectedNode, rHash: string) => {
rHash = rHash?.replace(/\+/g, '-')?.replace(/[/]/g, '_');
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Subscribing to Invoice ' + rHash + ' ..' });
options.url = selectedNode.settings.lnServerUrl + '/v2/invoices/subscribe/' + rHash;
options.url = selectedNode.Settings.lnServerUrl + '/v2/invoices/subscribe/' + rHash;
request(options).then((msg) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Invoice Information Received for ' + rHash });
if (typeof msg === 'string') {
@ -82,7 +82,7 @@ export class LNDWebSocketClient {
public subscribeToPayment = (options: any, selectedNode: SelectedNode, paymentHash: string) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Subscribing to Payment ' + paymentHash + ' ..' });
options.url = selectedNode.settings.lnServerUrl + '/v2/router/track/' + paymentHash;
options.url = selectedNode.Settings.lnServerUrl + '/v2/router/track/' + paymentHash;
request(options).then((msg) => {
this.logger.log({ selectedNode: selectedNode, level: 'INFO', fileName: 'WebSocketClient', msg: 'Payment Information Received for ' + paymentHash });
msg['type'] = 'payment';
@ -100,7 +100,7 @@ export class LNDWebSocketClient {
public setOptionsForSelNode = (selectedNode: SelectedNode) => {
const options = { url: '', rejectUnauthorized: false, json: true, form: null };
try {
options['headers'] = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(selectedNode.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
options['headers'] = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(selectedNode.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
} catch (err) {
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: 'WebSocketClient', msg: 'Set Options Error', error: JSON.stringify(err) });
}

@ -8,7 +8,7 @@ import { Database, DatabaseService } from '../../utils/database.js';
import { Logger, LoggerService } from '../../utils/logger.js';
import { Common, CommonService } from '../../utils/common.js';
import { WSServer } from '../../utils/webSocketServer.js';
import { NodeAuthentication, SSO } from '../../models/config.model.js';
import { ApplicationConfig, Authentication, SSO } from '../../models/config.model.js';
const options = { url: '' };
const logger: LoggerService = Logger;
@ -25,7 +25,7 @@ export const maskPasswords = (obj) => {
keys[keys[i]] = maskPasswords(obj[keys[i]]);
}
if (typeof keys[i] === 'string' &&
(keys[i].toLowerCase().includes('password') || keys[i].toLowerCase().includes('multipass') ||
((keys[i].toLowerCase().includes('password') && keys[i] !== 'allowPasswordUpdate') || keys[i].toLowerCase().includes('multipass') ||
keys[i].toLowerCase().includes('rpcpass') || keys[i].toLowerCase().includes('rpcpassword') ||
keys[i].toLowerCase().includes('rpcuser'))
) {
@ -36,6 +36,41 @@ export const maskPasswords = (obj) => {
return obj;
};
export const removeSecureData = (config: ApplicationConfig) => {
delete config.rtlConfFilePath;
delete config.rtlPass;
delete config.multiPass;
delete config.multiPassHashed;
delete config.secret2FA;
config.nodes.map((node) => {
delete node.Authentication.macaroonPath;
delete node.Authentication.runePath;
delete node.Authentication.lnApiPassword;
return node;
});
return config;
};
export const addSecureData = (config: ApplicationConfig) => {
config.SSO.rtlCookiePath = common.appConfig.SSO.rtlCookiePath;
config.multiPass = common.appConfig.multiPass;
config.multiPassHashed = common.appConfig.multiPassHashed;
config.secret2FA = common.appConfig.secret2FA;
config.nodes.map((node, i) => {
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.macaroonPath) {
node.Authentication.macaroonPath = common.appConfig.nodes[i].Authentication.macaroonPath;
}
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.runePath) {
node.Authentication.runePath = common.appConfig.nodes[i].Authentication.runePath;
}
if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.lnApiPassword) {
node.Authentication.lnApiPassword = common.appConfig.nodes[i].Authentication.lnApiPassword;
}
return node;
});
return config;
};
export const getCurrencyRates = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting Currency Rates..' });
options.url = 'https://blockchain.info/ticker';
@ -51,7 +86,7 @@ export const getCurrencyRates = (req, res, next) => {
export const getFile = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting File..' });
const file = req.query.path ? req.query.path : (req.session.selectedNode.settings.channelBackupPath + sep + 'channel-' + req.query.channel?.replace(':', '-') + '.bak');
const file = req.query.path ? req.query.path : (req.session.selectedNode.Settings.channelBackupPath + sep + 'channel-' + req.query.channel?.replace(':', '-') + '.bak');
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'RTLConf', msg: 'Channel Point', data: req.query.channel });
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'RTLConf', msg: 'File Path', data: file });
fs.readFile(file, 'utf8', (errRes, data) => {
@ -67,7 +102,7 @@ export const getFile = (req, res, next) => {
});
};
export const getRTLConfig = (req, res, next) => {
export const getApplicationSettings = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..' });
const confFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
fs.readFile(confFile, 'utf8', (errRes, data) => {
@ -76,39 +111,26 @@ export const getRTLConfig = (req, res, next) => {
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
} else {
const appConfData = JSON.parse(data);
delete appConfData.rtlConfFilePath;
delete appConfData.rtlPass;
delete appConfData.multiPass;
delete appConfData.multiPassHashed;
delete appConfData.rtlSecret2fa;
const appConfData = removeSecureData(JSON.parse(data));
appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate;
appConfData.enable2FA = common.appConfig.enable2FA;
appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index);
appConfData.nodes.map((node) => {
node.authentication = node.Authentication;
node.settings = node.Settings;
delete node.Authentication;
delete node.Settings;
delete node.authentication.macaroonPath;
delete node.authentication.runePath;
delete node.authentication.lnApiPassword;
return node;
});
const token = req.headers.authorization ? req.headers.authorization.split(' ')[1] : '';
jwt.verify(token, common.secret_key, (err, user) => {
if (err) {
// Delete sensitive data for initial response (without security token)
// Delete unnecessary data for initial response (without security token)
const selNodeIdx = appConfData.nodes.findIndex((node) => node.index === appConfData.selectedNodeIndex) || 0;
appConfData.SSO = new SSO();
appConfData.secret2fa = '';
appConfData.secret2FA = '';
appConfData.dbDirectoryPath = '';
appConfData.nodes[selNodeIdx].authentication = new NodeAuthentication();
delete appConfData.nodes[selNodeIdx].settings.bitcoindConfigPath;
delete appConfData.nodes[selNodeIdx].settings.lnServerUrl;
delete appConfData.nodes[selNodeIdx].settings.swapServerUrl;
delete appConfData.nodes[selNodeIdx].settings.boltzServerUrl;
delete appConfData.nodes[selNodeIdx].settings.enableOffers;
delete appConfData.nodes[selNodeIdx].settings.enablePeerswap;
delete appConfData.nodes[selNodeIdx].settings.channelBackupPath;
appConfData.nodes[selNodeIdx].Authentication = new Authentication();
delete appConfData.nodes[selNodeIdx].Settings.bitcoindConfigPath;
delete appConfData.nodes[selNodeIdx].Settings.lnServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.swapServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.boltzServerUrl;
delete appConfData.nodes[selNodeIdx].Settings.enableOffers;
delete appConfData.nodes[selNodeIdx].Settings.enablePeerswap;
delete appConfData.nodes[selNodeIdx].Settings.channelBackupPath;
appConfData.nodes = [appConfData.nodes[selNodeIdx]];
}
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received', data: appConfData });
@ -142,10 +164,10 @@ export const getConfig = (req, res, next) => {
let fileFormat = 'INI';
switch (req.params.nodeType) {
case 'ln':
confFile = req.session.selectedNode.authentication.configPath;
confFile = req.session.selectedNode.Authentication.configPath;
break;
case 'bitcoind':
confFile = req.session.selectedNode.settings.bitcoindConfigPath;
confFile = req.session.selectedNode.Settings.bitcoindConfigPath;
break;
case 'rtl':
fileFormat = 'JSON';
@ -187,38 +209,21 @@ export const getConfig = (req, res, next) => {
};
export const updateNodeSettings = (req, res, next) => {
const { updatedSettings } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating UI Settings..' });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Node Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
if (node && node.Settings) {
node.Settings.userPersona = updatedSettings.userPersona;
node.Settings.themeMode = updatedSettings.themeMode;
node.Settings.themeColor = updatedSettings.themeColor;
node.Settings.unannouncedChannels = updatedSettings.unannouncedChannels;
node.Settings.fiatConversion = updatedSettings.fiatConversion;
if (updatedSettings.fiatConversion) {
node.Settings.currencyUnit = updatedSettings.currencyUnit ? updatedSettings.currencyUnit : 'USD';
} else {
delete node.Settings.currencyUnit;
}
const selectedNode = common.findNode(req.session.selectedNode.index);
selectedNode.settings.userPersona = updatedSettings.userPersona;
selectedNode.settings.themeMode = updatedSettings.themeMode;
selectedNode.settings.themeColor = updatedSettings.themeColor;
selectedNode.settings.unannouncedChannels = updatedSettings.unannouncedChannels;
selectedNode.settings.fiatConversion = updatedSettings.fiatConversion;
if (updatedSettings.fiatConversion) {
selectedNode.settings.currencyUnit = updatedSettings.currencyUnit ? updatedSettings.currencyUnit : 'USD';
} else {
delete selectedNode.settings.currencyUnit;
}
common.replaceNode(req, selectedNode);
node.Settings = req.body;
}
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'UI Settings Updated', data: maskPasswords(config) });
const selectedNode = common.findNode(req.session.selectedNode.index);
if (selectedNode && selectedNode.Settings) {
selectedNode.Settings = req.body;
common.replaceNode(req, selectedNode);
}
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Node Settings Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Node Settings Updated Successfully' });
} catch (errRes) {
const errMsg = 'Update Node Settings Error';
@ -228,125 +233,19 @@ export const updateNodeSettings = (req, res, next) => {
};
export const updateApplicationSettings = (req, res, next) => {
const { defaultNodeIndex } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Default Node..' });
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Application Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
config.defaultNodeIndex = defaultNodeIndex;
try {
const config = addSecureData(req.body);
delete config.selectedNodeIndex;
delete config.enable2FA;
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Default Node Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Default Node Updated Successfully' });
common.appConfig = config;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Application Settings Updated', data: maskPasswords(common.appConfig) });
res.status(201).json(removeSecureData(config));
} catch (errRes) {
const errMsg = 'Update Default Node Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const update2FASettings = (req, res, next) => {
const { secret2fa } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating 2FA Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
if (secret2fa && secret2fa.trim() !== '') {
config.secret2fa = secret2fa;
} else {
delete config.secret2fa;
}
const message = secret2fa.trim() === '' ? 'Two factor authentication disabled successfully.' : 'Two factor authentication enabled successfully.';
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
common.appConfig.rtlSecret2fa = config.secret2fa;
common.appConfig.enable2FA = !!config.secret2fa;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: message });
res.status(201).json({ message: message });
} catch (errRes) {
const errMsg = 'Update 2FA Settings Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const updateSSO = (req, res, next) => {
const { SSO } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating SSO Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
delete config.SSO;
config.SSO = SSO;
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'SSO Setting Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'SSO Updated Successfully' });
} catch (errRes) {
const errMsg = 'Update SSO Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};
export const updateServiceSettings = (req, res, next) => {
const { service, settings } = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Service Settings..' });
const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json';
const config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const selectedNode = common.findNode(req.session.selectedNode.index);
config.nodes.forEach((node) => {
if (node.index === req.session.selectedNode.index) {
switch (service) {
case 'LOOP':
if (settings.enable) {
node.Settings.swapServerUrl = settings.serverUrl;
node.Authentication.swapMacaroonPath = settings.macaroonPath;
selectedNode.settings.swapServerUrl = settings.serverUrl;
selectedNode.authentication.swapMacaroonPath = settings.macaroonPath;
} else {
delete node.Settings.swapServerUrl;
delete node.Authentication.swapMacaroonPath;
delete selectedNode.settings.swapServerUrl;
delete selectedNode.authentication.swapMacaroonPath;
}
break;
case 'BOLTZ':
if (settings.enable) {
node.Settings.boltzServerUrl = settings.serverUrl;
node.Authentication.boltzMacaroonPath = settings.macaroonPath;
selectedNode.settings.boltzServerUrl = settings.serverUrl;
selectedNode.authentication.boltzMacaroonPath = settings.macaroonPath;
} else {
delete node.Settings.boltzServerUrl;
delete node.Authentication.boltzMacaroonPath;
delete selectedNode.settings.boltzServerUrl;
delete selectedNode.authentication.boltzMacaroonPath;
}
break;
case 'OFFERS':
node.Settings.enableOffers = settings.enableOffers;
selectedNode.settings.enableOffers = settings.enableOffers;
break;
case 'PEERSWAP':
node.Settings.enablePeerswap = settings.enablePeerswap;
selectedNode.settings.enablePeerswap = settings.enablePeerswap;
break;
default:
break;
}
common.replaceNode(req, selectedNode);
}
return node;
});
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Service Settings Updated', data: maskPasswords(config) });
res.status(201).json({ message: 'Service Settings Updated Successfully' });
} catch (errRes) {
const errMsg = 'Update Service Settings Error';
const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.error, error: err.error });
}
};

@ -47,7 +47,7 @@ const handleMultipleFailedAttemptsError = (failed, currentTime, errMsg) => {
}
};
export const verifyToken = (twoFAToken) => !!(common.appConfig.rtlSecret2fa && common.appConfig.rtlSecret2fa !== '' && otplib.authenticator.check(twoFAToken, common.appConfig.rtlSecret2fa));
export const verifyToken = (twoFAToken) => !!(common.appConfig.secret2FA && common.appConfig.secret2FA !== '' && otplib.authenticator.check(twoFAToken, common.appConfig.secret2FA));
export const authenticateUser = (req, res, next) => {
const { authenticateWith, authenticationValue, twoFAToken } = req.body;

@ -1,4 +1,15 @@
export class NodeSettings {
export class SSO {
constructor(
public rtlSso?: number,
public rtlCookiePath?: string,
public logoutRedirectLink?: string,
public cookieValue?: string
) { }
}
export class Settings {
constructor(
public lnServerUrl?: string,
@ -20,7 +31,7 @@ export class NodeSettings {
}
export class NodeAuthentication {
export class Authentication {
constructor(
public options?: any,
@ -36,33 +47,6 @@ export class NodeAuthentication {
}
export class SelectedNode {
constructor(
public logLevel?: string,
public logFile?: string,
public index?: string,
public lnNode?: string,
public lnImplementation?: string,
public lnVersion?: string,
public apiVersion?: string,
public settings?: NodeSettings,
public authentication?: NodeAuthentication
) { }
}
export class SSO {
constructor(
public rtlSso?: number,
public rtlCookiePath?: string,
public logoutRedirectLink?: string,
public cookieValue?: string
) { }
}
export class ApplicationConfig {
constructor(
@ -75,13 +59,28 @@ export class ApplicationConfig {
public multiPassHashed?: string,
public allowPasswordUpdate?: boolean,
public enable2FA?: boolean,
public rtlSecret2fa?: string,
public secret2FA?: string,
public SSO?: SSO,
public nodes?: SelectedNode[]
) {}
}
export class SelectedNode {
constructor(
public logLevel?: string,
public logFile?: string,
public index?: number,
public lnNode?: string,
public lnImplementation?: string,
public lnVersion?: string,
public Settings?: Settings,
public Authentication?: Authentication
) { }
}
export class LogJSONObj {
constructor(

@ -1,12 +1,12 @@
import exprs from 'express';
const { Router } = exprs;
import { isAuthenticated } from '../../utils/authCheck.js';
import { getRTLConfig, updateNodeSettings, getConfig, getFile, updateSelectedNode, updateApplicationSettings, getCurrencyRates } from '../../controllers/shared/RTLConf.js';
import { updateNodeSettings, getConfig, getFile, updateSelectedNode, updateApplicationSettings, getCurrencyRates, getApplicationSettings } from '../../controllers/shared/RTLConf.js';
const router = Router();
router.get('/', getApplicationSettings);
router.get('/rates', getCurrencyRates);
router.get('/rtlconf', getRTLConfig);
router.get('/file', isAuthenticated, getFile);
router.get('/updateSelNode/:currNodeIndex/:prevNodeIndex', updateSelectedNode);
router.get('/config/:nodeType', isAuthenticated, getConfig);

@ -12,7 +12,7 @@ export class CommonService {
public nodes: SelectedNode[] = [];
public selectedNode: SelectedNode = null;
public ssoInit = { rtlSso: 0, rtlCookiePath: '', logoutRedirectLink: '', cookieValue: '' };
public appConfig: ApplicationConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, rtlSecret2fa: '', SSO: this.ssoInit, nodes: [] };
public appConfig: ApplicationConfig = { defaultNodeIndex: 0, selectedNodeIndex: 0, rtlConfFilePath: '', dbDirectoryPath: join(dirname(fileURLToPath(import.meta.url)), '..', '..'), rtlPass: '', allowPasswordUpdate: true, enable2FA: false, secret2FA: '', SSO: this.ssoInit, nodes: [] };
public port = 3000;
public host = '';
public secret_key = crypto.randomBytes(64).toString('hex');
@ -28,15 +28,15 @@ export class CommonService {
public setSwapServerOptions = (req) => {
const swapOptions = {
baseUrl: req.session.selectedNode.settings.swapServerUrl,
baseUrl: req.session.selectedNode.Settings.swapServerUrl,
uri: '',
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': '' }
};
if (req.session.selectedNode.authentication.swapMacaroonPath) {
if (req.session.selectedNode.Authentication.swapMacaroonPath) {
try {
swapOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.swapMacaroonPath, 'loop.macaroon')).toString('hex') };
swapOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.swapMacaroonPath, 'loop.macaroon')).toString('hex') };
} catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Loop macaroon Error', error: err });
}
@ -47,14 +47,14 @@ export class CommonService {
public getBoltzServerOptions = (req) => {
const boltzOptions = {
url: req.session.selectedNode.settings.boltzServerUrl,
url: req.session.selectedNode.Settings.boltzServerUrl,
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': '' }
};
if (req.session.selectedNode.authentication.boltzMacaroonPath) {
if (req.session.selectedNode.Authentication.boltzMacaroonPath) {
try {
boltzOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.boltzMacaroonPath, 'admin.macaroon')).toString('hex') };
boltzOptions.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.boltzMacaroonPath, 'admin.macaroon')).toString('hex') };
} catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Boltz macaroon Error', error: err });
}
@ -64,12 +64,12 @@ export class CommonService {
};
public getOptions = (req) => {
if (req.session.selectedNode && req.session.selectedNode.authentication.options) {
req.session.selectedNode.authentication.options.method = (req.session.selectedNode.lnImplementation && req.session.selectedNode.lnImplementation.toUpperCase() === 'LND') ? 'GET' : 'POST';
delete req.session.selectedNode.authentication.options.form;
delete req.session.selectedNode.authentication.options.body;
req.session.selectedNode.authentication.options.qs = {};
return req.session.selectedNode.authentication.options;
if (req.session.selectedNode && req.session.selectedNode.Authentication.options) {
req.session.selectedNode.Authentication.options.method = (req.session.selectedNode.lnImplementation && req.session.selectedNode.lnImplementation.toUpperCase() === 'LND') ? 'GET' : 'POST';
delete req.session.selectedNode.Authentication.options.form;
delete req.session.selectedNode.Authentication.options.body;
req.session.selectedNode.Authentication.options.qs = {};
return req.session.selectedNode.Authentication.options;
}
return this.handleError({ statusCode: 401, message: 'Session expired after a day\'s inactivity' }, 'Session Expired', 'Session Expiry Error', this.selectedNode);
};
@ -78,7 +78,7 @@ export class CommonService {
if (!req.session.selectedNode) {
req.session.selectedNode = {};
}
req.session.selectedNode.authentication.options = {
req.session.selectedNode.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -89,30 +89,30 @@ export class CommonService {
switch (req.session.selectedNode.lnImplementation.toUpperCase()) {
case 'CLN':
try {
if (!req.session.selectedNode.authentication.runeValue) {
req.session.selectedNode.authentication.runeValue = this.getRuneValue(req.session.selectedNode.authentication.runePath);
if (!req.session.selectedNode.Authentication.runeValue) {
req.session.selectedNode.Authentication.runeValue = this.getRuneValue(req.session.selectedNode.Authentication.runePath);
}
req.session.selectedNode.authentication.options.headers = { rune: req.session.selectedNode.authentication.runeValue };
req.session.selectedNode.Authentication.options.headers = { rune: req.session.selectedNode.Authentication.runeValue };
} catch (err) {
throw new Error(err);
}
break;
case 'ECL':
req.session.selectedNode.authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + req.session.selectedNode.authentication.lnApiPassword).toString('base64') };
req.session.selectedNode.Authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + req.session.selectedNode.Authentication.lnApiPassword).toString('base64') };
break;
default:
req.session.selectedNode.authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
req.session.selectedNode.Authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(req.session.selectedNode.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
break;
}
}
if (req.session.selectedNode) {
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Updated Node Options for ' + req.session.selectedNode.lnNode, data: req.session.selectedNode.authentication.options });
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Updated Node Options for ' + req.session.selectedNode.lnNode, data: req.session.selectedNode.Authentication.options });
}
return { status: 200, message: 'Updated Successfully' };
} catch (err) {
req.session.selectedNode.authentication.options = {
req.session.selectedNode.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -135,10 +135,10 @@ export class CommonService {
};
public setOptions = (req) => {
if (this.nodes[0].authentication.options && this.nodes[0].authentication.options.headers) { return; }
if (this.nodes[0].Authentication.options && this.nodes[0].Authentication.options.headers) { return; }
if (this.nodes && this.nodes.length > 0) {
this.nodes.forEach((node) => {
node.authentication.options = {
node.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
@ -149,34 +149,34 @@ export class CommonService {
switch (node.lnImplementation.toUpperCase()) {
case 'CLN':
try {
if (!node.authentication.runeValue) {
node.authentication.runeValue = this.getRuneValue(node.authentication.runePath);
if (!node.Authentication.runeValue) {
node.Authentication.runeValue = this.getRuneValue(node.Authentication.runePath);
}
node.authentication.options.headers = { rune: node.authentication.runeValue };
node.Authentication.options.headers = { rune: node.Authentication.runeValue };
} catch (err) {
throw new Error(err);
}
break;
case 'ECL':
node.authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + node.authentication.lnApiPassword).toString('base64') };
node.Authentication.options.headers = { authorization: 'Basic ' + Buffer.from(':' + node.Authentication.lnApiPassword).toString('base64') };
break;
default:
node.authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(node.authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
node.Authentication.options.headers = { 'Grpc-Metadata-macaroon': fs.readFileSync(join(node.Authentication.macaroonPath, 'admin.macaroon')).toString('hex') };
break;
}
}
} catch (err) {
this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Common Set Options Error', error: err });
node.authentication.options = {
node.Authentication.options = {
url: '',
rejectUnauthorized: false,
json: true,
form: ''
};
}
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Set Node Options for ' + node.lnNode, data: node.authentication.options });
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Set Node Options for ' + node.lnNode, data: node.Authentication.options });
});
this.updateSelectedNodeOptions(req);
}
@ -420,12 +420,12 @@ export class CommonService {
};
public getAllNodeAllChannelBackup = (node: SelectedNode) => {
const channel_backup_file = node.settings.channelBackupPath + sep + 'channel-all.bak';
const channel_backup_file = node.Settings.channelBackupPath + sep + 'channel-all.bak';
const options = {
url: node.settings.lnServerUrl + '/v1/channels/backup',
url: node.Settings.lnServerUrl + '/v1/channels/backup',
rejectUnauthorized: false,
json: true,
headers: { 'Grpc-Metadata-macaroon': fs.readFileSync(node.authentication.macaroonPath + '/admin.macaroon').toString('hex') }
headers: { 'Grpc-Metadata-macaroon': fs.readFileSync(node.Authentication.macaroonPath + '/admin.macaroon').toString('hex') }
};
this.logger.log({ selectedNode: this.selectedNode, level: 'INFO', fileName: 'Common', msg: 'Getting Channel Backup for Node ' + node.lnNode + '..' });
request(options).then((body) => {
@ -486,9 +486,9 @@ export class CommonService {
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'INDEX: ' + selNode.index });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN NODE: ' + selNode.lnNode });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + selNode.lnImplementation });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + selNode.settings.fiatConversion });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + selNode.settings.currencyUnit });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + selNode.settings.lnServerUrl });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + selNode.Settings.fiatConversion });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + selNode.Settings.currencyUnit });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + selNode.Settings.lnServerUrl });
this.logger.log({ selectedNode: selNode, level: 'INFO', fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + this.appConfig.SSO.logoutRedirectLink + '\r\n' });
}
};

@ -125,17 +125,16 @@ export class ConfigService {
private validateNodeConfig = (config) => {
if ((process?.env?.RTL_SSO && +process?.env?.RTL_SSO === 0) || (typeof process?.env?.RTL_SSO === 'undefined' && +config.SSO.rtlSSO === 0)) {
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
this.common.appConfig.rtlPass = this.hash.update(process?.env?.APP_PASSWORD).digest('hex');
config.rtlPass = this.hash.update(process?.env?.APP_PASSWORD).digest('hex');
this.common.appConfig.allowPasswordUpdate = false;
} else if (config.multiPassHashed && config.multiPassHashed !== '') {
this.common.appConfig.rtlPass = config.multiPassHashed;
config.rtlPass = config.multiPassHashed;
} else if (config.multiPass && config.multiPass !== '') {
this.common.appConfig.rtlPass = this.common.replacePasswordWithHash(this.hash.update(config.multiPass).digest('hex'));
config.rtlPass = this.common.replacePasswordWithHash(this.hash.update(config.multiPass).digest('hex'));
} else {
this.errMsg = this.errMsg + '\nNode Authentication can be set with multiPass only. Please set multiPass in RTL-Config.json';
}
this.common.appConfig.rtlSecret2fa = config.secret2fa;
this.common.appConfig.enable2FA = !!config.secret2fa;
config.enable2FA = !!config.secret2FA;
} else {
if (process?.env?.APP_PASSWORD && process?.env?.APP_PASSWORD.trim() !== '') {
this.errMsg = this.errMsg + '\nRTL Password cannot be set with SSO. Please set SSO as 0 or remove password.';
@ -143,10 +142,10 @@ export class ConfigService {
}
this.common.port = (process?.env?.PORT) ? this.normalizePort(process?.env?.PORT) : (config.port) ? this.normalizePort(config.port) : 3000;
this.common.host = (process?.env?.HOST) ? process?.env?.HOST : (config.host) ? config.host : null;
this.common.appConfig.dbDirectoryPath = (process?.env?.DB_DIRECTORY_PATH) ? process?.env?.DB_DIRECTORY_PATH : (config.dbDirectoryPath) ? config.dbDirectoryPath : join(dirname(fileURLToPath(import.meta.url)), '..', '..');
config.dbDirectoryPath = (process?.env?.DB_DIRECTORY_PATH) ? process?.env?.DB_DIRECTORY_PATH : (config.dbDirectoryPath) ? config.dbDirectoryPath : join(dirname(fileURLToPath(import.meta.url)), '..', '..');
if (config.nodes && config.nodes.length > 0) {
config.nodes.forEach((node, idx) => {
this.common.nodes[idx] = { settings: {}, authentication: {} };
this.common.nodes[idx] = { Settings: {}, Authentication: {} };
this.common.nodes[idx].index = node.index;
this.common.nodes[idx].lnNode = node.lnNode;
this.common.nodes[idx].lnImplementation = (process?.env?.lnImplementation) ? process?.env?.lnImplementation : node.lnImplementation ? node.lnImplementation : 'LND';
@ -154,9 +153,9 @@ export class ConfigService {
switch (this.common.nodes[idx].lnImplementation) {
case 'CLN':
if (process?.env?.RUNE_PATH && process?.env?.RUNE_PATH.trim() !== '') {
this.common.nodes[idx].authentication.runePath = process?.env?.RUNE_PATH;
this.common.nodes[idx].Authentication.runePath = process?.env?.RUNE_PATH;
} else if (node.Authentication && node.Authentication.runePath && node.Authentication.runePath.trim() !== '') {
this.common.nodes[idx].authentication.runePath = node.Authentication.runePath;
this.common.nodes[idx].Authentication.runePath = node.Authentication.runePath;
} else {
this.errMsg = 'Please set rune path for node index ' + node.index + ' in RTL-Config.json!';
}
@ -164,106 +163,106 @@ export class ConfigService {
case 'ECL':
if (process?.env?.LN_API_PASSWORD) {
this.common.nodes[idx].authentication.lnApiPassword = process?.env?.LN_API_PASSWORD;
this.common.nodes[idx].Authentication.lnApiPassword = process?.env?.LN_API_PASSWORD;
} else if (node.Authentication && node.Authentication.lnApiPassword) {
this.common.nodes[idx].authentication.lnApiPassword = node.Authentication.lnApiPassword;
this.common.nodes[idx].Authentication.lnApiPassword = node.Authentication.lnApiPassword;
} else {
this.common.nodes[idx].authentication.lnApiPassword = '';
this.common.nodes[idx].Authentication.lnApiPassword = '';
}
break;
default:
if (process?.env?.MACAROON_PATH && process?.env?.MACAROON_PATH.trim() !== '') {
this.common.nodes[idx].authentication.macaroonPath = process?.env?.MACAROON_PATH;
this.common.nodes[idx].Authentication.macaroonPath = process?.env?.MACAROON_PATH;
} else if (node.Authentication && node.Authentication.macaroonPath && node.Authentication.macaroonPath.trim() !== '') {
this.common.nodes[idx].authentication.macaroonPath = node.Authentication.macaroonPath;
this.common.nodes[idx].Authentication.macaroonPath = node.Authentication.macaroonPath;
} else {
this.errMsg = 'Please set macaroon path for node index ' + node.index + ' in RTL-Config.json!';
}
break;
}
if (process?.env?.CONFIG_PATH) {
this.common.nodes[idx].authentication.configPath = process?.env?.CONFIG_PATH;
this.common.nodes[idx].Authentication.configPath = process?.env?.CONFIG_PATH;
} else if (node.Authentication && node.Authentication.configPath) {
this.common.nodes[idx].authentication.configPath = node.Authentication.configPath;
this.common.nodes[idx].Authentication.configPath = node.Authentication.configPath;
} else {
this.common.nodes[idx].authentication.configPath = '';
this.common.nodes[idx].Authentication.configPath = '';
}
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].authentication.lnApiPassword === '' && this.common.nodes[idx].authentication.configPath !== '') {
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].Authentication.lnApiPassword === '' && this.common.nodes[idx].Authentication.configPath !== '') {
try {
const exists = fs.existsSync(this.common.nodes[idx].authentication.configPath || '');
const exists = fs.existsSync(this.common.nodes[idx].Authentication.configPath || '');
if (exists) {
try {
const configFile = fs.readFileSync((this.common.nodes[idx].authentication.configPath || ''), 'utf-8');
const configFile = fs.readFileSync((this.common.nodes[idx].Authentication.configPath || ''), 'utf-8');
const iniParsed = ini.parse(configFile);
this.common.nodes[idx].authentication.lnApiPassword = iniParsed['eclair.api.password'] ? iniParsed['eclair.api.password'] : parseHocon(configFile).eclair.api.password;
this.common.nodes[idx].Authentication.lnApiPassword = iniParsed['eclair.api.password'] ? iniParsed['eclair.api.password'] : parseHocon(configFile).eclair.api.password;
} catch (err) {
this.errMsg = this.errMsg + '\nSomething went wrong while reading config file: \n' + err;
}
} else {
this.errMsg = this.errMsg + '\nInvalid config path: ' + this.common.nodes[idx].authentication.configPath;
this.errMsg = this.errMsg + '\nInvalid config path: ' + this.common.nodes[idx].Authentication.configPath;
}
} catch (err) {
this.errMsg = this.errMsg + '\nUnable to read config file: \n' + err;
}
}
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].authentication.lnApiPassword === '') {
if (this.common.nodes[idx].lnImplementation === 'ECL' && this.common.nodes[idx].Authentication.lnApiPassword === '') {
this.errMsg = this.errMsg + '\nPlease set config path Or api password for node index ' + node.index + ' in RTL-Config.json! It is mandatory for Eclair authentication!';
}
if (process?.env?.LN_SERVER_URL && process?.env?.LN_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = process?.env?.LN_SERVER_URL.endsWith('/v1') ? process?.env?.LN_SERVER_URL.slice(0, -3) : process?.env?.LN_SERVER_URL;
this.common.nodes[idx].Settings.lnServerUrl = process?.env?.LN_SERVER_URL.endsWith('/v1') ? process?.env?.LN_SERVER_URL.slice(0, -3) : process?.env?.LN_SERVER_URL;
} else if (process?.env?.LND_SERVER_URL && process?.env?.LND_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = process?.env?.LND_SERVER_URL.endsWith('/v1') ? process?.env?.LND_SERVER_URL.slice(0, -3) : process?.env?.LND_SERVER_URL;
this.common.nodes[idx].Settings.lnServerUrl = process?.env?.LND_SERVER_URL.endsWith('/v1') ? process?.env?.LND_SERVER_URL.slice(0, -3) : process?.env?.LND_SERVER_URL;
} else if (node.Settings.lnServerUrl && node.Settings.lnServerUrl.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = node.Settings.lnServerUrl.endsWith('/v1') ? node.Settings.lnServerUrl.slice(0, -3) : node.Settings.lnServerUrl;
this.common.nodes[idx].Settings.lnServerUrl = node.Settings.lnServerUrl.endsWith('/v1') ? node.Settings.lnServerUrl.slice(0, -3) : node.Settings.lnServerUrl;
} else if (node.Settings.lndServerUrl && node.Settings.lndServerUrl.trim() !== '') {
this.common.nodes[idx].settings.lnServerUrl = node.Settings.lndServerUrl.endsWith('/v1') ? node.Settings.lndServerUrl.slice(0, -3) : node.Settings.lndServerUrl;
this.common.nodes[idx].Settings.lnServerUrl = node.Settings.lndServerUrl.endsWith('/v1') ? node.Settings.lndServerUrl.slice(0, -3) : node.Settings.lndServerUrl;
} else {
this.errMsg = this.errMsg + '\nPlease set LN Server URL for node index ' + node.index + ' in RTL-Config.json!';
}
this.common.nodes[idx].settings.userPersona = node.Settings.userPersona ? node.Settings.userPersona : 'MERCHANT';
this.common.nodes[idx].settings.themeMode = node.Settings.themeMode ? node.Settings.themeMode : 'DAY';
this.common.nodes[idx].settings.themeColor = node.Settings.themeColor ? node.Settings.themeColor : 'PURPLE';
this.common.nodes[idx].settings.unannouncedChannels = node.Settings.unannouncedChannels ? !!node.Settings.unannouncedChannels : false;
this.common.nodes[idx].settings.logLevel = node.Settings.logLevel ? node.Settings.logLevel : 'ERROR';
this.common.nodes[idx].settings.fiatConversion = node.Settings.fiatConversion ? !!node.Settings.fiatConversion : false;
if (this.common.nodes[idx].settings.fiatConversion) {
this.common.nodes[idx].settings.currencyUnit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
this.common.nodes[idx].Settings.userPersona = node.Settings.userPersona ? node.Settings.userPersona : 'MERCHANT';
this.common.nodes[idx].Settings.themeMode = node.Settings.themeMode ? node.Settings.themeMode : 'DAY';
this.common.nodes[idx].Settings.themeColor = node.Settings.themeColor ? node.Settings.themeColor : 'PURPLE';
this.common.nodes[idx].Settings.unannouncedChannels = node.Settings.unannouncedChannels ? !!node.Settings.unannouncedChannels : false;
this.common.nodes[idx].Settings.logLevel = node.Settings.logLevel ? node.Settings.logLevel : 'ERROR';
this.common.nodes[idx].Settings.fiatConversion = node.Settings.fiatConversion ? !!node.Settings.fiatConversion : false;
if (this.common.nodes[idx].Settings.fiatConversion) {
this.common.nodes[idx].Settings.currencyUnit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
}
if (process?.env?.SWAP_SERVER_URL && process?.env?.SWAP_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.swapServerUrl = process?.env?.SWAP_SERVER_URL.endsWith('/v1') ? process?.env?.SWAP_SERVER_URL.slice(0, -3) : process?.env?.SWAP_SERVER_URL;
this.common.nodes[idx].authentication.swapMacaroonPath = process?.env?.SWAP_MACAROON_PATH;
this.common.nodes[idx].Settings.swapServerUrl = process?.env?.SWAP_SERVER_URL.endsWith('/v1') ? process?.env?.SWAP_SERVER_URL.slice(0, -3) : process?.env?.SWAP_SERVER_URL;
this.common.nodes[idx].Authentication.swapMacaroonPath = process?.env?.SWAP_MACAROON_PATH;
} else if (node.Settings.swapServerUrl && node.Settings.swapServerUrl.trim() !== '') {
this.common.nodes[idx].settings.swapServerUrl = node.Settings.swapServerUrl.endsWith('/v1') ? node.Settings.swapServerUrl.slice(0, -3) : node.Settings.swapServerUrl;
this.common.nodes[idx].authentication.swapMacaroonPath = node.Authentication.swapMacaroonPath ? node.Authentication.swapMacaroonPath : '';
this.common.nodes[idx].Settings.swapServerUrl = node.Settings.swapServerUrl.endsWith('/v1') ? node.Settings.swapServerUrl.slice(0, -3) : node.Settings.swapServerUrl;
this.common.nodes[idx].Authentication.swapMacaroonPath = node.Authentication.swapMacaroonPath ? node.Authentication.swapMacaroonPath : '';
} else {
this.common.nodes[idx].settings.swapServerUrl = '';
this.common.nodes[idx].authentication.swapMacaroonPath = '';
this.common.nodes[idx].Settings.swapServerUrl = '';
this.common.nodes[idx].Authentication.swapMacaroonPath = '';
}
if (process?.env?.BOLTZ_SERVER_URL && process?.env?.BOLTZ_SERVER_URL.trim() !== '') {
this.common.nodes[idx].settings.boltzServerUrl = process?.env?.BOLTZ_SERVER_URL.endsWith('/v1') ? process?.env?.BOLTZ_SERVER_URL.slice(0, -3) : process?.env?.BOLTZ_SERVER_URL;
this.common.nodes[idx].authentication.boltzMacaroonPath = process?.env?.BOLTZ_MACAROON_PATH;
this.common.nodes[idx].Settings.boltzServerUrl = process?.env?.BOLTZ_SERVER_URL.endsWith('/v1') ? process?.env?.BOLTZ_SERVER_URL.slice(0, -3) : process?.env?.BOLTZ_SERVER_URL;
this.common.nodes[idx].Authentication.boltzMacaroonPath = process?.env?.BOLTZ_MACAROON_PATH;
} else if (node.Settings.boltzServerUrl && node.Settings.boltzServerUrl.trim() !== '') {
this.common.nodes[idx].settings.boltzServerUrl = node.Settings.boltzServerUrl.endsWith('/v1') ? node.Settings.boltzServerUrl.slice(0, -3) : node.Settings.boltzServerUrl;
this.common.nodes[idx].authentication.boltzMacaroonPath = node.Authentication.boltzMacaroonPath ? node.Authentication.boltzMacaroonPath : '';
this.common.nodes[idx].Settings.boltzServerUrl = node.Settings.boltzServerUrl.endsWith('/v1') ? node.Settings.boltzServerUrl.slice(0, -3) : node.Settings.boltzServerUrl;
this.common.nodes[idx].Authentication.boltzMacaroonPath = node.Authentication.boltzMacaroonPath ? node.Authentication.boltzMacaroonPath : '';
} else {
this.common.nodes[idx].settings.boltzServerUrl = '';
this.common.nodes[idx].authentication.boltzMacaroonPath = '';
this.common.nodes[idx].Settings.boltzServerUrl = '';
this.common.nodes[idx].Authentication.boltzMacaroonPath = '';
}
this.common.nodes[idx].settings.enableOffers = process?.env?.ENABLE_OFFERS ? process?.env?.ENABLE_OFFERS : (node.Settings.enableOffers) ? node.Settings.enableOffers : false;
this.common.nodes[idx].settings.enablePeerswap = process?.env?.ENABLE_PEERSWAP ? process?.env?.ENABLE_PEERSWAP : (node.Settings.enablePeerswap) ? node.Settings.enablePeerswap : false;
this.common.nodes[idx].settings.bitcoindConfigPath = process?.env?.BITCOIND_CONFIG_PATH ? process?.env?.BITCOIND_CONFIG_PATH : (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
this.common.nodes[idx].settings.channelBackupPath = process?.env?.CHANNEL_BACKUP_PATH ? process?.env?.CHANNEL_BACKUP_PATH : (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : this.common.appConfig.rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node.index;
this.common.nodes[idx].Settings.enableOffers = process?.env?.ENABLE_OFFERS ? process?.env?.ENABLE_OFFERS : (node.Settings.enableOffers) ? node.Settings.enableOffers : false;
this.common.nodes[idx].Settings.enablePeerswap = process?.env?.ENABLE_PEERSWAP ? process?.env?.ENABLE_PEERSWAP : (node.Settings.enablePeerswap) ? node.Settings.enablePeerswap : false;
this.common.nodes[idx].Settings.bitcoindConfigPath = process?.env?.BITCOIND_CONFIG_PATH ? process?.env?.BITCOIND_CONFIG_PATH : (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
this.common.nodes[idx].Settings.channelBackupPath = process?.env?.CHANNEL_BACKUP_PATH ? process?.env?.CHANNEL_BACKUP_PATH : (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : this.common.appConfig.rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node.index;
try {
this.common.createDirectory(this.common.nodes[idx].settings.channelBackupPath);
const exists = fs.existsSync(this.common.nodes[idx].settings.channelBackupPath + sep + 'channel-all.bak');
this.common.createDirectory(this.common.nodes[idx].Settings.channelBackupPath);
const exists = fs.existsSync(this.common.nodes[idx].Settings.channelBackupPath + sep + 'channel-all.bak');
if (!exists) {
try {
if (this.common.nodes[idx].lnImplementation === 'LND') {
this.common.getAllNodeAllChannelBackup(this.common.nodes[idx]);
} else {
const createStream = fs.createWriteStream(this.common.nodes[idx].settings.channelBackupPath + sep + 'channel-all.bak');
const createStream = fs.createWriteStream(this.common.nodes[idx].Settings.channelBackupPath + sep + 'channel-all.bak');
createStream.end();
}
} catch (err) {
@ -273,9 +272,9 @@ export class ConfigService {
} catch (err) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while creating the backup directory: \n' + err });
}
this.common.nodes[idx].settings.logFile = this.common.appConfig.rtlConfFilePath + '/logs/RTL-Node-' + node.index + '.log';
this.common.nodes[idx].Settings.logFile = config.rtlConfFilePath + '/logs/RTL-Node-' + node.index + '.log';
this.logger.log({ selectedNode: this.common.selectedNode, level: 'INFO', fileName: 'Config', msg: 'Node Config: ' + JSON.stringify(this.common.nodes[idx]) });
const log_file = this.common.nodes[idx].settings.logFile;
const log_file = this.common.nodes[idx].Settings.logFile;
if (fs.existsSync(log_file || '')) {
fs.writeFile((log_file || ''), '', () => { });
} else {
@ -296,27 +295,27 @@ export class ConfigService {
private setSSOParams = (config) => {
if (process?.env?.RTL_SSO) {
this.common.appConfig.SSO.rtlSso = +process?.env?.RTL_SSO;
config.SSO.rtlSso = +process?.env?.RTL_SSO;
} else if (config.SSO && config.SSO.rtlSSO) {
this.common.appConfig.SSO.rtlSso = config.SSO.rtlSSO;
config.SSO.rtlSso = config.SSO.rtlSSO;
}
if (process?.env?.RTL_COOKIE_PATH) {
this.common.appConfig.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
config.SSO.rtlCookiePath = process?.env?.RTL_COOKIE_PATH;
} else if (config.SSO && config.SSO.rtlCookiePath) {
this.common.appConfig.SSO.rtlCookiePath = config.SSO.rtlCookiePath;
config.SSO.rtlCookiePath = config.SSO.rtlCookiePath;
} else {
this.common.appConfig.SSO.rtlCookiePath = '';
config.SSO.rtlCookiePath = '';
}
if (process?.env?.LOGOUT_REDIRECT_LINK) {
this.common.appConfig.SSO.logoutRedirectLink = process?.env?.LOGOUT_REDIRECT_LINK;
config.SSO.logoutRedirectLink = process?.env?.LOGOUT_REDIRECT_LINK;
} else if (config.SSO && config.SSO.logoutRedirectLink) {
this.common.appConfig.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
config.SSO.logoutRedirectLink = config.SSO.logoutRedirectLink;
}
if (+this.common.appConfig.SSO.rtlSso) {
if (!this.common.appConfig.SSO.rtlCookiePath || this.common.appConfig.SSO.rtlCookiePath.trim() === '') {
if (+config.SSO.rtlSso) {
if (!config.SSO.rtlCookiePath || config.SSO.rtlCookiePath.trim() === '') {
this.errMsg = 'Please set rtlCookiePath value for single sign on option!';
} else {
this.common.readCookie();
@ -340,9 +339,11 @@ export class ConfigService {
fs.writeFileSync(confFileFullPath, JSON.stringify(this.setDefaultConfig()));
}
const config = JSON.parse(fs.readFileSync(confFileFullPath, 'utf-8'));
config.rtlConfFilePath = this.common.appConfig.rtlConfFilePath;
this.updateLogByLevel();
this.validateNodeConfig(config);
this.setSelectedNode(config);
this.common.appConfig = config;
} catch (err: any) {
this.logger.log({ selectedNode: this.common.selectedNode, level: 'ERROR', fileName: 'Config', msg: 'Something went wrong while configuring the node server: \n' + err });
throw new Error(err);

@ -17,16 +17,16 @@ export class LoggerService {
msgStr = msgStr + '.\r\n';
}
console.error(msgStr);
if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
break;
case 'WARN':
msgStr = prepMsgData(msgJSON, msgStr);
if (!msgJSON.selectedNode || msgJSON.selectedNode.settings.logLevel === 'WARN' || msgJSON.selectedNode.settings.logLevel === 'INFO' || msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (!msgJSON.selectedNode || msgJSON.selectedNode.Settings.logLevel === 'WARN' || msgJSON.selectedNode.Settings.logLevel === 'INFO' || msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;
@ -34,17 +34,17 @@ export class LoggerService {
case 'INFO':
if (!msgJSON.selectedNode && msgJSON.fileName === 'RTL') {
console.log(msgStr + '.\r\n');
} else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'INFO') {
} else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'INFO') {
msgStr = msgStr + '.\r\n';
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
} else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
} else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
msgStr = prepMsgData(msgJSON, msgStr);
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;
@ -52,11 +52,11 @@ export class LoggerService {
case 'DEBUG':
if (!msgJSON.selectedNode) {
console.log(msgStr + '.\r\n');
} else if (msgJSON.selectedNode && msgJSON.selectedNode.settings.logLevel === 'DEBUG') {
} else if (msgJSON.selectedNode && msgJSON.selectedNode.Settings.logLevel === 'DEBUG') {
msgStr = prepMsgData(msgJSON, msgStr);
console.log(msgStr);
if (msgJSON.selectedNode.settings.logFile) {
fs.appendFile(msgJSON.selectedNode.settings.logFile, msgStr, () => { });
if (msgJSON.selectedNode.Settings.logFile) {
fs.appendFile(msgJSON.selectedNode.Settings.logFile, msgStr, () => { });
}
}
break;

@ -1,4 +1,4 @@
<div fxLayout="column" id="rtl-container" class="rtl-container medium" [ngClass]="[settings.themeColor | lowercase, settings.themeMode | lowercase]">
<div fxLayout="column" id="rtl-container" class="rtl-container medium" [ngClass]="[selNode.Settings.themeColor | lowercase, selNode.Settings.themeMode | lowercase]">
<mat-toolbar fxLayout="row" fxLayoutAlign="space-between center" class="bg-primary rtl-top-toolbar">
<div>
<button *ngIf="flgLoggedIn" mat-icon-button matTooltipPosition="right" [matTooltip]="flgSideNavOpened ? 'Hide Navigation Menu' : 'Show Navigation Menu'" [matTooltipDisabled]="smallScreen" (click)="sideNavToggle()">
@ -29,7 +29,7 @@
</div>
</mat-sidenav-content>
</mat-sidenav-container>
<div *ngIf="!settings.themeColor" class="rtl-spinner">
<div *ngIf="!selNode.Settings.themeColor" class="rtl-spinner">
<mat-spinner color="accent" />
<h4>Loading RTL...</h4>
</div>

@ -14,7 +14,7 @@ import { CommonService } from './shared/services/common.service';
import { SessionService } from './shared/services/session.service';
import { AlertTypeEnum, RTLActions, ScreenSizeEnum } from './shared/services/consts-enums-functions';
import { rootAppConfig, rootNodeData, rootSelectedNode } from './store/rtl.selector';
import { RTLConfiguration, Settings, GetInfoRoot } from './shared/models/RTLconfig';
import { RTLConfiguration, GetInfoRoot } from './shared/models/RTLconfig';
import { closeAllDialogs, fetchRTLConfig, login, logout, openAlert } from './store/rtl.actions';
import { routeAnimation } from './shared/animation/route-animation';
@ -30,11 +30,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('sideNavigation', { static: false }) sideNavigation: any;
@ViewChild('sideNavContent', { static: false }) sideNavContent: any;
public settings: Settings;
public information: GetInfoRoot = {};
public flgLoading: Array<Boolean | 'error'> = [true]; // 0: Info
public flgSideNavOpened = true;
public flgCopied = false;
public selNode: Node | any;
public appConfig: RTLConfiguration;
public accessKey = '';
public xSmallScreen = false;
@ -78,7 +78,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.store.dispatch(fetchRTLConfig());
this.accessKey = this.readAccessKey() || '';
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[1])).subscribe((selNode) => {
this.settings = selNode.settings;
if (!this.sessionService.getItem('token')) {
this.flgLoggedIn = false;
this.flgLoading[0] = false;
@ -86,6 +85,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.flgLoggedIn = true;
this.userIdle.startWatching();
}
this.selNode = selNode;
});
this.store.select(rootAppConfig).pipe(takeUntil(this.unSubs[2])).subscribe((appConfig) => { this.appConfig = appConfig; });
this.store.select(rootNodeData).pipe(takeUntil(this.unSubs[3])).subscribe((nodeData) => {
@ -98,11 +98,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
}
this.actions.pipe(
takeUntil(this.unSubs[4]),
filter((action) => action.type === RTLActions.SET_RTL_CONFIG || action.type === RTLActions.LOGIN || action.type === RTLActions.LOGOUT)).
filter((action) => action.type === RTLActions.FETCH_APPLICATION_SETTINGS || action.type === RTLActions.LOGIN || action.type === RTLActions.LOGOUT)).
subscribe((action: (any)) => {
if (action.type === RTLActions.SET_RTL_CONFIG) {
if (action.type === RTLActions.SET_APPLICATION_SETTINGS) {
if (!this.sessionService.getItem('token')) {
if (+action.payload.sso.rtlSSO) {
if (+action.payload.SSO.rtlSSO) {
if (!this.accessKey || this.accessKey.trim().length < 32) {
this.router.navigate(['./error'], { state: { errorCode: '406', errorMessage: 'Access key too short. It should be at least 32 characters long.' } });
} else {

@ -93,7 +93,7 @@
<ng-template #sweepAllBlock>
<div fxLayout="column">
<mat-vertical-stepper #stepper [linear]="true" (selectionChange)="stepSelectionChanged($event)">
<mat-step *ngIf="!appConfig.sso.rtlSSO" [stepControl]="passwordFormGroup" [editable]="flgEditable">
<mat-step *ngIf="!appConfig.SSO.rtlSSO" [stepControl]="passwordFormGroup" [editable]="flgEditable">
<form fxLayout="column" fxLayoutAlign="space-between" class="my-1 pr-1" [formGroup]="passwordFormGroup">
<ng-template matStepLabel>{{passwordFormLabel}}</ng-template>
<div fxLayout="row">

@ -132,8 +132,8 @@ export class CLNOnChainSendModalComponent implements OnInit, OnDestroy {
});
combineLatest([this.store.select(rootSelectedNode), this.store.select(rootAppConfig)]).pipe(takeUntil(this.unSubs[1])).
subscribe(([selNode, appConfig]) => {
this.fiatConversion = selNode.settings.fiatConversion;
this.amountUnits = selNode.settings.currencyUnits;
this.fiatConversion = selNode.Settings.fiatConversion;
this.amountUnits = selNode.Settings.currencyUnits;
this.appConfig = appConfig;
});
this.store.select(clnNodeInformation).pipe(takeUntil(this.unSubs[2])).

@ -48,8 +48,8 @@ export class ECLOnChainSendModalComponent implements OnInit, OnDestroy {
ngOnInit() {
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[0])).subscribe((selNode) => {
this.fiatConversion = selNode.settings.fiatConversion;
this.amountUnits = selNode.settings.currencyUnits;
this.fiatConversion = selNode.Settings.fiatConversion;
this.amountUnits = selNode.Settings.currencyUnits;
this.logger.info(selNode);
});
this.actions.pipe(

@ -60,7 +60,7 @@
<ng-template #sweepAllBlock>
<div fxLayout="column">
<mat-vertical-stepper #stepper [linear]="true" (selectionChange)="stepSelectionChanged($event)">
<mat-step *ngIf="!appConfig.sso.rtlSSO" [stepControl]="passwordFormGroup" [editable]="flgEditable">
<mat-step *ngIf="!appConfig.SSO.rtlSSO" [stepControl]="passwordFormGroup" [editable]="flgEditable">
<form fxLayout="column" fxLayoutAlign="space-between" class="my-1 pr-1" [formGroup]="passwordFormGroup">
<ng-template matStepLabel>{{passwordFormLabel}}</ng-template>
<div fxLayout="row">

@ -109,8 +109,8 @@ export class OnChainSendModalComponent implements OnInit, OnDestroy {
this.appConfig = appConfig;
});
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[2])).subscribe((selNode) => {
this.fiatConversion = selNode.settings.fiatConversion;
this.amountUnits = selNode.settings.currencyUnits;
this.fiatConversion = selNode.Settings.fiatConversion;
this.amountUnits = selNode.Settings.currencyUnits;
this.logger.info(selNode);
});
this.actions.pipe(

@ -34,8 +34,8 @@ export class CurrencyUnitConverterComponent implements OnInit, OnChanges, OnDest
ngOnInit() {
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[0])).subscribe((selNode) => {
this.fiatConversion = selNode.settings.fiatConversion;
this.currencyUnits = selNode.settings.currencyUnits;
this.fiatConversion = selNode.Settings.fiatConversion;
this.currencyUnits = selNode.Settings.currencyUnits;
if (!this.fiatConversion) {
this.currencyUnits.splice(2, 1);
}

@ -12,10 +12,9 @@ import * as sha256 from 'sha256';
import { RTLConfiguration } from '../../../models/RTLconfig';
import { AuthConfig } from '../../../models/alertData';
import { RTLEffects } from '../../../../store/rtl.effects';
import { RTLState } from '../../../../store/rtl.state';
import { isAuthorized, twoFASaveSettings } from '../../../../store/rtl.actions';
import { isAuthorized, updateApplicationSettings } from '../../../../store/rtl.actions';
@Component({
selector: 'rtl-two-factor-auth',
@ -92,7 +91,8 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
onVerifyToken(): boolean | void {
if (this.appConfig?.enable2FA) {
this.store.dispatch(twoFASaveSettings({ payload: { secret2fa: '' } }));
this.appConfig.secret2FA = '';
this.store.dispatch(updateApplicationSettings({ payload: this.appConfig }));
this.generateSecret();
this.isTokenValid = true;
} else {
@ -104,13 +104,11 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
this.tokenFormGroup.controls.token.setErrors({ notValid: true });
return true;
}
this.store.dispatch(twoFASaveSettings({ payload: { secret2fa: this.secretFormGroup.controls.secret.value } }));
this.appConfig.secret2FA = this.secretFormGroup.controls.secret.value;
this.store.dispatch(updateApplicationSettings({ payload: this.appConfig }));
this.tokenFormGroup.controls.token.setValue('');
}
this.flgValidated = true;
if (this.appConfig) {
this.appConfig.enable2FA = !this.appConfig?.enable2FA;
}
}
stepSelectionChanged(event: any) {

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

@ -8,7 +8,7 @@
</perfect-scrollbar>
</mat-select>
<mat-divider class="w-100" />
<mat-tree *ngIf="settings?.lnServerUrl" #tree [dataSource]="navMenus" [treeControl]="treeControlNested">
<mat-tree *ngIf="selNode.Settings?.lnServerUrl" #tree [dataSource]="navMenus" [treeControl]="treeControlNested">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle routerLinkActive="active-link" routerLink="{{node.link}}">
<div tabindex="2" (click)="onChildNavClicked(node)">
<div fxLayout="row" fxFlex="100" fxLayoutAlign="start center">

@ -8,7 +8,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, ConfigSettingsNode, Settings, GetInfoRoot } from '../../../models/RTLconfig';
import { RTLConfiguration, Node, Settings, GetInfoRoot } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { SessionService } from '../../../services/session.service';
import { GetInfoChain } from '../../../models/lndModels';
@ -34,8 +34,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
faEye = faEye;
public appConfig: RTLConfiguration;
public selConfigNodeIndex: Number;
public selNode: ConfigSettingsNode | any;
public settings: Settings | null;
public selNode: Node | any;
public version = '';
public information: GetInfoRoot = {};
public informationChain: GetInfoChain = {};
@ -73,7 +72,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
this.appConfig = appConfig;
});
this.store.select(rootSelNodeAndNodeData).pipe(takeUntil(this.unSubs[1])).
subscribe((rootData: { nodeDate: GetInfoRoot, selNode: ConfigSettingsNode | null }) => {
subscribe((rootData: { nodeDate: GetInfoRoot, selNode: Node | null }) => {
this.information = rootData.nodeDate;
if (this.information.identity_pubkey) {
if (this.information.chains && typeof this.information.chains[0] === 'string') {
@ -93,7 +92,6 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
this.smallScreen = true;
}
this.selNode = rootData.selNode;
this.settings = this.selNode?.settings || null;
this.selConfigNodeIndex = +(rootData.selNode?.index || 0);
if (this.selNode && this.selNode.lnImplementation) {
this.filterSideMenuNodes();
@ -162,12 +160,12 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
clonedMenu = JSON.parse(JSON.stringify(MENU_DATA.LNDChildren));
this.navMenus.data = clonedMenu?.filter((navMenuData: any) => {
if (navMenuData.children && navMenuData.children.length) {
navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.settings?.userPersona) && navMenuChild.link !== '/services/loop' && navMenuChild.link !== '/services/boltz') ||
(navMenuChild.link === '/services/loop' && this.settings?.swapServerUrl && this.settings.swapServerUrl.trim() !== '') ||
(navMenuChild.link === '/services/boltz' && this.settings?.boltzServerUrl && this.settings.boltzServerUrl.trim() !== ''));
navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.selNode.Settings.userPersona) && navMenuChild.link !== '/services/loop' && navMenuChild.link !== '/services/boltz') ||
(navMenuChild.link === '/services/loop' && this.selNode.Settings.swapServerUrl && this.selNode.Settings.swapServerUrl.trim() !== '') ||
(navMenuChild.link === '/services/boltz' && this.selNode.Settings.boltzServerUrl && this.selNode.Settings.boltzServerUrl.trim() !== ''));
return navMenuData.children.length > 0;
}
return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.settings?.userPersona;
return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.selNode.Settings.userPersona;
});
}
@ -176,12 +174,12 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
clonedMenu = JSON.parse(JSON.stringify(MENU_DATA.CLNChildren));
this.navMenus.data = clonedMenu?.filter((navMenuData: any) => {
if (navMenuData.children && navMenuData.children.length) {
navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.settings?.userPersona) && navMenuChild.link !== '/services/peerswap') ||
(navMenuChild.link === '/services/peerswap' && this.settings?.enablePeerswap) ||
(navMenuChild.link === '/services/boltz' && this.settings?.boltzServerUrl && this.settings.boltzServerUrl.trim() !== ''));
navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.selNode.Settings.userPersona) && navMenuChild.link !== '/services/peerswap') ||
(navMenuChild.link === '/services/peerswap' && this.selNode.Settings.enablePeerswap) ||
(navMenuChild.link === '/services/boltz' && this.selNode.Settings.boltzServerUrl && this.selNode.Settings.boltzServerUrl.trim() !== ''));
return navMenuData.children.length > 0;
}
return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.settings?.userPersona;
return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.selNode.Settings.userPersona;
});
}

@ -7,8 +7,8 @@ import { faInfoCircle, faCode, faExclamationTriangle } from '@fortawesome/free-s
import { LoggerService } from '../../../services/logger.service';
import { RTLState } from '../../../../store/rtl.state';
import { rootSelectedNode } from '../../../../store/rtl.selector';
import { ConfigSettingsNode } from '../../../models/RTLconfig';
import { updateServiceSettings } from '../../../../store/rtl.actions';
import { Node } from '../../../models/RTLconfig';
import { updateNodeSettings } from '../../../../store/rtl.actions';
import { setChildNodeSettingsLND } from '../../../../lnd/store/lnd.actions';
import { setChildNodeSettingsCLN } from '../../../../cln/store/cln.actions';
import { setChildNodeSettingsECL } from '../../../../eclair/store/ecl.actions';
@ -31,7 +31,7 @@ export class ExperimentalSettingsComponent implements OnInit, OnDestroy {
public faCode = faCode;
public features = [{ name: 'Offers', enabled: false }, { name: 'Channel Funding Policy', enabled: false }];
public enableOffers = false;
public selNode: ConfigSettingsNode;
public selNode: Node;
public fundingPolicy: FunderPolicy = {};
public policyTypes = LADS_POLICY;
public selPolicyType = LADS_POLICY[0];
@ -60,7 +60,7 @@ export class ExperimentalSettingsComponent implements OnInit, OnDestroy {
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[1])).
subscribe((selNode) => {
this.selNode = selNode;
this.enableOffers = this.selNode.settings.enableOffers || false;
this.enableOffers = this.selNode.Settings.enableOffers || false;
this.features[0].enabled = this.enableOffers;
this.logger.info(this.selNode);
});
@ -89,27 +89,27 @@ export class ExperimentalSettingsComponent implements OnInit, OnDestroy {
onUpdateFeature(): boolean | void {
this.logger.info(this.selNode);
this.selNode.settings.enableOffers = this.enableOffers;
this.selNode.Settings.enableOffers = this.enableOffers;
this.features[0].enabled = this.enableOffers;
this.store.dispatch(updateServiceSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_SETTING, service: ServicesEnum.OFFERS, settings: { enableOffers: this.enableOffers } } }));
this.store.dispatch(setChildNodeSettingsLND({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers
}
}));
this.store.dispatch(setChildNodeSettingsCLN({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers
}
}));
this.store.dispatch(setChildNodeSettingsECL({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.enableOffers
}
}));
// this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_SETTING, service: ServicesEnum.OFFERS, settings: { enableOffers: this.enableOffers } } }));
// this.store.dispatch(setChildNodeSettingsLND({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl, enableOffers: this.enableOffers
// }
// }));
// this.store.dispatch(setChildNodeSettingsCLN({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl, enableOffers: this.enableOffers
// }
// }));
// this.store.dispatch(setChildNodeSettingsECL({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl, enableOffers: this.enableOffers
// }
// }));
}
onUpdateFundingPolicy() {

@ -8,7 +8,7 @@ import { openAlert } from '../../../store/rtl.actions';
import { RTLEffects } from '../../../store/rtl.effects';
import { IsAuthorizedComponent } from '../../components/data-modal/is-authorized/is-authorized.component';
import { ConfigSettingsNode, RTLConfiguration } from '../../models/RTLconfig';
import { Node, RTLConfiguration } from '../../models/RTLconfig';
import { RTLState } from '../../../store/rtl.state';
import { rootAppConfig, rootSelectedNode } from '../../../store/rtl.selector';
@ -22,7 +22,7 @@ export class NodeConfigComponent implements OnInit, OnDestroy {
public faTools = faTools;
public showLnConfig = false;
public appConfig: RTLConfiguration;
public selNode: ConfigSettingsNode | any;
public selNode: Node | any;
public lnImplementationStr = '';
public links = [{ link: 'nodesettings', name: 'Node Settings' }, { link: 'pglayout', name: 'Page Layout' }, { link: 'services', name: 'Services' }, { link: 'experimental', name: 'Experimental' }, { link: 'lnconfig', name: this.lnImplementationStr }];
public activeLink = '';
@ -59,7 +59,7 @@ export class NodeConfigComponent implements OnInit, OnDestroy {
this.lnImplementationStr = 'LND Config';
break;
}
if (this.selNode.authentication && this.selNode.authentication.configPath && this.selNode.authentication.configPath.trim() !== '') {
if (this.selNode.Authentication && this.selNode.Authentication.configPath && this.selNode.Authentication.configPath.trim() !== '') {
this.links[4].name = this.lnImplementationStr;
this.showLnConfig = true;
}
@ -67,7 +67,7 @@ export class NodeConfigComponent implements OnInit, OnDestroy {
}
showLnConfigClicked() {
if (!this.appConfig.sso.rtlSSO) {
if (!this.appConfig.SSO.rtlSSO) {
this.store.dispatch(openAlert({
payload: {
maxWidth: '50rem',

@ -14,7 +14,7 @@
<span>Use this control to toggle setting which defaults to opening unannounced channels only.</span>
</div>
<div fxLayout="row wrap" fxLayoutAlign="start center">
<mat-slide-toggle tabindex="1" color="primary" name="unannouncedChannels" [(ngModel)]="selNode.settings.unannouncedChannels" (change)="!selNode.settings.unannouncedChannels">Open Unannounced Channels</mat-slide-toggle>
<mat-slide-toggle tabindex="1" color="primary" name="unannouncedChannels" [(ngModel)]="selNode.Settings.unannouncedChannels" (change)="!selNode.Settings.unannouncedChannels">Open Unannounced Channels</mat-slide-toggle>
</div>
</div>
</mat-expansion-panel>
@ -31,15 +31,15 @@
<span>Fiat conversion calls <strong><a href="https://www.blockchain.com/api/exchange_rates_api" target="blank">Blockchain.com</a></strong> API to get conversion rates.</span>
</div>
<div fxLayout="row wrap" fxLayoutAlign="start center">
<mat-slide-toggle tabindex="2" color="primary" name="fiatConversion" class="mr-2" [(ngModel)]="selNode.settings.fiatConversion" (change)="!selNode.settings.currencyUnit">Enable Fiat Conversion</mat-slide-toggle>
<mat-slide-toggle tabindex="2" color="primary" name="fiatConversion" class="mr-2" [(ngModel)]="selNode.Settings.fiatConversion" (change)="!selNode.Settings.currencyUnit">Enable Fiat Conversion</mat-slide-toggle>
<mat-form-field>
<mat-label>Fiat Currency</mat-label>
<mat-select #currencyUnit="ngModel" autoFocus tabindex="3" name="currencyUnit" [disabled]="!selNode.settings.fiatConversion" [required]="selNode.settings.fiatConversion" [(ngModel)]="selNode.settings.currencyUnit" (selectionChange)="onCurrencyChange($event)">
<mat-select #currencyUnit="ngModel" autoFocus tabindex="3" name="currencyUnit" [disabled]="!selNode.Settings.fiatConversion" [required]="selNode.Settings.fiatConversion" [(ngModel)]="selNode.Settings.currencyUnit" (selectionChange)="onCurrencyChange($event)">
<mat-option *ngFor="let currencyUnit of currencyUnits" [value]="currencyUnit.id">
{{currencyUnit.id}}
</mat-option>
</mat-select>
<mat-error *ngIf="selNode.settings.fiatConversion && !selNode.settings.currencyUnit">Currency unit is required.</mat-error>
<mat-error *ngIf="selNode.Settings.fiatConversion && !selNode.Settings.currencyUnit">Currency unit is required.</mat-error>
</mat-form-field>
</div>
</div>
@ -58,8 +58,8 @@
</div>
<div fxLayout="column" fxLayoutAlign="start start" fxFlex="100">
<h4>Dashboard Layout</h4>
<mat-radio-group class="radio-group" color="primary" tabindex="1" name="userPersona" [(ngModel)]="selNode.settings.userPersona">
<mat-radio-button *ngFor="let userPersona of userPersonas" class="radio-text mr-4" [value]="userPersona" [checked]="selNode.settings.userPersona === userPersona">
<mat-radio-group class="radio-group" color="primary" tabindex="1" name="userPersona" [(ngModel)]="selNode.Settings.userPersona">
<mat-radio-button *ngFor="let userPersona of userPersonas" class="radio-text mr-4" [value]="userPersona" [checked]="selNode.Settings.userPersona === userPersona">
{{userPersona | titlecase}}
</mat-radio-button>
</mat-radio-group>
@ -91,7 +91,7 @@
<div fxLayout="column" fxLayoutAlign="start start" class="mt-1">
<div fxLayout="row">
<button class="mr-1" mat-stroked-button color="primary" tabindex="10" (click)="onResetSettings()">Reset</button>
<button mat-flat-button color="primary" tabindex="11" (click)="onUpdateSettings()">Update</button>
<button mat-flat-button color="primary" tabindex="11" (click)="onUpdateNodeSettings()">Update</button>
</div>
</div>
</div>

@ -5,11 +5,11 @@ import { Store } from '@ngrx/store';
import { faMoneyBillAlt, faPaintBrush, faInfoCircle, faExclamationTriangle, faEyeSlash } from '@fortawesome/free-solid-svg-icons';
import { CURRENCY_UNITS, UserPersonaEnum, ScreenSizeEnum, FIAT_CURRENCY_UNITS, NODE_SETTINGS, UI_MESSAGES } from '../../../services/consts-enums-functions';
import { ConfigSettingsNode, Settings } from '../../../models/RTLconfig';
import { Node, Settings } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { CommonService } from '../../../services/common.service';
import { RTLState } from '../../../../store/rtl.state';
import { saveSettings, setSelectedNode } from '../../../../store/rtl.actions';
import { updateNodeSettings, setSelectedNode } from '../../../../store/rtl.actions';
import { setChildNodeSettingsECL } from '../../../../eclair/store/ecl.actions';
import { setChildNodeSettingsCLN } from '../../../../cln/store/cln.actions';
import { setChildNodeSettingsLND } from '../../../../lnd/store/lnd.actions';
@ -27,7 +27,7 @@ export class NodeSettingsComponent implements OnInit, OnDestroy {
public faPaintBrush = faPaintBrush;
public faInfoCircle = faInfoCircle;
public faEyeSlash = faEyeSlash;
public selNode: ConfigSettingsNode | any;
public selNode: Node | any;
public userPersonas = [UserPersonaEnum.OPERATOR, UserPersonaEnum.MERCHANT];
public currencyUnits = FIAT_CURRENCY_UNITS;
public themeModes = NODE_SETTINGS.modes;
@ -49,89 +49,88 @@ export class NodeSettingsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[0])).subscribe((selNode) => {
this.selNode = selNode;
this.selectedThemeMode = this.themeModes.find((themeMode) => this.selNode.settings.themeMode === themeMode.id) || this.themeModes[0];
this.selectedThemeColor = this.selNode.settings.themeColor;
if (!this.selNode.settings.fiatConversion) {
this.selNode.settings.currencyUnit = '';
this.selectedThemeMode = this.themeModes.find((themeMode) => this.selNode.Settings.themeMode === themeMode.id) || this.themeModes[0];
this.selectedThemeColor = this.selNode.Settings.themeColor;
if (!this.selNode.Settings.fiatConversion) {
this.selNode.Settings.currencyUnit = '';
}
this.previousSettings = JSON.parse(JSON.stringify(this.selNode.settings));
this.previousSettings = JSON.parse(JSON.stringify(this.selNode.Settings));
this.logger.info(selNode);
});
}
onCurrencyChange(event: any) {
this.selNode.settings.currencyUnits = [...CURRENCY_UNITS, event.value];
this.selNode.Settings.currencyUnits = [...CURRENCY_UNITS, event.value];
this.store.dispatch(setChildNodeSettingsLND({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
this.store.dispatch(setChildNodeSettingsCLN({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
this.store.dispatch(setChildNodeSettingsECL({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: event.value,
currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels,
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
}
toggleSettings(toggleField: string, event?: any) {
this.selNode.settings[toggleField] = !this.selNode.settings[toggleField];
this.selNode.Settings[toggleField] = !this.selNode.Settings[toggleField];
}
changeThemeColor(newThemeColor: string) {
this.selectedThemeColor = newThemeColor;
this.selNode.settings.themeColor = newThemeColor;
this.selNode.Settings.themeColor = newThemeColor;
}
chooseThemeMode() {
this.selNode.settings.themeMode = this.selectedThemeMode.id;
this.selNode.Settings.themeMode = this.selectedThemeMode.id;
}
onUpdateSettings(): boolean | void {
if (this.selNode.settings.fiatConversion && !this.selNode.settings.currencyUnit) {
onUpdateNodeSettings(): boolean | void {
if (this.selNode.Settings.fiatConversion && !this.selNode.Settings.currencyUnit) {
return true;
}
this.logger.info(this.selNode.settings);
this.store.dispatch(saveSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_NODE_SETTINGS, settings: this.selNode.settings } }));
this.logger.info(this.selNode.Settings);
this.store.dispatch(setChildNodeSettingsLND({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath,
selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits,
fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath,
selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits,
fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
this.store.dispatch(setChildNodeSettingsCLN({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath,
selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits,
fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath,
selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits,
fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
this.store.dispatch(setChildNodeSettingsECL({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath,
selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits,
fiatConversion: this.selNode.settings.fiatConversion, unannouncedChannels: this.selNode.settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl
userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath,
selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits,
fiatConversion: this.selNode.Settings.fiatConversion, unannouncedChannels: this.selNode.Settings.unannouncedChannels, lnImplementation: this.selNode.lnImplementation,
swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.selNode.Settings.boltzServerUrl
}
}));
}
onResetSettings() {
const prevIndex = this.selNode.index || -1;
this.selNode.settings = this.previousSettings;
this.selNode.Settings = this.previousSettings;
this.selectedThemeMode = this.themeModes.find((themeMode) => themeMode.id === this.previousSettings.themeMode) || this.themeModes[0];
this.selectedThemeColor = this.previousSettings.themeColor;
this.store.dispatch(setSelectedNode({ payload: { uiMessage: UI_MESSAGES.NO_SPINNER, prevLnNodeIndex: +prevIndex, currentLnNode: this.selNode, isInitialSetup: true } }));

@ -11,7 +11,7 @@ import { CommonService } from '../../../services/common.service';
import { RTLState } from '../../../../store/rtl.state';
import { ApiCallStatusPayload } from '../../../models/apiCallsPayload';
import { rootSelectedNode } from '../../../../store/rtl.selector';
import { SelNodeChild, ConfigSettingsNode } from '../../../models/RTLconfig';
import { SelNodeChild, Node } from '../../../models/RTLconfig';
import { TableSetting, PageSettings } from '../../../models/pageSettings';
import { clnNodeSettings, clnPageSettings } from '../../../../cln/store/cln.selector';
import { lndNodeSettings, lndPageSettings } from '../../../../lnd/store/lnd.selector';
@ -29,7 +29,7 @@ export class PageSettingsComponent implements OnInit, OnDestroy {
public faPenRuler = faPenRuler;
public faExclamationTriangle = faExclamationTriangle;
public selNode: ConfigSettingsNode;
public selNode: Node;
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
public pageSizeOptions = PAGE_SIZE_OPTIONS;

@ -4,10 +4,10 @@ import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { ServicesEnum, UI_MESSAGES } from '../../../../services/consts-enums-functions';
import { ConfigSettingsNode } from '../../../../models/RTLconfig';
import { Node } from '../../../../models/RTLconfig';
import { LoggerService } from '../../../../services/logger.service';
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { updateServiceSettings } from '../../../../../store/rtl.actions';
import { updateNodeSettings } from '../../../../../store/rtl.actions';
import { RTLState } from '../../../../../store/rtl.state';
import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions';
import { setChildNodeSettingsCLN } from '../../../../../cln/store/cln.actions';
@ -23,8 +23,8 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy {
@ViewChild('form', { static: true }) form: any;
public faInfoCircle = faInfoCircle;
public selNode: ConfigSettingsNode | any;
public previousSelNode: ConfigSettingsNode | any;
public selNode: Node | any;
public previousSelNode: Node | any;
public enableBoltz = false;
public serverUrl = '';
public macaroonPath = '';
@ -37,9 +37,9 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy {
pipe(takeUntil(this.unSubs[0])).
subscribe((selNode) => {
this.selNode = selNode;
this.enableBoltz = !!(selNode.settings.boltzServerUrl && selNode.settings.boltzServerUrl.trim() !== '');
this.serverUrl = this.selNode.settings.boltzServerUrl || '';
this.macaroonPath = this.selNode.authentication.boltzMacaroonPath;
this.enableBoltz = !!(selNode.Settings.boltzServerUrl && selNode.Settings.boltzServerUrl.trim() !== '');
this.serverUrl = this.selNode.Settings.boltzServerUrl || '';
this.macaroonPath = this.selNode.Authentication.boltzMacaroonPath;
this.previousSelNode = JSON.parse(JSON.stringify(this.selNode));
this.logger.info(selNode);
});
@ -67,33 +67,33 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy {
return true;
}
this.logger.info(this.selNode);
this.selNode.settings.boltzServerUrl = this.serverUrl;
this.selNode.authentication.boltzMacaroonPath = this.macaroonPath;
this.store.dispatch(updateServiceSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_BOLTZ_SETTINGS, service: ServicesEnum.BOLTZ, settings: { enable: this.enableBoltz, serverUrl: this.serverUrl, macaroonPath: this.macaroonPath } } }));
this.store.dispatch(setChildNodeSettingsLND({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers
}
}));
this.store.dispatch(setChildNodeSettingsCLN({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers
}
}));
this.store.dispatch(setChildNodeSettingsECL({
payload: {
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.settings.enableOffers
}
}));
this.selNode.Settings.boltzServerUrl = this.serverUrl;
this.selNode.Authentication.boltzMacaroonPath = this.macaroonPath;
// this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_BOLTZ_SETTINGS, service: ServicesEnum.BOLTZ, settings: { enable: this.enableBoltz, serverUrl: this.serverUrl, macaroonPath: this.macaroonPath } } }));
// this.store.dispatch(setChildNodeSettingsLND({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.Settings.enableOffers
// }
// }));
// this.store.dispatch(setChildNodeSettingsCLN({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.Settings.enableOffers
// }
// }));
// this.store.dispatch(setChildNodeSettingsECL({
// payload: {
// userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion,
// unannouncedChannels: this.selNode.unannouncedChannels, lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.Settings.swapServerUrl, boltzServerUrl: this.serverUrl, enableOffers: this.selNode.Settings.enableOffers
// }
// }));
}
onReset() {
this.selNode = JSON.parse(JSON.stringify(this.previousSelNode));
this.serverUrl = this.selNode.settings.boltzServerUrl || '';
this.macaroonPath = this.selNode.authentication.boltzMacaroonPath;
this.serverUrl = this.selNode.Settings.boltzServerUrl || '';
this.macaroonPath = this.selNode.Authentication.boltzMacaroonPath;
this.enableBoltz = !!(this.serverUrl && this.serverUrl.trim() !== '');
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save