Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LDK mark channel as inactive and show error if counterparty forwarding info missing #267

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export type Channel = {
forwardingFeeBaseMsat: number;
unspendablePunishmentReserve: number;
counterpartyUnspendablePunishmentReserve: number;
error?: string;
};

export type UpdateChannelRequest = {
Expand Down
13 changes: 12 additions & 1 deletion lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,21 +833,32 @@ 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),
LocalSpendableBalance: int64(ldkChannel.OutboundCapacityMsat),
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,
ConfirmationsRequired: ldkChannel.ConfirmationsRequired,
ForwardingFeeBaseMsat: ldkChannel.Config.ForwardingFeeBaseMsat(),
UnspendablePunishmentReserve: unspendablePunishmentReserve,
CounterpartyUnspendablePunishmentReserve: ldkChannel.CounterpartyUnspendablePunishmentReserve,
Error: channelError,
})
}

Expand Down
1 change: 1 addition & 0 deletions lnclient/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading