import AsyncButton from "@/Components/Button/AsyncButton"; import Icon from "@/Components/Icons/Icon"; import { WalletInvoice, useWallet } from "@/Wallet"; import { LNURL } from "@snort/shared"; import { useEffect, useState } from "react"; import { FormattedMessage, FormattedNumber, useIntl } from "react-intl"; export function WalletSendPage() { const wallets = useWallet(); const { formatMessage } = useIntl(); const [invoice, setInvoice] = useState(""); const [error, setError] = useState(""); const [lnurl, isLnurl] = useState(true); const [amount, setAmount] = useState(0); const [comment, setComment] = useState(""); const [result, setResult] = useState(); useEffect(() => { isLnurl(!invoice.startsWith("lnbc")); }, [invoice]); return (

"{b}", wallet: wallets.config?.info.alias, }} />

setInvoice(e.target.value)} /> {lnurl && ( <> setComment(e.target.value)} />
setAmount(Number(e.target.value))} />
)} { try { if (wallets.wallet) { if (!isLnurl) { const res = await wallets.wallet.payInvoice(invoice); setResult(res); } else { const lnurl = new LNURL(invoice); await lnurl.load(); const pr = await lnurl.getInvoice(amount, comment); if (pr.pr) { const res = await wallets.wallet.payInvoice(pr.pr); setResult(res); } } } } catch (e) { setError((e as Error).message); } }}> {error && {error}} {result && (
, fee: , }} />
)}
); }