import { InfoIcon } from "lucide-react";
import { ChannelWarning } from "src/components/channels/ChannelWarning";
import { FormattedBitcoinAmount } from "src/components/FormattedBitcoinAmount";
import Loading from "src/components/Loading.tsx";
import { Badge } from "src/components/ui/badge.tsx";
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "src/components/ui/card";
import { Progress } from "src/components/ui/progress.tsx";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "src/components/ui/table.tsx";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "src/components/ui/tooltip.tsx";
import { useNodeDetails } from "src/hooks/useNodeDetails";
import { Channel, LongUnconfirmedZeroConfChannel } from "src/types";
import { ChannelDropdownMenu } from "./ChannelDropdownMenu";
type ChannelsTableProps = {
channels?: Channel[];
longUnconfirmedZeroConfChannels: LongUnconfirmedZeroConfChannel[];
};
export function ChannelsTable({
channels,
longUnconfirmedZeroConfChannels,
}: ChannelsTableProps) {
if (channels && !channels.length) {
return null;
}
return (
Channels
Peer
Type
The type of lightning channel, By default private channel
is recommended. If you a podcaster or musician and expect
to receive keysend or Value4Value payments you will need a
public channel.
Status
Capacity
Total Spending and Receiving capacity of your lightning
channel.
Reserve
Funds each participant sets aside to discourage cheating
by ensuring each party has something at stake. This
reserve cannot be spent during the channel's lifetime and
typically amounts to 1% of the channel capacity. The
reserve will automatically be filled when payments are
received on the channel.
{channels && channels.length > 0 && (
<>
{channels
.sort((a, b) =>
a.localBalanceMsat + a.remoteBalanceMsat >
b.localBalanceMsat + b.remoteBalanceMsat
? -1
: 1
)
.map((channel) => {
const unconfirmedChannel =
longUnconfirmedZeroConfChannels.find(
(uc) => uc.id === channel.id
);
return (
1}
/>
);
})}
>
)}
{!channels && (
)}
);
}
type ChannelTableRowProps = {
channel: Channel;
unconfirmedChannel: LongUnconfirmedZeroConfChannel | undefined;
hasMultipleChannels: boolean;
};
function ChannelTableRow({
channel,
unconfirmedChannel,
hasMultipleChannels,
}: ChannelTableRowProps) {
const { data: peerDetails } = useNodeDetails(channel.remotePubkey);
const capacityMsat = channel.localBalanceMsat + channel.remoteBalanceMsat;
const alias = peerDetails?.alias || "Unknown";
return (
{alias}
{channel.public ? "Public" : "Private"}
{channel.status == "online" ? (
unconfirmedChannel ? (
Unconfirmed
) : (
Online
)
) : channel.status == "opening" ? (
Opening
) : (
Offline
)}
{channel.localBalanceMsat <
channel.unspendablePunishmentReserveSat * 1000 && (
<>
{" "}
/{" "}
>
)}
);
}