Removed `removeMsat` and lookup page

clnrest-migration
ShahanaFarooqui 7 months ago
parent 8e9e6fabe0
commit e1cc56b8d5

@ -15,29 +15,7 @@ export const listPeerChannels = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels }); 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) => { return Promise.all(body.channels?.map((channel) => {
channel.to_us_msat = common.removeMSat(channel.to_us_msat);
channel.total_msat = common.removeMSat(channel.total_msat);
channel.to_them_msat = channel.total_msat - channel.to_us_msat; channel.to_them_msat = channel.total_msat - channel.to_us_msat;
channel.last_tx_fee_msat = common.removeMSat(channel.last_tx_fee_msat);
channel.funding.local_funds_msat = common.removeMSat(channel.funding.local_funds_msat);
channel.funding.remote_funds_msat = common.removeMSat(channel.funding.remote_funds_msat);
channel.funding.pushed_msat = common.removeMSat(channel.funding.pushed_msat);
channel.min_to_us_msat = common.removeMSat(channel.min_to_us_msat);
channel.max_to_us_msat = common.removeMSat(channel.max);
channel.fee_base_msat = common.removeMSat(channel.fee_base_msat);
channel.dust_limit_msat = common.removeMSat(channel.dust_limit_msat);
channel.max_total_htlc_in_msat = common.removeMSat(channel.max_total_htlc_in_msat);
channel.their_reserve_msat = common.removeMSat(channel.their_reserve_msat);
channel.our_reserve_msat = common.removeMSat(channel.our_reserve_msat);
channel.spendable_msat = common.removeMSat(channel.spendable_msat);
channel.receivable_msat = common.removeMSat(channel.receivable_msat);
channel.minimum_htlc_in_msat = common.removeMSat(channel.minimum_htlc_in_msat);
channel.minimum_htlc_out_msat = common.removeMSat(channel.minimum_htlc_out_msat);
channel.maximum_htlc_out_msat = common.removeMSat(channel.maximum_htlc_out_msat);
channel.in_offered_msat = common.removeMSat(channel.in_offered_msat);
channel.in_fulfilled_msat = common.removeMSat(channel.in_fulfilled_msat);
channel.out_offered_msat = common.removeMSat(channel.out_offered_msat);
channel.out_fulfilled_msat = common.removeMSat(channel.out_fulfilled_msat);
channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - (channel.total_msat - channel.to_us_msat)) / channel.total_msat)).toFixed(3); channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - (channel.total_msat - channel.to_us_msat)) / channel.total_msat)).toFixed(3);
return getAlias(req.session.selectedNode, channel, 'peer_id'); return getAlias(req.session.selectedNode, channel, 'peer_id');
})).then((values) => { })).then((values) => {
@ -112,11 +90,6 @@ export const listForwards = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.body.status, data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.body.status, data: body });
body.forwards = !body.forwards ? [] : (req.body.status === 'failed' || req.body.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse(); body.forwards = !body.forwards ? [] : (req.body.status === 'failed' || req.body.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse();
body.forwards.forEach((forward) => {
forward.in_msat = common.removeMSat(forward.in_msat);
forward.out_msat = common.removeMSat(forward.out_msat);
forward.fee_msat = common.removeMSat(forward.fee_msat);
});
res.status(200).json(body.forwards); res.status(200).json(body.forwards);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode); const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode);
@ -134,13 +107,6 @@ export const funderUpdatePolicy = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Funder Policy Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Funder Policy Received', data: body });
body.min_their_funding_msat = common.removeMSat(body.min_their_funding_msat);
body.max_their_funding_msat = common.removeMSat(body.max_their_funding_msat);
body.per_channel_min_msat = common.removeMSat(body.per_channel_min_msat);
body.per_channel_max_msat = common.removeMSat(body.per_channel_max_msat);
body.reserve_tank_msat = common.removeMSat(body.reserve_tank_msat);
body.channel_fee_max_base_msat = common.removeMSat(body.channel_fee_max_base_msat);
body.lease_fee_base_msat = common.removeMSat(body.lease_fee_base_msat);
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Channels', 'Funder Policy Error', req.session.selectedNode); const err = common.handleError(errRes, 'Channels', 'Funder Policy Error', req.session.selectedNode);

@ -48,7 +48,6 @@ export const getInfo = (req, res, next) => {
body.uris.push(body.id + '@' + addr.address + ':' + addr.port); body.uris.push(body.id + '@' + addr.address + ':' + addr.port);
}); });
} }
body.fees_collected_msat = common.removeMSat(body.fees_collected_msat);
req.session.selectedNode.ln_version = body.version || ''; req.session.selectedNode.ln_version = body.version || '';
req.session.selectedNode.api_version = body.api_version || ''; req.session.selectedNode.api_version = body.api_version || '';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Connecting to the Core Lightning\'s Websocket Server.' }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Connecting to the Core Lightning\'s Websocket Server.' });

@ -31,10 +31,6 @@ export const listInvoices = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
body.invoices.forEach((invoice) => {
invoice.amount_msat = common.removeMSat(invoice.amount_msat);
invoice.amount_received_msat = common.removeMSat(invoice.amount_received_msat);
});
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Invoice', 'List Invoices Error', req.session.selectedNode); const err = common.handleError(errRes, 'Invoice', 'List Invoices Error', req.session.selectedNode);

@ -14,7 +14,10 @@ export const getRoute = (req, res, next) => {
options.body = req.body; options.body = req.body;
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body });
res.status(200).json({ routes: body }); return Promise.all(body.route?.map((rt) => getAlias(req.session.selectedNode, rt, 'id'))).then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Network Routes with Alias Received', data: body });
res.status(200).json(body || []);
});
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Network', 'Query Routes Error', req.session.selectedNode); const err = common.handleError(errRes, 'Network', 'Query Routes Error', req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.message, error: err.error }); return res.status(err.statusCode).json({ message: err.message, error: err.error });
@ -59,19 +62,13 @@ export const listNodes = (req, res, next) => {
return res.status(options.statusCode).json({ message: options.message, error: options.error }); return res.status(options.statusCode).json({ message: options.message, error: options.error });
} }
options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes'; options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body });
let response = body.nodes; let response = body.nodes;
if (req.body.liquidity_ads) { if (req.body.liquidity_ads) {
response = body.nodes.filter((node) => { response = body.nodes.filter((node) => ((node.option_will_fund) ? node : null));
if (node.option_will_fund) {
node.option_will_fund.lease_fee_base_msat = common.removeMSat(node.option_will_fund.lease_fee_base_msat);
node.option_will_fund.channel_fee_max_base_msat = common.removeMSat(node.option_will_fund.channel_fee_max_base_msat);
return node;
}
return null;
});
} }
res.status(200).json(response); res.status(200).json(response);
}).catch((errRes) => { }).catch((errRes) => {

@ -49,8 +49,6 @@ export const getUTXOs = (req, res, next) => {
// Local Remote Balance Calculation // Local Remote Balance Calculation
let lrBalance = { localBalance: 0, remoteBalance: 0, inactiveBalance: 0, pendingBalance: 0 }; let lrBalance = { localBalance: 0, remoteBalance: 0, inactiveBalance: 0, pendingBalance: 0 };
body.channels.forEach((channel) => { body.channels.forEach((channel) => {
channel.our_amount_msat = common.removeMSat(channel.our_amount_msat);
channel.amount_msat = common.removeMSat(channel.amount_msat);
if ((channel.state === 'CHANNELD_NORMAL') && channel.connected === true) { if ((channel.state === 'CHANNELD_NORMAL') && channel.connected === true) {
lrBalance.localBalance = lrBalance.localBalance + channel.our_amount_msat; lrBalance.localBalance = lrBalance.localBalance + channel.our_amount_msat;
lrBalance.remoteBalance = lrBalance.remoteBalance + (channel.amount_msat - channel.our_amount_msat); lrBalance.remoteBalance = lrBalance.remoteBalance + (channel.amount_msat - channel.our_amount_msat);
@ -72,7 +70,6 @@ export const getUTXOs = (req, res, next) => {
// Onchain Balance Calculation // Onchain Balance Calculation
let onchainBalance = { totalBalance: 0, confBalance: 0, unconfBalance: 0 }; let onchainBalance = { totalBalance: 0, confBalance: 0, unconfBalance: 0 };
body.outputs.forEach((output) => { body.outputs.forEach((output) => {
output.amount_msat = common.removeMSat(output.amount_msat);
if (output.status === 'confirmed') { if (output.status === 'confirmed') {
onchainBalance.confBalance = onchainBalance.confBalance + output.amount_msat; onchainBalance.confBalance = onchainBalance.confBalance + output.amount_msat;
} }

@ -34,8 +34,6 @@ function paymentReducer(accumulator, currentPayment) {
} }
function summaryReducer(accumulator, mpp) { function summaryReducer(accumulator, mpp) {
if (mpp.status === 'complete') { if (mpp.status === 'complete') {
mpp.amount_msat = common.removeMSat(mpp.amount_msat);
mpp.amount_sent_msat = common.removeMSat(mpp.amount_sent_msat);
accumulator.amount_msat = accumulator.amount_msat + mpp.amount_msat; accumulator.amount_msat = accumulator.amount_msat + mpp.amount_msat;
accumulator.amount_sent_msat = accumulator.amount_sent_msat + mpp.amount_sent_msat; accumulator.amount_sent_msat = accumulator.amount_sent_msat + mpp.amount_sent_msat;
accumulator.status = mpp.status; accumulator.status = mpp.status;
@ -58,8 +56,6 @@ function groupBy(payments) {
temp.is_group = false; temp.is_group = false;
temp.is_expanded = false; temp.is_expanded = false;
temp.total_parts = 1; temp.total_parts = 1;
temp.amount_msat = common.removeMSat(temp.amount_msat);
temp.amount_sent_msat = common.removeMSat(temp.amount_sent_msat);
delete temp.partid; delete temp.partid;
} }
else { else {

@ -15,33 +15,7 @@ export const getPeers = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers; const peers = !body.peers ? [] : body.peers;
return Promise.all(peers?.map((peer) => { return Promise.all(peers?.map((peer) => getAlias(req.session.selectedNode, peer, 'id'))).then((values) => {
peer.channels.forEach((channel) => {
channel.to_us_msat = common.removeMSat(channel.to_us_msat);
channel.total_msat = common.removeMSat(channel.total_msat);
channel.last_tx_fee_msat = common.removeMSat(channel.last_tx_fee_msat);
channel.funding.local_funds_msat = common.removeMSat(channel.funding.local_funds_msat);
channel.funding.remote_funds_msat = common.removeMSat(channel.funding.remote_funds_msat);
channel.funding.pushed_msat = common.removeMSat(channel.funding.pushed_msat);
channel.min_to_us_msat = common.removeMSat(channel.min_to_us_msat);
channel.max_to_us_msat = common.removeMSat(channel.max);
channel.fee_base_msat = common.removeMSat(channel.fee_base_msat);
channel.dust_limit_msat = common.removeMSat(channel.dust_limit_msat);
channel.max_total_htlc_in_msat = common.removeMSat(channel.max_total_htlc_in_msat);
channel.their_reserve_msat = common.removeMSat(channel.their_reserve_msat);
channel.our_reserve_msat = common.removeMSat(channel.our_reserve_msat);
channel.spendable_msat = common.removeMSat(channel.spendable_msat);
channel.receivable_msat = common.removeMSat(channel.receivable_msat);
channel.minimum_htlc_in_msat = common.removeMSat(channel.minimum_htlc_in_msat);
channel.minimum_htlc_out_msat = common.removeMSat(channel.minimum_htlc_out_msat);
channel.maximum_htlc_out_msat = common.removeMSat(channel.maximum_htlc_out_msat);
channel.in_offered_msat = common.removeMSat(channel.in_offered_msat);
channel.in_fulfilled_msat = common.removeMSat(channel.in_fulfilled_msat);
channel.out_offered_msat = common.removeMSat(channel.out_offered_msat);
channel.out_fulfilled_msat = common.removeMSat(channel.out_fulfilled_msat);
});
return getAlias(req.session.selectedNode, peer, 'id');
})).then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Sorted Peers List Received', data: body.peers }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Sorted Peers List Received', data: body.peers });
res.status(200).json(body.peers || []); res.status(200).json(body.peers || []);
}); });

@ -14,20 +14,6 @@ export const decodePayment = (req, res, next) => {
options.body = req.body; options.body = req.body;
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
body.amount_msat = common.removeMSat(body.amount_msat);
body.invreq_amount_msat = common.removeMSat(body.invreq_amount_msat);
body.offer_amount_msat = common.removeMSat(body.offer_amount_msat);
body.invoice_amount_msat = common.removeMSat(body.invoice_amount_msat);
body.invoice_paths?.forEach((path) => {
if (path.payinfo && path.payinfo.fee_base_msat) {
path.payinfo.fee_base_msat = common.removeMSat(path.payinfo.fee_base_msat);
}
});
body.routes?.forEach((route) => {
route.hops.forEach((hop) => {
hop.fee_base_msat = common.removeMSat(hop.fee_base_msat);
});
});
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode); const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode);

@ -570,7 +570,6 @@ export class CommonService {
const dataStr = foundDataLine ? foundDataLine.substring((foundDataLine.indexOf(search_string)) + search_string.length) : '{}'; const dataStr = foundDataLine ? foundDataLine.substring((foundDataLine.indexOf(search_string)) + search_string.length) : '{}';
return JSON.parse(dataStr); return JSON.parse(dataStr);
}; };
this.removeMSat = (value) => ((value && typeof value === 'string' && value.includes('msat')) ? +value.replace('msat', '') : value ? value : 0);
} }
} }
export const Common = new CommonService(); export const Common = new CommonService();

@ -15,29 +15,7 @@ export const listPeerChannels = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels }); 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) => { return Promise.all(body.channels?.map((channel) => {
channel.to_us_msat = common.removeMSat(channel.to_us_msat);
channel.total_msat = common.removeMSat(channel.total_msat);
channel.to_them_msat = channel.total_msat - channel.to_us_msat; channel.to_them_msat = channel.total_msat - channel.to_us_msat;
channel.last_tx_fee_msat = common.removeMSat(channel.last_tx_fee_msat);
channel.funding.local_funds_msat = common.removeMSat(channel.funding.local_funds_msat);
channel.funding.remote_funds_msat = common.removeMSat(channel.funding.remote_funds_msat);
channel.funding.pushed_msat = common.removeMSat(channel.funding.pushed_msat);
channel.min_to_us_msat = common.removeMSat(channel.min_to_us_msat);
channel.max_to_us_msat = common.removeMSat(channel.max);
channel.fee_base_msat = common.removeMSat(channel.fee_base_msat);
channel.dust_limit_msat = common.removeMSat(channel.dust_limit_msat);
channel.max_total_htlc_in_msat = common.removeMSat(channel.max_total_htlc_in_msat);
channel.their_reserve_msat = common.removeMSat(channel.their_reserve_msat);
channel.our_reserve_msat = common.removeMSat(channel.our_reserve_msat);
channel.spendable_msat = common.removeMSat(channel.spendable_msat);
channel.receivable_msat = common.removeMSat(channel.receivable_msat);
channel.minimum_htlc_in_msat = common.removeMSat(channel.minimum_htlc_in_msat);
channel.minimum_htlc_out_msat = common.removeMSat(channel.minimum_htlc_out_msat);
channel.maximum_htlc_out_msat = common.removeMSat(channel.maximum_htlc_out_msat);
channel.in_offered_msat = common.removeMSat(channel.in_offered_msat);
channel.in_fulfilled_msat = common.removeMSat(channel.in_fulfilled_msat);
channel.out_offered_msat = common.removeMSat(channel.out_offered_msat);
channel.out_fulfilled_msat = common.removeMSat(channel.out_fulfilled_msat);
channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - (channel.total_msat - channel.to_us_msat)) / channel.total_msat)).toFixed(3); channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - (channel.total_msat - channel.to_us_msat)) / channel.total_msat)).toFixed(3);
return getAlias(req.session.selectedNode, channel, 'peer_id'); return getAlias(req.session.selectedNode, channel, 'peer_id');
})).then((values) => { })).then((values) => {
@ -108,11 +86,6 @@ export const listForwards = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.body.status, data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.body.status, data: body });
body.forwards = !body.forwards ? [] : (req.body.status === 'failed' || req.body.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse(); body.forwards = !body.forwards ? [] : (req.body.status === 'failed' || req.body.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse();
body.forwards.forEach((forward) => {
forward.in_msat = common.removeMSat(forward.in_msat);
forward.out_msat = common.removeMSat(forward.out_msat);
forward.fee_msat = common.removeMSat(forward.fee_msat);
});
res.status(200).json(body.forwards); res.status(200).json(body.forwards);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode); const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode);
@ -129,13 +102,6 @@ export const funderUpdatePolicy = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Funder Update Body', data: options.body });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Funder Policy Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Funder Policy Received', data: body });
body.min_their_funding_msat = common.removeMSat(body.min_their_funding_msat);
body.max_their_funding_msat = common.removeMSat(body.max_their_funding_msat);
body.per_channel_min_msat = common.removeMSat(body.per_channel_min_msat);
body.per_channel_max_msat = common.removeMSat(body.per_channel_max_msat);
body.reserve_tank_msat = common.removeMSat(body.reserve_tank_msat);
body.channel_fee_max_base_msat = common.removeMSat(body.channel_fee_max_base_msat);
body.lease_fee_base_msat = common.removeMSat(body.lease_fee_base_msat);
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Channels', 'Funder Policy Error', req.session.selectedNode); const err = common.handleError(errRes, 'Channels', 'Funder Policy Error', req.session.selectedNode);

@ -45,7 +45,6 @@ export const getInfo = (req, res, next) => {
body.uris.push(body.id + '@' + addr.address + ':' + addr.port); body.uris.push(body.id + '@' + addr.address + ':' + addr.port);
}); });
} }
body.fees_collected_msat = common.removeMSat(body.fees_collected_msat);
req.session.selectedNode.ln_version = body.version || ''; req.session.selectedNode.ln_version = body.version || '';
req.session.selectedNode.api_version = body.api_version || ''; req.session.selectedNode.api_version = body.api_version || '';
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Connecting to the Core Lightning\'s Websocket Server.' }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'GetInfo', msg: 'Connecting to the Core Lightning\'s Websocket Server.' });

@ -29,10 +29,6 @@ export const listInvoices = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List URL', data: options.url });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body });
body.invoices.forEach((invoice) => {
invoice.amount_msat = common.removeMSat(invoice.amount_msat);
invoice.amount_received_msat = common.removeMSat(invoice.amount_received_msat);
});
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Invoice', 'List Invoices Error', req.session.selectedNode); const err = common.handleError(errRes, 'Invoice', 'List Invoices Error', req.session.selectedNode);

@ -15,7 +15,10 @@ export const getRoute = (req, res, next) => {
options.body = req.body; options.body = req.body;
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'Network Routes Received', data: body });
res.status(200).json({ routes: body }); return Promise.all(body.route?.map((rt) => getAlias(req.session.selectedNode, rt, 'id'))).then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Network Routes with Alias Received', data: body });
res.status(200).json(body || []);
});
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Network', 'Query Routes Error', req.session.selectedNode); const err = common.handleError(errRes, 'Network', 'Query Routes Error', req.session.selectedNode);
return res.status(err.statusCode).json({ message: err.message, error: err.error }); return res.status(err.statusCode).json({ message: err.message, error: err.error });
@ -57,19 +60,13 @@ export const listNodes = (req, res, next) => {
options = common.getOptions(req); options = common.getOptions(req);
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); } if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes'; options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes';
options.body = req.body;
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body });
let response = body.nodes; let response = body.nodes;
if (req.body.liquidity_ads) { if (req.body.liquidity_ads) {
response = body.nodes.filter((node) => { response = body.nodes.filter((node) => ((node.option_will_fund) ? node : null));
if (node.option_will_fund) {
node.option_will_fund.lease_fee_base_msat = common.removeMSat(node.option_will_fund.lease_fee_base_msat);
node.option_will_fund.channel_fee_max_base_msat = common.removeMSat(node.option_will_fund.channel_fee_max_base_msat);
return node;
}
return null;
});
} }
res.status(200).json(response); res.status(200).json(response);
}).catch((errRes) => { }).catch((errRes) => {

@ -46,8 +46,6 @@ export const getUTXOs = (req, res, next) => {
// Local Remote Balance Calculation // Local Remote Balance Calculation
let lrBalance = { localBalance: 0, remoteBalance: 0, inactiveBalance: 0, pendingBalance: 0 }; let lrBalance = { localBalance: 0, remoteBalance: 0, inactiveBalance: 0, pendingBalance: 0 };
body.channels.forEach((channel) => { body.channels.forEach((channel) => {
channel.our_amount_msat = common.removeMSat(channel.our_amount_msat);
channel.amount_msat = common.removeMSat(channel.amount_msat);
if ((channel.state === 'CHANNELD_NORMAL') && channel.connected === true) { if ((channel.state === 'CHANNELD_NORMAL') && channel.connected === true) {
lrBalance.localBalance = lrBalance.localBalance + channel.our_amount_msat; lrBalance.localBalance = lrBalance.localBalance + channel.our_amount_msat;
lrBalance.remoteBalance = lrBalance.remoteBalance + (channel.amount_msat - channel.our_amount_msat); lrBalance.remoteBalance = lrBalance.remoteBalance + (channel.amount_msat - channel.our_amount_msat);
@ -67,7 +65,6 @@ export const getUTXOs = (req, res, next) => {
// Onchain Balance Calculation // Onchain Balance Calculation
let onchainBalance = { totalBalance: 0, confBalance: 0, unconfBalance: 0 }; let onchainBalance = { totalBalance: 0, confBalance: 0, unconfBalance: 0 };
body.outputs.forEach((output) => { body.outputs.forEach((output) => {
output.amount_msat = common.removeMSat(output.amount_msat);
if (output.status === 'confirmed') { if (output.status === 'confirmed') {
onchainBalance.confBalance = onchainBalance.confBalance + output.amount_msat; onchainBalance.confBalance = onchainBalance.confBalance + output.amount_msat;
} else if (output.status === 'unconfirmed') { } else if (output.status === 'unconfirmed') {

@ -36,8 +36,6 @@ function paymentReducer(accumulator, currentPayment) {
function summaryReducer(accumulator, mpp) { function summaryReducer(accumulator, mpp) {
if (mpp.status === 'complete') { if (mpp.status === 'complete') {
mpp.amount_msat = common.removeMSat(mpp.amount_msat);
mpp.amount_sent_msat = common.removeMSat(mpp.amount_sent_msat);
accumulator.amount_msat = accumulator.amount_msat + mpp.amount_msat; accumulator.amount_msat = accumulator.amount_msat + mpp.amount_msat;
accumulator.amount_sent_msat = accumulator.amount_sent_msat + mpp.amount_sent_msat; accumulator.amount_sent_msat = accumulator.amount_sent_msat + mpp.amount_sent_msat;
accumulator.status = mpp.status; accumulator.status = mpp.status;
@ -57,8 +55,6 @@ function groupBy(payments) {
temp.is_group = false; temp.is_group = false;
temp.is_expanded = false; temp.is_expanded = false;
temp.total_parts = 1; temp.total_parts = 1;
temp.amount_msat = common.removeMSat(temp.amount_msat);
temp.amount_sent_msat = common.removeMSat(temp.amount_sent_msat);
delete temp.partid; delete temp.partid;
} else { } else {
const paySummary = curr?.reduce(summaryReducer, { amount_msat: 0, amount_sent_msat: 0, status: (curr[0] && curr[0].status) ? curr[0].status : 'failed' }); const paySummary = curr?.reduce(summaryReducer, { amount_msat: 0, amount_sent_msat: 0, status: (curr[0] && curr[0].status) ? curr[0].status : 'failed' });

@ -15,33 +15,7 @@ export const getPeers = (req, res, next) => {
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Peers', msg: 'Peers List Received', data: body });
const peers = !body.peers ? [] : body.peers; const peers = !body.peers ? [] : body.peers;
return Promise.all(peers?.map((peer) => { return Promise.all(peers?.map((peer) => getAlias(req.session.selectedNode, peer, 'id'))).then((values) => {
peer.channels.forEach((channel) => {
channel.to_us_msat = common.removeMSat(channel.to_us_msat);
channel.total_msat = common.removeMSat(channel.total_msat);
channel.last_tx_fee_msat = common.removeMSat(channel.last_tx_fee_msat);
channel.funding.local_funds_msat = common.removeMSat(channel.funding.local_funds_msat);
channel.funding.remote_funds_msat = common.removeMSat(channel.funding.remote_funds_msat);
channel.funding.pushed_msat = common.removeMSat(channel.funding.pushed_msat);
channel.min_to_us_msat = common.removeMSat(channel.min_to_us_msat);
channel.max_to_us_msat = common.removeMSat(channel.max);
channel.fee_base_msat = common.removeMSat(channel.fee_base_msat);
channel.dust_limit_msat = common.removeMSat(channel.dust_limit_msat);
channel.max_total_htlc_in_msat = common.removeMSat(channel.max_total_htlc_in_msat);
channel.their_reserve_msat = common.removeMSat(channel.their_reserve_msat);
channel.our_reserve_msat = common.removeMSat(channel.our_reserve_msat);
channel.spendable_msat = common.removeMSat(channel.spendable_msat);
channel.receivable_msat = common.removeMSat(channel.receivable_msat);
channel.minimum_htlc_in_msat = common.removeMSat(channel.minimum_htlc_in_msat);
channel.minimum_htlc_out_msat = common.removeMSat(channel.minimum_htlc_out_msat);
channel.maximum_htlc_out_msat = common.removeMSat(channel.maximum_htlc_out_msat);
channel.in_offered_msat = common.removeMSat(channel.in_offered_msat);
channel.in_fulfilled_msat = common.removeMSat(channel.in_fulfilled_msat);
channel.out_offered_msat = common.removeMSat(channel.out_offered_msat);
channel.out_fulfilled_msat = common.removeMSat(channel.out_fulfilled_msat);
});
return getAlias(req.session.selectedNode, peer, 'id');
})).then((values) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Sorted Peers List Received', data: body.peers }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Sorted Peers List Received', data: body.peers });
res.status(200).json(body.peers || []); res.status(200).json(body.peers || []);
}); });

@ -14,20 +14,6 @@ export const decodePayment = (req, res, next) => {
options.body = req.body; options.body = req.body;
request.post(options).then((body) => { request.post(options).then((body) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded', data: body });
body.amount_msat = common.removeMSat(body.amount_msat);
body.invreq_amount_msat = common.removeMSat(body.invreq_amount_msat);
body.offer_amount_msat = common.removeMSat(body.offer_amount_msat);
body.invoice_amount_msat = common.removeMSat(body.invoice_amount_msat);
body.invoice_paths?.forEach((path) => {
if (path.payinfo && path.payinfo.fee_base_msat) {
path.payinfo.fee_base_msat = common.removeMSat(path.payinfo.fee_base_msat);
}
});
body.routes?.forEach((route) => {
route.hops.forEach((hop) => {
hop.fee_base_msat = common.removeMSat(hop.fee_base_msat);
});
});
res.status(200).json(body); res.status(200).json(body);
}).catch((errRes) => { }).catch((errRes) => {
const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode); const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode);

@ -537,8 +537,6 @@ export class CommonService {
return JSON.parse(dataStr); return JSON.parse(dataStr);
}; };
public removeMSat = (value) => ((value && typeof value === 'string' && value.includes('msat')) ? +value.replace('msat', '') : value ? value : 0);
} }
export const Common = new CommonService(); export const Common = new CommonService();

@ -54,7 +54,7 @@ export class CLNLookupsComponent implements OnInit, OnDestroy {
this.nodeLookupValue = typeof resLookup.payload[0] !== 'object' ? { nodeid: '' } : JSON.parse(JSON.stringify(resLookup.payload[0])); this.nodeLookupValue = typeof resLookup.payload[0] !== 'object' ? { nodeid: '' } : JSON.parse(JSON.stringify(resLookup.payload[0]));
break; break;
case 1: case 1:
this.channelLookupValue = typeof resLookup.payload[0] !== 'object' ? [] : JSON.parse(JSON.stringify(resLookup.payload)); this.channelLookupValue = typeof resLookup.payload.channels !== 'object' ? [] : JSON.parse(JSON.stringify(resLookup.payload.channels));
break; break;
default: default:
break; break;

@ -57,10 +57,9 @@ export class CLNQueryRoutesComponent implements OnInit, OnDestroy {
}); });
this.clnEffects.setQueryRoutesCL.pipe(takeUntil(this.unSubs[1])).subscribe((queryRoute) => { this.clnEffects.setQueryRoutesCL.pipe(takeUntil(this.unSubs[1])).subscribe((queryRoute) => {
this.qrHops.data = []; this.qrHops.data = [];
if (queryRoute.routes && queryRoute.routes.length && queryRoute.routes.length > 0) { if (queryRoute.route && queryRoute.route.length && queryRoute.route.length > 0) {
this.flgLoading[0] = false; this.flgLoading[0] = false;
this.qrHops = new MatTableDataSource<Routes>([...queryRoute.routes]); this.qrHops = new MatTableDataSource<Routes>([...queryRoute.route]);
this.qrHops.data = queryRoute.routes;
} else { } else {
this.flgLoading[0] = 'error'; this.flgLoading[0] = 'error';
} }

@ -204,7 +204,7 @@ export class CLNEffects implements OnDestroy {
mergeMap((action: { type: string, payload: { id: string } }) => { mergeMap((action: { type: string, payload: { id: string } }) => {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.CONNECT_PEER })); this.store.dispatch(openSpinner({ payload: UI_MESSAGES.CONNECT_PEER }));
this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'SaveNewPeer', status: APICallStatusEnum.INITIATED } })); this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'SaveNewPeer', status: APICallStatusEnum.INITIATED } }));
return this.httpClient.post<Peer[]>(this.CHILD_API_URL + API_END_POINTS.PEERS_API, action.payload.id). return this.httpClient.post<Peer[]>(this.CHILD_API_URL + API_END_POINTS.PEERS_API, { id: action.payload.id }).
pipe( pipe(
map((postRes: Peer[]) => { map((postRes: Peer[]) => {
this.logger.info(postRes); this.logger.info(postRes);
@ -460,7 +460,7 @@ export class CLNEffects implements OnDestroy {
ofType(CLNActions.GET_QUERY_ROUTES_CLN), ofType(CLNActions.GET_QUERY_ROUTES_CLN),
mergeMap((action: { type: string, payload: GetQueryRoutes }) => { mergeMap((action: { type: string, payload: GetQueryRoutes }) => {
this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'GetQueryRoutes', status: APICallStatusEnum.INITIATED } })); this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'GetQueryRoutes', status: APICallStatusEnum.INITIATED } }));
return this.httpClient.post(this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/getRoute/', { id: action.payload.destPubkey, amount_msat: action.payload.amount, riskfactor: 0 }). return this.httpClient.post(this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/getRoute', { id: action.payload.destPubkey, amount_msat: action.payload.amount, riskfactor: 0 }).
pipe( pipe(
map((qrRes: any) => { map((qrRes: any) => {
this.logger.info(qrRes); this.logger.info(qrRes);
@ -471,8 +471,8 @@ export class CLNEffects implements OnDestroy {
}; };
}), }),
catchError((err: any) => { catchError((err: any) => {
this.store.dispatch(setQueryRoutes({ payload: { routes: [] } })); this.store.dispatch(setQueryRoutes({ payload: { route: [] } }));
this.handleErrorWithAlert('GetQueryRoutes', UI_MESSAGES.NO_SPINNER, 'Get Query Routes Failed', this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/getRoute/' + action.payload.destPubkey + '/' + action.payload.amount, err); this.handleErrorWithAlert('GetQueryRoutes', UI_MESSAGES.NO_SPINNER, 'Get Query Routes Failed', this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/getRoute', err);
return of({ type: RTLActions.VOID }); return of({ type: RTLActions.VOID });
}) })
); );
@ -492,7 +492,7 @@ export class CLNEffects implements OnDestroy {
mergeMap((action: { type: string, payload: string }) => { mergeMap((action: { type: string, payload: string }) => {
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.SEARCHING_NODE })); this.store.dispatch(openSpinner({ payload: UI_MESSAGES.SEARCHING_NODE }));
this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'Lookup', status: APICallStatusEnum.INITIATED } })); this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'Lookup', status: APICallStatusEnum.INITIATED } }));
return this.httpClient.get(this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/listNode/' + action.payload). return this.httpClient.post(this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/listNodes', { id: action.payload }).
pipe( pipe(
map((resPeer) => { map((resPeer) => {
this.logger.info(resPeer); this.logger.info(resPeer);
@ -504,7 +504,7 @@ export class CLNEffects implements OnDestroy {
}; };
}), }),
catchError((err: any) => { catchError((err: any) => {
this.handleErrorWithAlert('Lookup', UI_MESSAGES.SEARCHING_NODE, 'Peer Lookup Failed', this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/listNode/' + action.payload, err); this.handleErrorWithAlert('Lookup', UI_MESSAGES.SEARCHING_NODE, 'Peer Lookup Failed', this.CHILD_API_URL + API_END_POINTS.NETWORK_API + '/listNodes/' + action.payload, err);
return of({ type: RTLActions.VOID }); return of({ type: RTLActions.VOID });
}) })
); );

@ -280,7 +280,7 @@ export interface Routes {
} }
export interface QueryRoutes { export interface QueryRoutes {
routes: Routes[]; route: Routes[];
} }
export interface ChannelHTLC { export interface ChannelHTLC {

Loading…
Cancel
Save