fix: catching getChannel callback error (#46)

catching FullChannelDetailsNotFound on the getChannel call we do using the lightning library, this seems to be a response we get if the channel edge is not found or is a zombie one.

fixes https://github.com/apotdevin/thunderhub/issues/45
This commit is contained in:
Gonzalo Aune 2020-05-21 07:06:17 +01:00 committed by GitHub
parent b23f8c2299
commit caefd02234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 8 deletions

View file

@ -54,10 +54,23 @@ export const getForwardChannelsReport = {
}
const getNodeAlias = async (id: string, publicKey: string) => {
const channelInfo: ChannelsProps = await getChannel({
lnd,
id,
});
let channelInfo: ChannelsProps;
try {
channelInfo = await getChannel({
lnd,
id,
});
} catch (error) {
if (error[1] == 'FullChannelDetailsNotFound') {
return {
alias: 'Edge Zombie or not found',
color: '#000000',
};
}
logger.error('Error getting channel / node information: %o', error);
throw new Error(getErrorMsg(error));
}
const partnerPublicKey =
channelInfo.policies[0].public_key !== publicKey

View file

@ -62,10 +62,23 @@ export const getForwards = {
});
const getNodeAlias = async (id: string, publicKey: string) => {
const channelInfo: ChannelsProps = await getChannel({
lnd,
id,
});
let channelInfo: ChannelsProps;
try {
channelInfo = await getChannel({
lnd,
id,
});
} catch (error) {
if (error[1] == 'FullChannelDetailsNotFound') {
return {
alias: 'Edge Zombie or not found',
color: '#000000',
};
}
logger.error('Error getting channel / node information: %o', error);
throw new Error(getErrorMsg(error));
}
const partnerPublicKey =
channelInfo.policies[0].public_key !== publicKey