import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useNostr } from '@/providers/NostrProvider' import { Check, Copy, RefreshCcw } from 'lucide-react' import { generateSecretKey } from 'nostr-tools' import { nsecEncode } from 'nostr-tools/nip19' import { useState } from 'react' import { useTranslation } from 'react-i18next' export default function GenerateNewAccount({ back, onLoginSuccess }: { back: () => void onLoginSuccess: () => void }) { const { t } = useTranslation() const { nsecLogin } = useNostr() const [nsec, setNsec] = useState(generateNsec()) const [copied, setCopied] = useState(false) const [password, setPassword] = useState('') const handleLogin = () => { nsecLogin(nsec, password).then(() => onLoginSuccess()) } return (
{ e.preventDefault() handleLogin() }} >
{t( 'This is a private key. Do not share it with anyone. Keep it safe and secure. You will not be able to recover it if you lose it.' )}
setPassword(e.target.value)} />
) } function generateNsec() { const sk = generateSecretKey() return nsecEncode(sk) }