import * as bip39 from "@scure/bip39"; import { wordlist } from "@scure/bip39/wordlists/english.js"; import { AlertTriangleIcon, LifeBuoyIcon, ShieldCheckIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { useNavigate } from "react-router"; import { toast } from "sonner"; import MnemonicInputs from "src/components/mnemonic/MnemonicInputs"; import TwoColumnLayoutHeader from "src/components/TwoColumnLayoutHeader"; import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert"; import { Button } from "src/components/ui/button"; import useSetupStore from "src/state/SetupStore"; export function ImportMnemonic() { const navigate = useNavigate(); const setupStore = useSetupStore(); useEffect(() => { // in case the user presses back, remove their last-saved mnemonic useSetupStore.getState().updateNodeInfo({ mnemonic: undefined, }); }, []); const [mnemonic, setMnemonic] = useState(""); async function onSubmit(e: React.FormEvent) { e.preventDefault(); if ( mnemonic.split(" ").length !== 12 || !bip39.validateMnemonic(mnemonic, wordlist) ) { toast.error("Invalid recovery phrase"); return; } const currentDate = new Date(); const sixMonthsLater = new Date( currentDate.setMonth(currentDate.getMonth() + 6) ); setupStore.updateNodeInfo({ mnemonic, nextBackupReminder: sixMonthsLater.toISOString(), }); setupStore.setHasImportedMnemonic(true); navigate(`/setup/node`); } return (
Do not re-use the same key on multiple devices If you want to transfer your existing Hub to another machine please use the migrate feature from the Alby Hub settings.
Your recovery phrase is a set of 12 words used to restore your on-chain balance from a backup.
Keep it safe and private to ensure your funds remain secure.
); }