import { ExternalLinkIcon } from "lucide-react"; import React from "react"; import { toast } from "sonner"; import ExternalLink from "src/components/ExternalLink"; import { Input } from "src/components/ui/input"; import { Label } from "src/components/ui/label"; import { useChannels } from "src/hooks/useChannels"; import { Channel, UpdateChannelRequest } from "src/types"; import { request } from "src/utils/request"; import { AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "./ui/alert-dialog"; type Props = { channel: Channel; }; export function RoutingFeeDialogContent({ channel }: Props) { const currentBaseFeeSats: number = Math.floor( channel.forwardingFeeBaseMsat / 1000 ); const currentFeePPM: number = channel.forwardingFeeProportionalMillionths; const [baseFeeSats, setBaseFeeSats] = React.useState( currentBaseFeeSats !== undefined ? currentBaseFeeSats.toString() : "" ); const [ forwardingFeeProportionalMillionths, setForwardingFeeProportionalMillionths, ] = React.useState( currentFeePPM !== undefined ? currentFeePPM.toString() : "" ); const { mutate: reloadChannels } = useChannels(); async function updateFee() { try { const forwardingFeeBaseMsat = +baseFeeSats * 1000; console.info( `🎬 Updating channel ${channel.id} with ${channel.remotePubkey}` ); await request( `/api/peers/${channel.remotePubkey}/channels/${channel.id}`, { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ forwardingFeeBaseMsat: forwardingFeeBaseMsat, forwardingFeeProportionalMillionths: +forwardingFeeProportionalMillionths, } as UpdateChannelRequest), } ); await reloadChannels(); toast("Successfully updated channel"); } catch (error) { console.error(error); toast.error("Something went wrong", { description: "" + error, }); } } const handleSubmit = (_e: React.FormEvent) => { // NOTE: some weird behavior due to this dialog being triggered from a dropdown //e.preventDefault(); updateFee(); }; return ( Update Channel Routing Fee

Adjust the fee you charge for each payment routed through this channel. A high fee (e.g. 100,000 sats) can be set to prevent unwanted routing. No matter the fee, you can still receive payments.{" "}

{ setBaseFeeSats(e.target.value.trim()); }} /> { setForwardingFeeProportionalMillionths(e.target.value.trim()); }} />
Learn more about routing fees
Cancel Confirm
); }