import { getDecodedToken } from "@cashu/cashu-ts"; import { useMemo } from "react"; import { FormattedMessage } from "react-intl"; import useLogin from "Hooks/useLogin"; import { useUserProfile } from "Hooks/useUserProfile"; export default function CashuNuts({ token }: { token: string }) { const login = useLogin(); const profile = useUserProfile(login.publicKey); async function copyToken(e: React.MouseEvent, token: string) { e.stopPropagation(); await navigator.clipboard.writeText(token); } async function redeemToken(e: React.MouseEvent, token: string) { e.stopPropagation(); const lnurl = profile?.lud16 ?? ""; const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent( lnurl )}&autopay=yes`; window.open(url, "_blank"); } const cashu = useMemo(() => { try { if (!token.startsWith("cashuA") || token.length < 10) { return; } return getDecodedToken(token); } catch { // ignored } }, [token]); if (!cashu) return <>{token}; return (

acc + v.amount, 0), }} />

); }