import { ExternalLinkIcon, HourglassIcon } from "lucide-react";
import ExternalLink from "src/components/ExternalLink";
import { FormattedBitcoinAmount } from "src/components/FormattedBitcoinAmount";
import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert";
import { useInfo } from "src/hooks/useInfo";
import { useNodeDetails } from "src/hooks/useNodeDetails";
import { OnchainBalanceResponse, PendingBalancesDetails } from "src/types";
type PendingClosedChannelsAlertProps = {
balance: OnchainBalanceResponse;
};
export function PendingClosedChannelsAlert({
balance,
}: PendingClosedChannelsAlertProps) {
if (balance.pendingBalancesFromChannelClosuresSat <= 0) {
return null;
}
const pendingDetails = [
...balance.pendingBalancesDetails,
...balance.pendingSweepBalancesDetails,
];
return (
Pending Closed Channels
You have{" "}
{" "}
pending from closed channels
{pendingDetails.length > 0 && (
<>
{" "}
with
{pendingDetails.map((details, index) => (
))}
>
)}
. Once spendable again these will become available in your on-chain
balance. Funds from channels that were force closed may take up to 2
weeks to become available.{" "}
Learn more
);
}
type PendingBalancesDetailsItemProps = {
details: PendingBalancesDetails;
showSeparator: boolean;
};
function PendingBalancesDetailsItem({
details,
showSeparator,
}: PendingBalancesDetailsItemProps) {
const { data: info } = useInfo();
const { data: nodeDetails } = useNodeDetails(details.nodeId);
return (
{nodeDetails?.alias || "Unknown"}
{" "}
(
)
funding tx
{showSeparator && ","}
);
}