mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 06:21:37 +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,
|
getWalletInfo,
|
||||||
} from 'ln-service';
|
} from 'ln-service';
|
||||||
import { ContextType } from 'api/types/apiTypes';
|
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 { logger } from '../../../helpers/logger';
|
||||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||||
import {
|
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||||
getAuthLnd,
|
|
||||||
getErrorMsg,
|
|
||||||
getCorrectAuth,
|
|
||||||
} from '../../../helpers/helpers';
|
|
||||||
import { defaultParams } from '../../../helpers/defaultProps';
|
import { defaultParams } from '../../../helpers/defaultProps';
|
||||||
import { ChannelType } from '../../types/QueryType';
|
import { ChannelType } from '../../types/QueryType';
|
||||||
|
|
||||||
|
@ -35,18 +31,13 @@ export const getChannels = {
|
||||||
walletError &&
|
walletError &&
|
||||||
logger.debug('Error getting wallet info in getChannels: %o', walletError);
|
logger.debug('Error getting wallet info in getChannels: %o', walletError);
|
||||||
|
|
||||||
const [channelList, channelListError] = await toWithError(
|
const channelList = await to(
|
||||||
getLnChannels({
|
getLnChannels({
|
||||||
lnd,
|
lnd,
|
||||||
is_active: params.active,
|
is_active: params.active,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (channelListError) {
|
|
||||||
logger.error('Error getting channels: %o', channelListError);
|
|
||||||
throw new Error(getErrorMsg(channelListError));
|
|
||||||
}
|
|
||||||
|
|
||||||
const getChannelList = () =>
|
const getChannelList = () =>
|
||||||
Promise.all(
|
Promise.all(
|
||||||
channelList.channels.map(async channel => {
|
channelList.channels.map(async channel => {
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import { GraphQLList, GraphQLString } from 'graphql';
|
import { GraphQLList, GraphQLString } from 'graphql';
|
||||||
import { getClosedChannels as getLnClosedChannels, getNode } from 'ln-service';
|
import { getClosedChannels as getLnClosedChannels, getNode } from 'ln-service';
|
||||||
import { ContextType } from 'api/types/apiTypes';
|
import { ContextType } from 'api/types/apiTypes';
|
||||||
|
import { to, toWithError } from 'api/helpers/async';
|
||||||
import { logger } from '../../../helpers/logger';
|
import { logger } from '../../../helpers/logger';
|
||||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||||
import {
|
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||||
getAuthLnd,
|
|
||||||
getErrorMsg,
|
|
||||||
getCorrectAuth,
|
|
||||||
} from '../../../helpers/helpers';
|
|
||||||
|
|
||||||
import { defaultParams } from '../../../helpers/defaultProps';
|
import { defaultParams } from '../../../helpers/defaultProps';
|
||||||
import { ClosedChannelType } from '../../types/QueryType';
|
import { ClosedChannelType } from '../../types/QueryType';
|
||||||
|
|
||||||
|
@ -45,28 +41,32 @@ export const getClosedChannels = {
|
||||||
const auth = getCorrectAuth(params.auth, context);
|
const auth = getCorrectAuth(params.auth, context);
|
||||||
const lnd = getAuthLnd(auth);
|
const lnd = getAuthLnd(auth);
|
||||||
|
|
||||||
try {
|
const closedChannels: ChannelListProps = await to(
|
||||||
const closedChannels: ChannelListProps = await getLnClosedChannels({
|
getLnClosedChannels({ lnd })
|
||||||
lnd,
|
);
|
||||||
});
|
|
||||||
const channels = closedChannels.channels.map(async channel => {
|
const channels = closedChannels.channels.map(async channel => {
|
||||||
const nodeInfo = await getNode({
|
const [nodeInfo, nodeError] = await toWithError(
|
||||||
|
getNode({
|
||||||
lnd,
|
lnd,
|
||||||
is_omitting_channels: true,
|
is_omitting_channels: true,
|
||||||
public_key: channel.partner_public_key,
|
public_key: channel.partner_public_key,
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
nodeError &&
|
||||||
...channel,
|
logger.debug(
|
||||||
partner_node_info: {
|
`Error getting node with public key ${channel.partner_public_key}: %o`,
|
||||||
...nodeInfo,
|
nodeError
|
||||||
},
|
);
|
||||||
};
|
|
||||||
});
|
return {
|
||||||
return channels;
|
...channel,
|
||||||
} catch (error) {
|
partner_node_info: {
|
||||||
logger.error('Error getting closed channels: %o', error);
|
...(!nodeError && nodeInfo),
|
||||||
throw new Error(getErrorMsg(error));
|
},
|
||||||
}
|
};
|
||||||
|
});
|
||||||
|
return channels;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,13 +4,10 @@ import {
|
||||||
} from 'ln-service';
|
} from 'ln-service';
|
||||||
import { GraphQLList } from 'graphql';
|
import { GraphQLList } from 'graphql';
|
||||||
import { ContextType } from 'api/types/apiTypes';
|
import { ContextType } from 'api/types/apiTypes';
|
||||||
|
import { to, toWithError } from 'api/helpers/async';
|
||||||
import { logger } from '../../../helpers/logger';
|
import { logger } from '../../../helpers/logger';
|
||||||
import { requestLimiter } from '../../../helpers/rateLimiter';
|
import { requestLimiter } from '../../../helpers/rateLimiter';
|
||||||
import {
|
import { getAuthLnd, getCorrectAuth } from '../../../helpers/helpers';
|
||||||
getAuthLnd,
|
|
||||||
getErrorMsg,
|
|
||||||
getCorrectAuth,
|
|
||||||
} from '../../../helpers/helpers';
|
|
||||||
import { defaultParams } from '../../../helpers/defaultProps';
|
import { defaultParams } from '../../../helpers/defaultProps';
|
||||||
import { PendingChannelType } from '../../types/QueryType';
|
import { PendingChannelType } from '../../types/QueryType';
|
||||||
|
|
||||||
|
@ -44,31 +41,32 @@ export const getPendingChannels = {
|
||||||
const auth = getCorrectAuth(params.auth, context);
|
const auth = getCorrectAuth(params.auth, context);
|
||||||
const lnd = getAuthLnd(auth);
|
const lnd = getAuthLnd(auth);
|
||||||
|
|
||||||
try {
|
const pendingChannels: PendingChannelListProps = await to(
|
||||||
const pendingChannels: PendingChannelListProps = await getLnPendingChannels(
|
getLnPendingChannels({ lnd })
|
||||||
{
|
);
|
||||||
lnd,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const channels = pendingChannels.pending_channels.map(async channel => {
|
const channels = pendingChannels.pending_channels.map(async channel => {
|
||||||
const nodeInfo = await getNode({
|
const [nodeInfo, nodeError] = await toWithError(
|
||||||
|
getNode({
|
||||||
lnd,
|
lnd,
|
||||||
is_omitting_channels: true,
|
is_omitting_channels: true,
|
||||||
public_key: channel.partner_public_key,
|
public_key: channel.partner_public_key,
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
nodeError &&
|
||||||
...channel,
|
logger.debug(
|
||||||
partner_node_info: {
|
`Error getting node with public key ${channel.partner_public_key}: %o`,
|
||||||
...nodeInfo,
|
nodeError
|
||||||
},
|
);
|
||||||
};
|
|
||||||
});
|
return {
|
||||||
return channels;
|
...channel,
|
||||||
} catch (error) {
|
partner_node_info: {
|
||||||
logger.error('Error getting pending channels: %o', error);
|
...(!nodeError && nodeInfo),
|
||||||
throw new Error(getErrorMsg(error));
|
},
|
||||||
}
|
};
|
||||||
|
});
|
||||||
|
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 = () => {
|
const renderDetails = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -215,15 +232,7 @@ export const ChannelCard = ({
|
||||||
{renderLine('Transaction Vout:', transaction_vout)}
|
{renderLine('Transaction Vout:', transaction_vout)}
|
||||||
{renderLine('Unsettled Balance:', unsettled_balance)}
|
{renderLine('Unsettled Balance:', unsettled_balance)}
|
||||||
<Sub4Title>Partner Node Info</Sub4Title>
|
<Sub4Title>Partner Node Info</Sub4Title>
|
||||||
{renderLine('Node Capacity:', nodeCapacity)}
|
{renderPartner()}
|
||||||
{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)}
|
|
||||||
<AdminSwitch>
|
<AdminSwitch>
|
||||||
<Separation />
|
<Separation />
|
||||||
<RightAlign>
|
<RightAlign>
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
ResponsiveLine,
|
ResponsiveLine,
|
||||||
ResponsiveSingle,
|
ResponsiveSingle,
|
||||||
ResponsiveCol,
|
ResponsiveCol,
|
||||||
|
DarkSubTitle,
|
||||||
} from '../../../components/generic/Styled';
|
} from '../../../components/generic/Styled';
|
||||||
import { useConfigState } from '../../../context/ConfigContext';
|
import { useConfigState } from '../../../context/ConfigContext';
|
||||||
import {
|
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 = () => {
|
const renderDetails = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -108,12 +123,7 @@ export const PendingCard = ({
|
||||||
{renderLine('Local Reserve:', local_reserve)}
|
{renderLine('Local Reserve:', local_reserve)}
|
||||||
{renderLine('Remote Reserve:', remote_reserve)}
|
{renderLine('Remote Reserve:', remote_reserve)}
|
||||||
<Sub4Title>Partner Node Info</Sub4Title>
|
<Sub4Title>Partner Node Info</Sub4Title>
|
||||||
{renderLine('Node Capacity:', capacity)}
|
{renderPartner()}
|
||||||
{renderLine('Channels:', channel_count)}
|
|
||||||
{renderLine(
|
|
||||||
'Last Update:',
|
|
||||||
`${getDateDif(updated_at)} ago (${getFormatDate(updated_at)})`
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loadingโฆ
Add table
Reference in a new issue