mirror of
https://github.com/Ride-The-Lightning/RTL
synced 2024-11-03 23:15:24 +00:00
More api fixes
This commit is contained in:
parent
9c077e214c
commit
c3e6fb5b88
@ -12,12 +12,12 @@ export const listPeerChannels = (req, res, next) => {
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listpeerchannels';
|
||||
request.post(options).then((body) => {
|
||||
body.channels.map((channel) => {
|
||||
body.channels.forEach((channel) => {
|
||||
const local = channel.to_us_msat || 0;
|
||||
const remote = (channel.total_msat - local) || 0;
|
||||
const total = channel.total_msat || 0;
|
||||
// return getAliasForChannel(channel).then(channelAlias => {
|
||||
return {
|
||||
channel = {
|
||||
peer_id: channel.peer_id,
|
||||
peer_connected: channel.peer_connected,
|
||||
opener: channel.opener,
|
||||
@ -44,9 +44,8 @@ export const listPeerChannels = (req, res, next) => {
|
||||
balancedness: (total === 0) ? 1 : (1 - Math.abs((local - remote) / total)).toFixed(3)
|
||||
};
|
||||
});
|
||||
}).then((listPeerChannels) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: listPeerChannels });
|
||||
res.status(200).json(listPeerChannels);
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels });
|
||||
res.status(200).json(body.channels);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'List Peer Channels Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -59,7 +59,7 @@ export const listNodes = (req, res, next) => {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
const queryStr = req.query.liquidity_ads ? '?liquidity_ads=' + req.query.liquidity_ads : '';
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listNodes';
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes';
|
||||
options.form = req.params.id ? { id: req.params.id } : null;
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
|
||||
request.post(options).then((body) => {
|
||||
|
@ -70,13 +70,15 @@ 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';
|
||||
req.body.bolt11 = req.query.invoice || null;
|
||||
req.body.payment_hash = req.query.payment_hash || null;
|
||||
req.body.status = req.query.status || null;
|
||||
options.form = req.body;
|
||||
const { invoice, payment_hash, status } = req.query;
|
||||
options.form = {
|
||||
...(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 });
|
||||
res.status(200).json(groupBy(body.payments));
|
||||
res.status(200).json(body.payments && body.payments.length && body.payments.length > 0 ? groupBy(body.payments) : []);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'List Payments Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -16,6 +16,7 @@ export const getPeers = (req, res, next) => {
|
||||
peer.alias = peer.peer_id.substring(0, 20);
|
||||
return peer;
|
||||
});
|
||||
res.status(200).json(body.peers || []);
|
||||
// Promise.all(body.peers.map((peer) => getAliasForPeer(peer))).then((peerList) => {
|
||||
// logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peers with Alias Received', data: body });
|
||||
// res.status(200).json(peerList || []);
|
||||
|
@ -11,12 +11,12 @@ 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.ln_server_url + '/v1/listpeerchannels';
|
||||
request.post(options).then((body) => {
|
||||
body.channels.map((channel) => {
|
||||
body.channels.forEach((channel) => {
|
||||
const local = channel.to_us_msat || 0;
|
||||
const remote = (channel.total_msat - local) || 0;
|
||||
const total = channel.total_msat || 0;
|
||||
// return getAliasForChannel(channel).then(channelAlias => {
|
||||
return {
|
||||
channel = {
|
||||
peer_id: channel.peer_id,
|
||||
peer_connected: channel.peer_connected,
|
||||
opener: channel.opener,
|
||||
@ -43,9 +43,8 @@ export const listPeerChannels = (req, res, next) => {
|
||||
balancedness: (total === 0) ? 1 : (1 - Math.abs((local - remote) / total)).toFixed(3)
|
||||
};
|
||||
});
|
||||
}).then((listPeerChannels) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: listPeerChannels });
|
||||
res.status(200).json(listPeerChannels);
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels });
|
||||
res.status(200).json(body.channels);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'List Peer Channels Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -55,7 +55,7 @@ export const listNodes = (req, res, next) => {
|
||||
options = common.getOptions(req);
|
||||
if (options.error) { return res.status(options.statusCode).json({ message: options.message, error: options.error }); }
|
||||
const queryStr = req.query.liquidity_ads ? '?liquidity_ads=' + req.query.liquidity_ads : '';
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listNodes';
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/listnodes';
|
||||
options.form = req.params.id ? { id: req.params.id } : null;
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'DEBUG', fileName: 'Network', msg: 'List Nodes URL' + options.url });
|
||||
request.post(options).then((body) => {
|
||||
|
@ -61,13 +61,15 @@ 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';
|
||||
req.body.bolt11 = req.query.invoice || null;
|
||||
req.body.payment_hash = req.query.payment_hash || null;
|
||||
req.body.status = req.query.status || null;
|
||||
options.form = req.body;
|
||||
const { invoice, payment_hash, status } = req.query;
|
||||
options.form = {
|
||||
...(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 });
|
||||
res.status(200).json(groupBy(body.payments));
|
||||
res.status(200).json(body.payments && body.payments.length && body.payments.length > 0 ? groupBy(body.payments) : []);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Payments', 'List Payments Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
|
@ -15,6 +15,7 @@ export const getPeers = (req, res, next) => {
|
||||
peer.alias = peer.peer_id.substring(0, 20);
|
||||
return peer;
|
||||
});
|
||||
res.status(200).json(body.peers || []);
|
||||
// Promise.all(body.peers.map((peer) => getAliasForPeer(peer))).then((peerList) => {
|
||||
// logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Peers', msg: 'Peers with Alias Received', data: body });
|
||||
// res.status(200).json(peerList || []);
|
||||
|
@ -29,7 +29,6 @@ import { CLNOfferInformationComponent } from '../transactions/offers/offer-infor
|
||||
export class CLNEffects implements OnDestroy {
|
||||
|
||||
CHILD_API_URL = API_URL + '/cln';
|
||||
API_VERION = '';
|
||||
CLN_VERISON = '';
|
||||
private flgInitialized = false;
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
|
||||
@ -96,7 +95,6 @@ export class CLNEffects implements OnDestroy {
|
||||
takeUntil(this.actions.pipe(ofType(RTLActions.SET_SELECTED_NODE))),
|
||||
map((info) => {
|
||||
this.logger.info(info);
|
||||
this.API_VERION = info.api_version || '';
|
||||
this.CLN_VERISON = info.version || '';
|
||||
if (info.chains && info.chains.length && info.chains[0] &&
|
||||
(typeof info.chains[0] === 'object' && info.chains[0].hasOwnProperty('chain') && info?.chains[0].chain &&
|
||||
@ -330,11 +328,7 @@ export class CLNEffects implements OnDestroy {
|
||||
ofType(CLNActions.FETCH_CHANNELS_CLN),
|
||||
mergeMap(() => {
|
||||
this.store.dispatch(updateCLNAPICallStatus({ payload: { action: 'FetchChannels', status: APICallStatusEnum.INITIATED } }));
|
||||
const listChannelsEndpoint =
|
||||
this.commonService.isVersionCompatible(this.CLN_VERISON, '23.02') &&
|
||||
this.commonService.isVersionCompatible(this.API_VERION, '0.10.3') ?
|
||||
'/listPeerChannels' : '/listChannels';
|
||||
return this.httpClient.get<Channel[]>(this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + listChannelsEndpoint);
|
||||
return this.httpClient.get<Channel[]>(this.CHILD_API_URL + API_END_POINTS.CHANNELS_API + '/listPeerChannels');
|
||||
}),
|
||||
map((channels: Channel[]) => {
|
||||
this.logger.info(channels);
|
||||
|
Loading…
Reference in New Issue
Block a user