From caefd02234271bdeac5d2482064c3ae194688b0c Mon Sep 17 00:00:00 2001 From: Gonzalo Aune Date: Thu, 21 May 2020 07:06:17 +0100 Subject: [PATCH] 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 --- api/schemas/query/report/ForwardChannels.ts | 21 +++++++++++++++++---- api/schemas/query/transactions/forwards.ts | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/api/schemas/query/report/ForwardChannels.ts b/api/schemas/query/report/ForwardChannels.ts index 60656bfe..1d9eb0b9 100644 --- a/api/schemas/query/report/ForwardChannels.ts +++ b/api/schemas/query/report/ForwardChannels.ts @@ -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 diff --git a/api/schemas/query/transactions/forwards.ts b/api/schemas/query/transactions/forwards.ts index b9364113..6b49845c 100644 --- a/api/schemas/query/transactions/forwards.ts +++ b/api/schemas/query/transactions/forwards.ts @@ -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