mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-21 14:04:03 +01:00
fix: ๐ channels with unfound nodes
This commit is contained in:
parent
5df58ec9f4
commit
077e20d7da
5 changed files with 86 additions and 78 deletions
|
@ -6,14 +6,10 @@ import {
|
|||
getWalletInfo,
|
||||
} from 'ln-service';
|
||||
import { ContextType } from 'api/types/apiTypes';
|
||||
import { toWithError } from 'api/helpers/async';
|
||||
import { toWithError, to } from 'api/helpers/async';
|
||||
import { logger } from '../../../helpers/logger';
|
||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||
import {
|
||||
getAuthLnd,
|
||||
getErrorMsg,
|
||||
getCorrectAuth,
|
||||
} from '../../../helpers/helpers';
|
||||
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||
import { defaultParams } from '../../../helpers/defaultProps';
|
||||
import { ChannelType } from '../../types/QueryType';
|
||||
|
||||
|
@ -35,18 +31,13 @@ export const getChannels = {
|
|||
walletError &&
|
||||
logger.debug('Error getting wallet info in getChannels: %o', walletError);
|
||||
|
||||
const [channelList, channelListError] = await toWithError(
|
||||
const channelList = await to(
|
||||
getLnChannels({
|
||||
lnd,
|
||||
is_active: params.active,
|
||||
})
|
||||
);
|
||||
|
||||
if (channelListError) {
|
||||
logger.error('Error getting channels: %o', channelListError);
|
||||
throw new Error(getErrorMsg(channelListError));
|
||||
}
|
||||
|
||||
const getChannelList = () =>
|
||||
Promise.all(
|
||||
channelList.channels.map(async channel => {
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import { GraphQLList, GraphQLString } from 'graphql';
|
||||
import { getClosedChannels as getLnClosedChannels, getNode } from 'ln-service';
|
||||
import { ContextType } from 'api/types/apiTypes';
|
||||
import { to, toWithError } from 'api/helpers/async';
|
||||
import { logger } from '../../../helpers/logger';
|
||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||
import {
|
||||
getAuthLnd,
|
||||
getErrorMsg,
|
||||
getCorrectAuth,
|
||||
} from '../../../helpers/helpers';
|
||||
|
||||
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||
import { defaultParams } from '../../../helpers/defaultProps';
|
||||
import { ClosedChannelType } from '../../types/QueryType';
|
||||
|
||||
|
@ -45,28 +41,32 @@ export const getClosedChannels = {
|
|||
const auth = getCorrectAuth(params.auth, context);
|
||||
const lnd = getAuthLnd(auth);
|
||||
|
||||
try {
|
||||
const closedChannels: ChannelListProps = await getLnClosedChannels({
|
||||
lnd,
|
||||
});
|
||||
const channels = closedChannels.channels.map(async channel => {
|
||||
const nodeInfo = await getNode({
|
||||
const closedChannels: ChannelListProps = await to(
|
||||
getLnClosedChannels({ lnd })
|
||||
);
|
||||
|
||||
const channels = closedChannels.channels.map(async channel => {
|
||||
const [nodeInfo, nodeError] = await toWithError(
|
||||
getNode({
|
||||
lnd,
|
||||
is_omitting_channels: true,
|
||||
public_key: channel.partner_public_key,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
...channel,
|
||||
partner_node_info: {
|
||||
...nodeInfo,
|
||||
},
|
||||
};
|
||||
});
|
||||
return channels;
|
||||
} catch (error) {
|
||||
logger.error('Error getting closed channels: %o', error);
|
||||
throw new Error(getErrorMsg(error));
|
||||
}
|
||||
nodeError &&
|
||||
logger.debug(
|
||||
`Error getting node with public key ${channel.partner_public_key}: %o`,
|
||||
nodeError
|
||||
);
|
||||
|
||||
return {
|
||||
...channel,
|
||||
partner_node_info: {
|
||||
...(!nodeError && nodeInfo),
|
||||
},
|
||||
};
|
||||
});
|
||||
return channels;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -4,13 +4,10 @@ import {
|
|||
} from 'ln-service';
|
||||
import { GraphQLList } from 'graphql';
|
||||
import { ContextType } from 'api/types/apiTypes';
|
||||
import { to, toWithError } from 'api/helpers/async';
|
||||
import { logger } from '../../../helpers/logger';
|
||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||
import {
|
||||
getAuthLnd,
|
||||
getErrorMsg,
|
||||
getCorrectAuth,
|
||||
} from '../../../helpers/helpers';
|
||||
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||
import { defaultParams } from '../../../helpers/defaultProps';
|
||||
import { PendingChannelType } from '../../types/QueryType';
|
||||
|
||||
|
@ -44,31 +41,32 @@ export const getPendingChannels = {
|
|||
const auth = getCorrectAuth(params.auth, context);
|
||||
const lnd = getAuthLnd(auth);
|
||||
|
||||
try {
|
||||
const pendingChannels: PendingChannelListProps = await getLnPendingChannels(
|
||||
{
|
||||
lnd,
|
||||
}
|
||||
);
|
||||
const pendingChannels: PendingChannelListProps = await to(
|
||||
getLnPendingChannels({ lnd })
|
||||
);
|
||||
|
||||
const channels = pendingChannels.pending_channels.map(async channel => {
|
||||
const nodeInfo = await getNode({
|
||||
const channels = pendingChannels.pending_channels.map(async channel => {
|
||||
const [nodeInfo, nodeError] = await toWithError(
|
||||
getNode({
|
||||
lnd,
|
||||
is_omitting_channels: true,
|
||||
public_key: channel.partner_public_key,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
...channel,
|
||||
partner_node_info: {
|
||||
...nodeInfo,
|
||||
},
|
||||
};
|
||||
});
|
||||
return channels;
|
||||
} catch (error) {
|
||||
logger.error('Error getting pending channels: %o', error);
|
||||
throw new Error(getErrorMsg(error));
|
||||
}
|
||||
nodeError &&
|
||||
logger.debug(
|
||||
`Error getting node with public key ${channel.partner_public_key}: %o`,
|
||||
nodeError
|
||||
);
|
||||
|
||||
return {
|
||||
...channel,
|
||||
partner_node_info: {
|
||||
...(!nodeError && nodeInfo),
|
||||
},
|
||||
};
|
||||
});
|
||||
return channels;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -187,6 +187,23 @@ export const ChannelCard = ({
|
|||
});
|
||||
};
|
||||
|
||||
const renderPartner = () =>
|
||||
alias ? (
|
||||
<>
|
||||
{renderLine('Node Capacity:', nodeCapacity)}
|
||||
{renderLine('Channel Count:', channel_count)}
|
||||
{renderLine(
|
||||
'Last Update:',
|
||||
`${getDateDif(updated_at)} ago (${getFormatDate(updated_at)})`
|
||||
)}
|
||||
{renderLine('Base Fee:', `${base_fee} mSats`)}
|
||||
{renderLine('Fee Rate:', `${fee_rate} sats/MSats`)}
|
||||
{renderLine('CTLV Delta:', cltv_delta)}
|
||||
</>
|
||||
) : (
|
||||
<DarkSubTitle>Partner node not found</DarkSubTitle>
|
||||
);
|
||||
|
||||
const renderDetails = () => {
|
||||
return (
|
||||
<>
|
||||
|
@ -215,15 +232,7 @@ export const ChannelCard = ({
|
|||
{renderLine('Transaction Vout:', transaction_vout)}
|
||||
{renderLine('Unsettled Balance:', unsettled_balance)}
|
||||
<Sub4Title>Partner Node Info</Sub4Title>
|
||||
{renderLine('Node Capacity:', nodeCapacity)}
|
||||
{renderLine('Channel Count:', channel_count)}
|
||||
{renderLine(
|
||||
'Last Update:',
|
||||
`${getDateDif(updated_at)} ago (${getFormatDate(updated_at)})`
|
||||
)}
|
||||
{renderLine('Base Fee:', `${base_fee} mSats`)}
|
||||
{renderLine('Fee Rate:', `${fee_rate} sats/MSats`)}
|
||||
{renderLine('CTLV Delta:', cltv_delta)}
|
||||
{renderPartner()}
|
||||
<AdminSwitch>
|
||||
<Separation />
|
||||
<RightAlign>
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
ResponsiveLine,
|
||||
ResponsiveSingle,
|
||||
ResponsiveCol,
|
||||
DarkSubTitle,
|
||||
} from '../../../components/generic/Styled';
|
||||
import { useConfigState } from '../../../context/ConfigContext';
|
||||
import {
|
||||
|
@ -89,6 +90,20 @@ export const PendingCard = ({
|
|||
}
|
||||
};
|
||||
|
||||
const renderPartner = () =>
|
||||
alias ? (
|
||||
<>
|
||||
{renderLine('Node Capacity:', capacity)}
|
||||
{renderLine('Channels:', channel_count)}
|
||||
{renderLine(
|
||||
'Last Update:',
|
||||
`${getDateDif(updated_at)} ago (${getFormatDate(updated_at)})`
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<DarkSubTitle>Partner node not found</DarkSubTitle>
|
||||
);
|
||||
|
||||
const renderDetails = () => {
|
||||
return (
|
||||
<>
|
||||
|
@ -108,12 +123,7 @@ export const PendingCard = ({
|
|||
{renderLine('Local Reserve:', local_reserve)}
|
||||
{renderLine('Remote Reserve:', remote_reserve)}
|
||||
<Sub4Title>Partner Node Info</Sub4Title>
|
||||
{renderLine('Node Capacity:', capacity)}
|
||||
{renderLine('Channels:', channel_count)}
|
||||
{renderLine(
|
||||
'Last Update:',
|
||||
`${getDateDif(updated_at)} ago (${getFormatDate(updated_at)})`
|
||||
)}
|
||||
{renderPartner()}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
Loadingโฆ
Add table
Reference in a new issue