diff options
| author | Adam Soltys <[email protected]> | 2024-09-20 10:03:22 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-20 10:03:22 -0700 |
| commit | 5c86d9eadaa0021928ea39c7d0e875d0c446280f (patch) | |
| tree | 9d8465f37573f0efa1e84ce64d7d2336798cc319 /src/routes/(app)/account | |
| parent | d4c3d52fdde5fef8f72c1f572f1ce7c70da86b23 (diff) | |
| download | coinos-ui-5c86d9eadaa0021928ea39c7d0e875d0c446280f.tar.gz coinos-ui-5c86d9eadaa0021928ea39c7d0e875d0c446280f.zip | |
import key
Diffstat (limited to 'src/routes/(app)/account')
| -rw-r--r-- | src/routes/(app)/account/import/+page.svelte | 15 | ||||
| -rw-r--r-- | src/routes/(app)/account/pass/+page.svelte | 7 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/routes/(app)/account/import/+page.svelte b/src/routes/(app)/account/import/+page.svelte index 1e28f9df..866c1b1a 100644 --- a/src/routes/(app)/account/import/+page.svelte +++ b/src/routes/(app)/account/import/+page.svelte @@ -1,11 +1,12 @@ <script> + import { goto } from "$app/navigation"; + import { mnemonic } from "$lib/store"; import { versions } from "$lib/utils"; import { t } from "$lib/translations"; import { browser } from "$app/environment"; import Icon from "$comp/Icon.svelte"; import { validateMnemonic } from "@scure/bip39"; import { wordlist } from "@scure/bip39/wordlists/english"; - import { HDKey } from "@scure/bip32"; let el, pasted, text; @@ -16,10 +17,12 @@ let submit = () => { let valid = validateMnemonic(text, wordlist); - let v2 = HDKey.fromExtendedKey(text, versions); - - console.log(valid); - console.log(v2); + if (valid) { + $mnemonic = text; + goto("/account/pass"); + } else { + fail("Failed to validate seed phrase"); + } }; $: if (browser && pasted && text) form.submit() && (pasted = false); @@ -34,7 +37,7 @@ <textarea use:focus name="text" - placeholder="Enter a seed phrase or extended key" + placeholder="Enter a seed phrase" class="w-full p-4 border rounded-xl h-48 text-xl" bind:value={text} autocapitalize="none" diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte index 0eb16072..cf4e80e6 100644 --- a/src/routes/(app)/account/pass/+page.svelte +++ b/src/routes/(app)/account/pass/+page.svelte @@ -19,6 +19,7 @@ let { user } = data; let confirm, password, revealPassword, revealConfirm; + let type = "bitcoin"; onMount(() => { if (!$mnemonic) goto("/account/savings"); @@ -44,7 +45,7 @@ let fingerprint = child.fingerprint.toString(16).padStart(8, "0"); let receiving = child.deriveChild(0); - await post("/api/accounts", { fingerprint, pubkey, seed }); + await post("/api/accounts", { fingerprint, pubkey, seed, type }); goto(`/${user.username}`); } catch (e) { console.log(e); @@ -65,8 +66,8 @@ class="container w-full mx-auto text-lg px-4 max-w-xl space-y-5" > <p class="text-secondary mb-1"> - Careful! If you lose this password you won't be able to use the account. - We can't recover it for you. + If you lose this password you won't be able to use the account. We can't + recover it for you even if you have the seed phrase. </p> <div class="relative"> |
