aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-16 22:05:24 -0800
committerAdam Soltys <[email protected]>2026-02-16 22:05:24 -0800
commitd0784c34787e6d96f0131af2e12079e7915b2f57 (patch)
treeb814727de91158b9212aeddd45152c8d3bbda39c /src
parent99aee9c7d9265d9963e045d418fb231813a002f2 (diff)
downloadcoinos-ui-d0784c34787e6d96f0131af2e12079e7915b2f57.tar.gz
coinos-ui-d0784c34787e6d96f0131af2e12079e7915b2f57.zip
seed import
Diffstat (limited to 'src')
-rw-r--r--src/components/Account.svelte20
-rw-r--r--src/lib/socket.ts12
-rw-r--r--src/lib/store.ts1
-rw-r--r--src/locales/en.json1
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte2
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte14
-rw-r--r--src/routes/(app)/account/ark/+page.svelte2
-rw-r--r--src/routes/(app)/account/pass/+page.svelte2
-rw-r--r--src/routes/(app)/account/seed/+page.svelte2
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte2
-rw-r--r--src/routes/(static)/register/+page.svelte2
11 files changed, 38 insertions, 22 deletions
diff --git a/src/components/Account.svelte b/src/components/Account.svelte
index 88b08978..2ea7c9c0 100644
--- a/src/components/Account.svelte
+++ b/src/components/Account.svelte
@@ -8,7 +8,7 @@
import Balance from "$comp/Balance.svelte";
import { t } from "$lib/translations";
import { versions, s, f, loc, toFiat } from "$lib/utils";
- import { fiat } from "$lib/store";
+ import { fiat, importing } from "$lib/store";
import { arkkey, arkaid } from "$lib/ark";
import { getRememberedWalletPassword, forgetWalletPassword, getCachedPrfKey } from "$lib/passwordCache";
@@ -37,7 +37,7 @@
import("@scure/bip39"),
import("@scure/bip39/wordlists/english.js"),
]);
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mnemonic = entropyToMnemonic(entropy, wordlist);
const s = await mnemonicToSeed(mnemonic);
const master = HDKey.fromMasterSeed(s, versions);
@@ -61,7 +61,7 @@
import("@scure/bip39"),
import("@scure/bip39/wordlists/english.js"),
]);
- const entropy = new Uint8Array(nostrKey);
+ const entropy = new Uint8Array(nostrKey).slice(0, 16);
const mnemonic = entropyToMnemonic(entropy, wordlist);
const s = await mnemonicToSeed(mnemonic);
const master = HDKey.fromMasterSeed(s, versions);
@@ -187,11 +187,15 @@
<div class="flex items-start justify-between gap-4">
<div>
<div class="text-lg text-gray-400">{displayName}</div>
- <Balance {balance} {user} {rate} {id} {currency} />
- {#if pending}
- <div class="text-lg text-gray-600">
- +{$fiat && rate ? f(toFiat(pending, rate), currency, loc(user)) : s(pending)} {$t("accounts.pending")}
- </div>
+ {#if $importing.has(id)}
+ <div class="text-lg text-gray-400">{$t("accounts.importing")}</div>
+ {:else}
+ <Balance {balance} {user} {rate} {id} {currency} />
+ {#if pending}
+ <div class="text-lg text-gray-600">
+ +{$fiat && rate ? f(toFiat(pending, rate), currency, loc(user)) : s(pending)} {$t("accounts.pending")}
+ </div>
+ {/if}
{/if}
</div>
<div class="flex items-center gap-1 shrink-0 text-black">
diff --git a/src/lib/socket.ts b/src/lib/socket.ts
index e40eb39b..1ca244d9 100644
--- a/src/lib/socket.ts
+++ b/src/lib/socket.ts
@@ -1,7 +1,7 @@
import { goto, invalidate } from "$app/navigation";
import { navigating, page } from "$app/stores";
import { PUBLIC_SOCKET } from "$env/static/public";
-import { event, invoice, last, request } from "$lib/store";
+import { event, importing, invoice, last, request } from "$lib/store";
import { s, sleep, success, wait } from "$lib/utils";
import cookies from "js-cookie";
import { get } from "svelte/store";
@@ -40,11 +40,19 @@ export const messages = (data) => ({
},
async payment() {
- const { amount, confirmed, iid } = data;
+ const { amount, confirmed, iid, aid, type } = data;
invalidate("app:user");
invalidate("app:invoice");
invalidate("app:payments");
+ if (type === "import" && aid) {
+ importing.update((s) => {
+ s.delete(aid);
+ return new Set(s);
+ });
+ return;
+ }
+
const {
url: { pathname },
} = get(page);
diff --git a/src/lib/store.ts b/src/lib/store.ts
index 7499e148..d7e44167 100644
--- a/src/lib/store.ts
+++ b/src/lib/store.ts
@@ -96,3 +96,4 @@ export const token = persistSession("token");
export const ndef = writable();
export const showQr = persistLocal("showQr", true);
export const save = writable();
+export const importing = writable(new Set<string>());
diff --git a/src/locales/en.json b/src/locales/en.json
index 70840ab0..0e9895f7 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -56,6 +56,7 @@
"addAccount": "Add account",
"create": "Create",
"import": "Import",
+ "importing": "Importing...",
"accountSetup": "Account setup",
"enterSeed": "Enter a seed phrase",
"passwordMismatch": "Passwords don't match",
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index b37c2009..7f6f4036 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -44,7 +44,7 @@
import("@scure/bip39/wordlists/english.js"),
]);
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mn = entropyToMnemonic(entropy, wordlist);
const seed = await mnemonicToSeed(mn);
const master = HDKey.fromMasterSeed(seed, versions);
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index 3abc4bdc..065b85c6 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -6,6 +6,7 @@
import WalletPass from "$comp/WalletPass.svelte";
import { goto } from "$app/navigation";
import { copy, fail, focus, post } from "$lib/utils";
+ import { importing } from "$lib/store";
import { enhance } from "$app/forms";
import { t } from "$lib/translations";
import { tick } from "svelte";
@@ -81,7 +82,7 @@
let isCustodial = $derived(!seed && account.type !== "ark");
- let importing = $state(false);
+ let showImport = $state(false);
let importText = $state("");
let importSubmitting = $state(false);
@@ -105,7 +106,8 @@
pubkey,
});
- importing = false;
+ $importing = new Set([...$importing, id]);
+ showImport = false;
importText = "";
goto(`/${user.username}`, { invalidateAll: true });
} catch (e: any) {
@@ -122,7 +124,7 @@
}
if (!prfKey) return false;
try {
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
mnemonic = entropyToMnemonic(entropy, wordlist);
return true;
} catch (e) {
@@ -270,7 +272,7 @@
{/if}
{#if account.type === "bitcoin"}
- {#if importing}
+ {#if showImport}
<div class="space-y-2">
<textarea
placeholder={$t("accounts.enterSeed")}
@@ -279,7 +281,7 @@
autocapitalize="none"
></textarea>
<div class="flex gap-2">
- <button type="button" class="btn !w-auto grow" onclick={() => (importing = false)}>
+ <button type="button" class="btn !w-auto grow" onclick={() => (showImport = false)}>
{$t("accounts.back")}
</button>
<button type="button" class="btn btn-accent !w-auto grow" onclick={importSeed} disabled={importSubmitting}>
@@ -292,7 +294,7 @@
</div>
</div>
{:else}
- <button type="button" class="btn" onclick={() => (importing = true)}>
+ <button type="button" class="btn" onclick={() => (showImport = true)}>
<iconify-icon noobserver icon="ph:warning-bold" width="32"></iconify-icon>
<div class="my-auto">{$t("accounts.changeSeedPhrase")}</div>
</button>
diff --git a/src/routes/(app)/account/ark/+page.svelte b/src/routes/(app)/account/ark/+page.svelte
index b6bec5b7..243931fe 100644
--- a/src/routes/(app)/account/ark/+page.svelte
+++ b/src/routes/(app)/account/ark/+page.svelte
@@ -49,7 +49,7 @@
let deriveFromPrfKey = async (prfKey: ArrayBuffer) => {
try {
const { SingleKey, Wallet } = await import("@arkade-os/sdk");
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mnemonic = entropyToMnemonic(entropy, wordlist);
const seed = await mnemonicToSeed(mnemonic);
const master = HDKey.fromMasterSeed(seed, versions);
diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte
index 4e754489..2e1c711f 100644
--- a/src/routes/(app)/account/pass/+page.svelte
+++ b/src/routes/(app)/account/pass/+page.svelte
@@ -42,7 +42,7 @@
submitting = true;
await tick();
try {
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mn = entropyToMnemonic(entropy, wordlist);
const master = HDKey.fromMasterSeed(
await mnemonicToSeed(mn),
diff --git a/src/routes/(app)/account/seed/+page.svelte b/src/routes/(app)/account/seed/+page.svelte
index 335d92f2..d012ca42 100644
--- a/src/routes/(app)/account/seed/+page.svelte
+++ b/src/routes/(app)/account/seed/+page.svelte
@@ -22,7 +22,7 @@
const prfKey = await getWalletEntropy();
if (prfKey) {
try {
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mn = entropyToMnemonic(entropy, wordlist);
const seed = await mnemonicToSeed(mn);
const master = HDKey.fromMasterSeed(seed, versions);
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
index 1a0df2f2..967c47af 100644
--- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
+++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
@@ -113,7 +113,7 @@
import("@scure/bip39"),
import("@scure/bip39/wordlists/english.js"),
]);
- let entropy = new Uint8Array(prfKey);
+ let entropy = new Uint8Array(prfKey).slice(0, 16);
let mnemonic = entropyToMnemonic(entropy, wordlist);
let seed = await mnemonicToSeed(mnemonic);
let master = HDKey.fromMasterSeed(seed, network as any);
diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte
index 858b9695..dee4d0a3 100644
--- a/src/routes/(static)/register/+page.svelte
+++ b/src/routes/(static)/register/+page.svelte
@@ -224,7 +224,7 @@
import("@noble/hashes/utils.js"),
]);
- const entropy = new Uint8Array(prfKey);
+ const entropy = new Uint8Array(prfKey).slice(0, 16);
const mnemonic = entropyToMnemonic(entropy, wordlist);
const seed = await mnemonicToSeed(mnemonic);
const master = HDKey.fromMasterSeed(seed, versions);