From 7a3a8a2bbe44ef7ffd98caff0c73d8f76e372124 Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:00:22 +0700 Subject: [PATCH] fix: LDK mark channel as inactive and show error if counterparty forwarding info missing (#267) fix: mark channel as inactive and show error if counterparty forwarding info missing --- frontend/src/screens/channels/Channels.tsx | 18 +++++++++++------- frontend/src/types.ts | 1 + lnclient/ldk/ldk.go | 13 ++++++++++++- lnclient/models.go | 1 + 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/frontend/src/screens/channels/Channels.tsx b/frontend/src/screens/channels/Channels.tsx index 1356a7a7..a8ccc8c5 100644 --- a/frontend/src/screens/channels/Channels.tsx +++ b/frontend/src/screens/channels/Channels.tsx @@ -670,13 +670,17 @@ export default function Channels() { channel.localBalance + channel.remoteBalance; let channelWarning = ""; - if (channel.localSpendableBalance < capacity * 0.1) { - channelWarning = - "Spending balance low. You may have trouble sending payments through this channel."; - } - if (channel.localSpendableBalance > capacity * 0.9) { - channelWarning = - "Receiving capacity low. You may have trouble receiving payments through this channel."; + if (channel.error) { + channelWarning = channel.error; + } else { + if (channel.localSpendableBalance < capacity * 0.1) { + channelWarning = + "Spending balance low. You may have trouble sending payments through this channel."; + } + if (channel.localSpendableBalance > capacity * 0.9) { + channelWarning = + "Receiving capacity low. You may have trouble receiving payments through this channel."; + } } return ( diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 1009a91f..cd942f40 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -203,6 +203,7 @@ export type Channel = { forwardingFeeBaseMsat: number; unspendablePunishmentReserve: number; counterpartyUnspendablePunishmentReserve: number; + error?: string; }; export type UpdateChannelRequest = { diff --git a/lnclient/ldk/ldk.go b/lnclient/ldk/ldk.go index f1697bee..c1dae670 100644 --- a/lnclient/ldk/ldk.go +++ b/lnclient/ldk/ldk.go @@ -833,6 +833,16 @@ func (ls *LDKService) ListChannels(ctx context.Context) ([]lnclient.Channel, err unspendablePunishmentReserve = *ldkChannel.UnspendablePunishmentReserve } + var channelError *string + + if ldkChannel.CounterpartyForwardingInfoFeeBaseMsat == nil { + // if we don't have this, routing will not work (LND <-> LDK interoperability bug - https://github.com/lightningnetwork/lnd/issues/6870 ) + channelErrorValue := "Counterparty forwarding info not available. Please contact support@getalby.com" + channelError = &channelErrorValue + } + + isActive := ldkChannel.IsUsable /* superset of ldkChannel.IsReady */ && channelError == nil + channels = append(channels, lnclient.Channel{ InternalChannel: internalChannel, LocalBalance: int64(ldkChannel.ChannelValueSats*1000 - ldkChannel.InboundCapacityMsat - ldkChannel.CounterpartyUnspendablePunishmentReserve*1000), @@ -840,7 +850,7 @@ func (ls *LDKService) ListChannels(ctx context.Context) ([]lnclient.Channel, err RemoteBalance: int64(ldkChannel.InboundCapacityMsat), RemotePubkey: ldkChannel.CounterpartyNodeId, Id: ldkChannel.UserChannelId, // CloseChannel takes the UserChannelId - Active: ldkChannel.IsUsable, // superset of ldkChannel.IsReady + Active: isActive, Public: ldkChannel.IsPublic, FundingTxId: fundingTxId, Confirmations: ldkChannel.Confirmations, @@ -848,6 +858,7 @@ func (ls *LDKService) ListChannels(ctx context.Context) ([]lnclient.Channel, err ForwardingFeeBaseMsat: ldkChannel.Config.ForwardingFeeBaseMsat(), UnspendablePunishmentReserve: unspendablePunishmentReserve, CounterpartyUnspendablePunishmentReserve: ldkChannel.CounterpartyUnspendablePunishmentReserve, + Error: channelError, }) } diff --git a/lnclient/models.go b/lnclient/models.go index f0e6cd31..6be72091 100644 --- a/lnclient/models.go +++ b/lnclient/models.go @@ -90,6 +90,7 @@ type Channel struct { ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"` UnspendablePunishmentReserve uint64 `json:"unspendablePunishmentReserve"` CounterpartyUnspendablePunishmentReserve uint64 `json:"counterpartyUnspendablePunishmentReserve"` + Error *string `json:"error"` } type NodeStatus struct {