aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/account/setup
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-12 15:23:45 -0700
committerAdam Soltys <[email protected]>2024-09-17 09:19:25 -0700
commit2114156be3f89a2ef4c5bd13fd6d7a51d8fbc135 (patch)
treeae764021c0f9017493366862d42ea6cac904a76e /src/routes/(app)/account/setup
parent1f63848ca9fb01336f04b41434de1cc06a5b3d93 (diff)
downloadcoinos-ui-2114156be3f89a2ef4c5bd13fd6d7a51d8fbc135.tar.gz
coinos-ui-2114156be3f89a2ef4c5bd13fd6d7a51d8fbc135.zip
self custodial send
Diffstat (limited to 'src/routes/(app)/account/setup')
-rw-r--r--src/routes/(app)/account/setup/step2/+page.svelte28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/routes/(app)/account/setup/step2/+page.svelte b/src/routes/(app)/account/setup/step2/+page.svelte
index 8169ce06..221e545e 100644
--- a/src/routes/(app)/account/setup/step2/+page.svelte
+++ b/src/routes/(app)/account/setup/step2/+page.svelte
@@ -1,28 +1,44 @@
<script lang="ts">
- import { focus } from "$lib/utils";
import { t } from "$lib/translations";
import { mnemonic } from "$lib/store";
import Icon from "$comp/Icon.svelte";
- import { encrypt, decrypt } from "nostr-tools/nip49";
- import { mnemonicToEntropy, entropyToMnemonic } from "@scure/bip39";
+ import { encrypt } from "nostr-tools/nip49";
+ import {
+ mnemonicToSeed,
+ mnemonicToEntropy,
+ entropyToMnemonic,
+ } from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english";
- import { fail, post } from "$lib/utils";
+ import { focus, versions, fail, post } from "$lib/utils";
import { goto } from "$app/navigation";
+ import { HDKey } from "@scure/bip32";
export let data;
+
let { user } = data;
let password;
let submit = async () => {
let seed = await encrypt(mnemonicToEntropy($mnemonic, wordlist), password);
+ let master = HDKey.fromMasterSeed(
+ await mnemonicToSeed($mnemonic),
+ versions
+ );
+ let child = master.derive("m/84'/0'/0'");
+ let pubkey = child.publicExtendedKey;
+ let fingerprint = child.fingerprint.toString(16).padStart(8, "0");
+
+ let receiving = child.deriveChild(0);
try {
- await post("/api/accounts", { seed });
+ await post("/api/accounts", { fingerprint, pubkey, seed });
goto(`/${user.username}`);
} catch (e) {
console.log(e);
fail("Something went wrong");
}
+
+ $mnemonic = "";
};
</script>
@@ -41,7 +57,7 @@
than your login password. We can't reset it if you lose it.
</p>
- <input use:focus type="text" placeholder="Password" bind:value={password} />
+ <input use:focus type="text" placeholder="Password" bind:value={password} />
<button
class="bg-black text-white w-full px-5 py-6 text-xl rounded-2xl font-bold"