mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2024-11-19 01:40:29 +01:00
Removed query and move msat conversion
This commit is contained in:
parent
30a4f7f81e
commit
1b23c21374
@ -108,9 +108,15 @@ export const listForwards = (req, res, next) => {
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listforwards';
|
||||
options.body = req.body;
|
||||
request.get(options).then((body) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.query.status, data: body });
|
||||
res.status(200).json(!body.forwards ? [] : (req.query.status === 'failed' || req.query.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse());
|
||||
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 });
|
||||
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);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -63,13 +63,14 @@ export const listNodes = (req, res, next) => {
|
||||
request.post(options).then((body) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body });
|
||||
let response = body.nodes;
|
||||
if (req.query.liquidity_ads && typeof req.query.liquidity_ads === 'string' && req.query.liquidity_ads.toLowerCase() === 'yes') {
|
||||
if (req.body.liquidity_ads) {
|
||||
response = body.nodes.filter((node) => {
|
||||
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 node;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
res.status(200).json(response);
|
||||
|
@ -34,7 +34,6 @@ export const listOffers = (req, res, next) => {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listoffers';
|
||||
options.body = { offer_id: (req.query.offer_id) ? req.query.offer_id : null, active_only: !(req.query.active_only === '0' || req.query.active_only === 'false' || !req.query.active_only) };
|
||||
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 });
|
||||
|
@ -11,7 +11,7 @@ export const getNewAddress = (req, res, next) => {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/newaddr';
|
||||
options.body = { addresstype: req.query.type };
|
||||
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 });
|
||||
res.status(200).json(body);
|
||||
|
@ -86,12 +86,6 @@ export const listPayments = (req, res, next) => {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listsendpays';
|
||||
const { invoice, payment_hash, status } = req.query;
|
||||
options.body = {
|
||||
...(invoice && { bolt11: invoice }),
|
||||
...(payment_hash && { payment_hash }),
|
||||
...(status && { status })
|
||||
};
|
||||
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) : [];
|
||||
|
@ -4,37 +4,6 @@ import { Common } from '../../utils/common.js';
|
||||
let options = null;
|
||||
const logger = Logger;
|
||||
const common = Common;
|
||||
export const decodePaymentFromPaymentRequest = (selNode, payment) => {
|
||||
options.url = selNode.ln_server_url + '/v1/decode';
|
||||
options.body = { string: payment };
|
||||
return request.post(options).then((res) => {
|
||||
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: res });
|
||||
return res;
|
||||
}).catch((err) => { });
|
||||
};
|
||||
export const decodePayments = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payments List..' });
|
||||
options = common.getOptions(req);
|
||||
if (options.error) {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
if (req.body.payments) {
|
||||
const paymentsArr = req.body.payments.split(',');
|
||||
return Promise.all(paymentsArr?.map((payment) => decodePaymentFromPaymentRequest(req.session.selectedNode, payment))).
|
||||
then((values) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment List Decoded', data: values });
|
||||
res.status(200).json(values);
|
||||
}).
|
||||
catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'Decode Payments Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
}
|
||||
else {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Empty Payment List Decoded' });
|
||||
return res.status(200).json([]);
|
||||
}
|
||||
};
|
||||
export const decodePayment = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..' });
|
||||
options = common.getOptions(req);
|
||||
@ -45,6 +14,20 @@ export const decodePayment = (req, res, next) => {
|
||||
options.body = req.body;
|
||||
request.post(options).then((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);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode);
|
||||
|
@ -3,7 +3,7 @@ const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getRoute, listChannels, feeRates, listNodes } from '../../controllers/cln/network.js';
|
||||
const router = Router();
|
||||
router.get('/listNodes', isAuthenticated, listNodes);
|
||||
router.post('/listNodes', isAuthenticated, listNodes);
|
||||
router.post('/getRoute', isAuthenticated, getRoute);
|
||||
router.post('/feeRates', isAuthenticated, feeRates);
|
||||
router.post('/listChannels', isAuthenticated, listChannels);
|
||||
|
@ -3,7 +3,7 @@ const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getNewAddress, onChainWithdraw, getUTXOs } from '../../controllers/cln/onchain.js';
|
||||
const router = Router();
|
||||
router.get('/', isAuthenticated, getNewAddress);
|
||||
router.post('/', isAuthenticated, onChainWithdraw);
|
||||
router.post('/newaddr', isAuthenticated, getNewAddress);
|
||||
router.get('/utxos/', isAuthenticated, getUTXOs);
|
||||
export default router;
|
||||
|
@ -1,9 +1,8 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { decodePayments, decodePayment, signMessage, verifyMessage, listConfigs } from '../../controllers/cln/utility.js';
|
||||
import { decodePayment, signMessage, verifyMessage, listConfigs } from '../../controllers/cln/utility.js';
|
||||
const router = Router();
|
||||
router.get('/', isAuthenticated, decodePayments);
|
||||
router.post('/decode', isAuthenticated, decodePayment);
|
||||
router.post('/sign', isAuthenticated, signMessage);
|
||||
router.post('/verify', isAuthenticated, verifyMessage);
|
||||
|
File diff suppressed because one or more lines are too long
1
frontend/125.1437bbfbfc0a540b.js
Normal file
1
frontend/125.1437bbfbfc0a540b.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
frontend/main.75f6d7315073697a.js
Normal file
1
frontend/main.75f6d7315073697a.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
(()=>{"use strict";var e,v={},m={};function r(e){var f=m[e];if(void 0!==f)return f.exports;var t=m[e]={id:e,loaded:!1,exports:{}};return v[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}r.m=v,e=[],r.O=(f,t,i,o)=>{if(!t){var a=1/0;for(n=0;n<e.length;n++){for(var[t,i,o]=e[n],s=!0,l=0;l<t.length;l++)(!1&o||a>=o)&&Object.keys(r.O).every(b=>r.O[b](t[l]))?t.splice(l--,1):(s=!1,o<a&&(a=o));if(s){e.splice(n--,1);var d=i();void 0!==d&&(f=d)}}return f}o=o||0;for(var n=e.length;n>0&&e[n-1][2]>o;n--)e[n]=e[n-1];e[n]=[t,i,o]},r.d=(e,f)=>{for(var t in f)r.o(f,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:f[t]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((f,t)=>(r.f[t](e,f),f),[])),r.u=e=>e+"."+{125:"0f4fc2a7a33f89ec",456:"16212571f65d0b5f",570:"a719a189ca60c55b",758:"2801e2da6f8bba94"}[e]+".js",r.miniCssF=e=>{},r.o=(e,f)=>Object.prototype.hasOwnProperty.call(e,f),(()=>{var e={},f="RTLApp:";r.l=(t,i,o,n)=>{if(e[t])e[t].push(i);else{var a,s;if(void 0!==o)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var u=l[d];if(u.getAttribute("src")==t||u.getAttribute("data-webpack")==f+o){a=u;break}}a||(s=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",f+o),a.src=r.tu(t)),e[t]=[i];var c=(g,b)=>{a.onerror=a.onload=null,clearTimeout(p);var h=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach(y=>y(b)),g)return g(b)},p=setTimeout(c.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=c.bind(null,a.onerror),a.onload=c.bind(null,a.onload),s&&document.head.appendChild(a)}}})(),r.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:f=>f},typeof trustedTypes<"u"&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={666:0};r.f.j=(i,o)=>{var n=r.o(e,i)?e[i]:void 0;if(0!==n)if(n)o.push(n[2]);else if(666!=i){var a=new Promise((u,c)=>n=e[i]=[u,c]);o.push(n[2]=a);var s=r.p+r.u(i),l=new Error;r.l(s,u=>{if(r.o(e,i)&&(0!==(n=e[i])&&(e[i]=void 0),n)){var c=u&&("load"===u.type?"missing":u.type),p=u&&u.target&&u.target.src;l.message="Loading chunk "+i+" failed.\n("+c+": "+p+")",l.name="ChunkLoadError",l.type=c,l.request=p,n[1](l)}},"chunk-"+i,i)}else e[i]=0},r.O.j=i=>0===e[i];var f=(i,o)=>{var l,d,[n,a,s]=o,u=0;if(n.some(p=>0!==e[p])){for(l in a)r.o(a,l)&&(r.m[l]=a[l]);if(s)var c=s(r)}for(i&&i(o);u<n.length;u++)r.o(e,d=n[u])&&e[d]&&e[d][0](),e[d]=0;return r.O(c)},t=self.webpackChunkRTLApp=self.webpackChunkRTLApp||[];t.forEach(f.bind(null,0)),t.push=f.bind(null,t.push.bind(t))})()})();
|
||||
(()=>{"use strict";var e,v={},m={};function r(e){var f=m[e];if(void 0!==f)return f.exports;var t=m[e]={id:e,loaded:!1,exports:{}};return v[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}r.m=v,e=[],r.O=(f,t,i,o)=>{if(!t){var a=1/0;for(n=0;n<e.length;n++){for(var[t,i,o]=e[n],s=!0,l=0;l<t.length;l++)(!1&o||a>=o)&&Object.keys(r.O).every(b=>r.O[b](t[l]))?t.splice(l--,1):(s=!1,o<a&&(a=o));if(s){e.splice(n--,1);var d=i();void 0!==d&&(f=d)}}return f}o=o||0;for(var n=e.length;n>0&&e[n-1][2]>o;n--)e[n]=e[n-1];e[n]=[t,i,o]},r.d=(e,f)=>{for(var t in f)r.o(f,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:f[t]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((f,t)=>(r.f[t](e,f),f),[])),r.u=e=>e+"."+{125:"1437bbfbfc0a540b",456:"16212571f65d0b5f",570:"a719a189ca60c55b",758:"2801e2da6f8bba94"}[e]+".js",r.miniCssF=e=>{},r.o=(e,f)=>Object.prototype.hasOwnProperty.call(e,f),(()=>{var e={},f="RTLApp:";r.l=(t,i,o,n)=>{if(e[t])e[t].push(i);else{var a,s;if(void 0!==o)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var u=l[d];if(u.getAttribute("src")==t||u.getAttribute("data-webpack")==f+o){a=u;break}}a||(s=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",f+o),a.src=r.tu(t)),e[t]=[i];var c=(g,b)=>{a.onerror=a.onload=null,clearTimeout(p);var h=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach(y=>y(b)),g)return g(b)},p=setTimeout(c.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=c.bind(null,a.onerror),a.onload=c.bind(null,a.onload),s&&document.head.appendChild(a)}}})(),r.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:f=>f},typeof trustedTypes<"u"&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={666:0};r.f.j=(i,o)=>{var n=r.o(e,i)?e[i]:void 0;if(0!==n)if(n)o.push(n[2]);else if(666!=i){var a=new Promise((u,c)=>n=e[i]=[u,c]);o.push(n[2]=a);var s=r.p+r.u(i),l=new Error;r.l(s,u=>{if(r.o(e,i)&&(0!==(n=e[i])&&(e[i]=void 0),n)){var c=u&&("load"===u.type?"missing":u.type),p=u&&u.target&&u.target.src;l.message="Loading chunk "+i+" failed.\n("+c+": "+p+")",l.name="ChunkLoadError",l.type=c,l.request=p,n[1](l)}},"chunk-"+i,i)}else e[i]=0},r.O.j=i=>0===e[i];var f=(i,o)=>{var l,d,[n,a,s]=o,u=0;if(n.some(p=>0!==e[p])){for(l in a)r.o(a,l)&&(r.m[l]=a[l]);if(s)var c=s(r)}for(i&&i(o);u<n.length;u++)r.o(e,d=n[u])&&e[d]&&e[d][0](),e[d]=0;return r.O(c)},t=self.webpackChunkRTLApp=self.webpackChunkRTLApp||[];t.forEach(f.bind(null,0)),t.push=f.bind(null,t.push.bind(t))})()})();
|
@ -104,9 +104,15 @@ 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.ln_server_url + '/v1/listforwards';
|
||||
options.body = req.body;
|
||||
request.get(options).then((body) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received For Status ' + req.query.status, data: body });
|
||||
res.status(200).json(!body.forwards ? [] : (req.query.status === 'failed' || req.query.status === 'local_failed') ? body.forwards.slice(Math.max(0, body.forwards.length - 1000), Math.max(1000, body.forwards.length)).reverse() : body.forwards.reverse());
|
||||
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 });
|
||||
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);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Forwarding History Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -61,13 +61,14 @@ export const listNodes = (req, res, next) => {
|
||||
request.post(options).then((body) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Network', msg: 'List Nodes Finished', data: body });
|
||||
let response = body.nodes;
|
||||
if (req.query.liquidity_ads && typeof req.query.liquidity_ads === 'string' && req.query.liquidity_ads.toLowerCase() === 'yes') {
|
||||
if (req.body.liquidity_ads) {
|
||||
response = body.nodes.filter((node) => {
|
||||
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 node;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
res.status(200).json(response);
|
||||
|
@ -36,7 +36,6 @@ export const listOffers = (req, res, next) => {
|
||||
options = common.getOptions(req);
|
||||
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listoffers';
|
||||
options.body = { offer_id: (req.query.offer_id) ? req.query.offer_id : null, active_only: !(req.query.active_only === '0' || req.query.active_only === 'false' || !req.query.active_only) };
|
||||
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 });
|
||||
|
@ -10,7 +10,7 @@ export const getNewAddress = (req, res, next) => {
|
||||
options = common.getOptions(req);
|
||||
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/newaddr';
|
||||
options.body = { addresstype: req.query.type };
|
||||
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 });
|
||||
res.status(200).json(body);
|
||||
|
@ -79,12 +79,6 @@ export const listPayments = (req, res, next) => {
|
||||
options = common.getOptions(req);
|
||||
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listsendpays';
|
||||
const { invoice, payment_hash, status } = req.query;
|
||||
options.body = {
|
||||
...(invoice && { bolt11: invoice }),
|
||||
...(payment_hash && { payment_hash }),
|
||||
...(status && { status })
|
||||
};
|
||||
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) : [];
|
||||
|
@ -1,42 +1,11 @@
|
||||
import request from 'request-promise';
|
||||
import { Logger, LoggerService } from '../../utils/logger.js';
|
||||
import { Common, CommonService } from '../../utils/common.js';
|
||||
import { CommonSelectedNode } from '../../models/config.model.js';
|
||||
|
||||
let options = null;
|
||||
const logger: LoggerService = Logger;
|
||||
const common: CommonService = Common;
|
||||
|
||||
export const decodePaymentFromPaymentRequest = (selNode: CommonSelectedNode, payment) => {
|
||||
options.url = selNode.ln_server_url + '/v1/decode';
|
||||
options.body = { string: payment };
|
||||
return request.post(options).then((res) => {
|
||||
logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: res });
|
||||
return res;
|
||||
}).catch((err) => { });
|
||||
};
|
||||
|
||||
export const decodePayments = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payments List..' });
|
||||
options = common.getOptions(req);
|
||||
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
|
||||
if (req.body.payments) {
|
||||
const paymentsArr = req.body.payments.split(',');
|
||||
return Promise.all(paymentsArr?.map((payment) => decodePaymentFromPaymentRequest(req.session.selectedNode, payment))).
|
||||
then((values) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment List Decoded', data: values });
|
||||
res.status(200).json(values);
|
||||
}).
|
||||
catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'Decode Payments Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
} else {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Empty Payment List Decoded' });
|
||||
return res.status(200).json([]);
|
||||
}
|
||||
};
|
||||
|
||||
export const decodePayment = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..' });
|
||||
options = common.getOptions(req);
|
||||
@ -45,6 +14,20 @@ export const decodePayment = (req, res, next) => {
|
||||
options.body = req.body;
|
||||
request.post(options).then((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);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'Decode Payment Error', req.session.selectedNode);
|
||||
|
@ -5,7 +5,7 @@ import { getRoute, listChannels, feeRates, listNodes } from '../../controllers/c
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/listNodes', isAuthenticated, listNodes);
|
||||
router.post('/listNodes', isAuthenticated, listNodes);
|
||||
router.post('/getRoute', isAuthenticated, getRoute);
|
||||
router.post('/feeRates', isAuthenticated, feeRates);
|
||||
router.post('/listChannels', isAuthenticated, listChannels);
|
||||
|
@ -5,8 +5,8 @@ import { getNewAddress, onChainWithdraw, getUTXOs } from '../../controllers/cln/
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', isAuthenticated, getNewAddress);
|
||||
router.post('/', isAuthenticated, onChainWithdraw);
|
||||
router.post('/newaddr', isAuthenticated, getNewAddress);
|
||||
router.get('/utxos/', isAuthenticated, getUTXOs);
|
||||
|
||||
export default router;
|
||||
|
@ -1,11 +1,10 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { decodePayments, decodePayment, signMessage, verifyMessage, listConfigs } from '../../controllers/cln/utility.js';
|
||||
import { decodePayment, signMessage, verifyMessage, listConfigs } from '../../controllers/cln/utility.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', isAuthenticated, decodePayments);
|
||||
router.post('/decode', isAuthenticated, decodePayment);
|
||||
router.post('/sign', isAuthenticated, signMessage);
|
||||
router.post('/verify', isAuthenticated, verifyMessage);
|
||||
|
@ -93,7 +93,7 @@ export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
|
||||
this.colWidth = this.displayedColumns.length ? ((this.commonService.getContainerSize().width / this.displayedColumns.length) / 14) + 'rem' : '20rem';
|
||||
this.logger.info(this.displayedColumns);
|
||||
});
|
||||
combineLatest([this.store.select(nodeInfoAndNodeSettingsAndBalance), this.dataService.listNetworkNodes('?liquidity_ads=yes')]).pipe(takeUntil(this.unSubs[1])).
|
||||
combineLatest([this.store.select(nodeInfoAndNodeSettingsAndBalance), this.dataService.listNetworkNodes({ liquidity_ads: true })]).pipe(takeUntil(this.unSubs[1])).
|
||||
subscribe({
|
||||
next: ([infoSettingsBalSelector, nodeListRes]) => {
|
||||
this.information = infoSettingsBalSelector.information;
|
||||
|
@ -148,18 +148,18 @@ export class CLNEffects implements OnDestroy {
|
||||
ofType(CLNActions.GET_NEW_ADDRESS_CLN),
|
||||
mergeMap((action: { type: string, payload: GetNewAddress }) => {
|
||||
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.GENERATE_NEW_ADDRESS }));
|
||||
return this.httpClient.get(this.CHILD_API_URL + API_END_POINTS.ON_CHAIN_API + '?type=' + action.payload.addressCode).
|
||||
return this.httpClient.post(this.CHILD_API_URL + API_END_POINTS.ON_CHAIN_API + '/newaddr', { addresstype: action.payload.addressCode }).
|
||||
pipe(
|
||||
map((newAddress: any) => {
|
||||
this.logger.info(newAddress);
|
||||
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.GENERATE_NEW_ADDRESS }));
|
||||
return {
|
||||
type: CLNActions.SET_NEW_ADDRESS_CLN,
|
||||
payload: (newAddress && newAddress.address) ? newAddress.address : {}
|
||||
payload: (newAddress && newAddress[action.payload.addressCode]) ? newAddress[action.payload.addressCode] : {}
|
||||
};
|
||||
}),
|
||||
catchError((err: any) => {
|
||||
this.handleErrorWithAlert('GenerateNewAddress', UI_MESSAGES.GENERATE_NEW_ADDRESS, 'Generate New Address Failed', this.CHILD_API_URL + API_END_POINTS.ON_CHAIN_API + '?type=' + action.payload.addressId, err);
|
||||
this.handleErrorWithAlert('GenerateNewAddress', UI_MESSAGES.GENERATE_NEW_ADDRESS, 'Generate New Address Failed', this.CHILD_API_URL + API_END_POINTS.ON_CHAIN_API, err);
|
||||
return of({ type: RTLActions.VOID });
|
||||
})
|
||||
);
|
||||
@ -586,7 +586,7 @@ export class CLNEffects implements OnDestroy {
|
||||
mergeMap((action: { type: string, payload: { status: string } }) => {
|
||||
const statusInitial = action.payload.status.charAt(0).toUpperCase();
|
||||
this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'FetchForwardingHistory' + statusInitial, status: APICallStatusEnum.INITIATED } }));
|
||||
return this.httpClient.get(this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + '/listForwards?status=' + action.payload.status).
|
||||
return this.httpClient.post(this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + '/listForwards', action.payload).
|
||||
pipe(
|
||||
map((fhRes: any) => {
|
||||
this.logger.info(fhRes);
|
||||
@ -601,7 +601,7 @@ export class CLNEffects implements OnDestroy {
|
||||
return { type: RTLActions.VOID };
|
||||
}),
|
||||
catchError((err: any) => {
|
||||
this.handleErrorWithAlert('FetchForwardingHistory' + statusInitial, UI_MESSAGES.NO_SPINNER, 'Get ' + action.payload.status + ' Forwarding History Failed', this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + '/listForwards?status=' + action.payload.status, err);
|
||||
this.handleErrorWithAlert('FetchForwardingHistory' + statusInitial, UI_MESSAGES.NO_SPINNER, 'Get ' + action.payload.status + ' Forwarding History Failed', this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + '/listForwards', err);
|
||||
return of({ type: RTLActions.VOID });
|
||||
})
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ export class DataService implements OnDestroy {
|
||||
method = 'POST';
|
||||
}
|
||||
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.DECODE_PAYMENT }));
|
||||
return this.httpClient.request(method, url, body).pipe(
|
||||
return this.httpClient.request(method, url, { body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } }).pipe(
|
||||
takeUntil(this.unSubs[0]),
|
||||
map((res: any) => {
|
||||
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.DECODE_PAYMENT }));
|
||||
@ -280,7 +280,7 @@ export class DataService implements OnDestroy {
|
||||
return of(forwardsWithAlias);
|
||||
}),
|
||||
catchError((err) => {
|
||||
this.handleErrorWithAlert('getForwardingHistoryData', UI_MESSAGES.GET_FORWARDING_HISTORY, 'Forwarding History Failed', this.APIUrl + '/cln' + API_END_POINTS.CHANNELS_API + '/listForwards?status=' + status + '&start=' + start + '&end=' + end, err);
|
||||
this.handleErrorWithAlert('getForwardingHistoryData', UI_MESSAGES.GET_FORWARDING_HISTORY, 'Forwarding History Failed', this.APIUrl + '/cln' + API_END_POINTS.CHANNELS_API + '/listForwards', err);
|
||||
return throwError(() => new Error(this.extractErrorMessage(err)));
|
||||
}));
|
||||
} else {
|
||||
@ -288,10 +288,10 @@ export class DataService implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
listNetworkNodes(queryParams: string = '') {
|
||||
listNetworkNodes(payload) {
|
||||
return this.lnImplementationUpdated.pipe(first(), mergeMap((updatedLnImplementation) => {
|
||||
this.store.dispatch(openSpinner({ payload: UI_MESSAGES.LIST_NETWORK_NODES }));
|
||||
return this.httpClient.get(this.APIUrl + '/' + updatedLnImplementation + API_END_POINTS.NETWORK_API + '/listNodes' + queryParams).pipe(
|
||||
return this.httpClient.post(this.APIUrl + '/' + updatedLnImplementation + API_END_POINTS.NETWORK_API + '/listNodes', payload).pipe(
|
||||
takeUntil(this.unSubs[9]),
|
||||
mergeMap((res) => {
|
||||
this.store.dispatch(closeSpinner({ payload: UI_MESSAGES.LIST_NETWORK_NODES }));
|
||||
|
Loading…
Reference in New Issue
Block a user