aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-20 10:03:22 -0700
committerAdam Soltys <[email protected]>2024-09-20 10:03:22 -0700
commit5c86d9eadaa0021928ea39c7d0e875d0c446280f (patch)
tree9d8465f37573f0efa1e84ce64d7d2336798cc319
parentd4c3d52fdde5fef8f72c1f572f1ce7c70da86b23 (diff)
downloadcoinos-ui-5c86d9eadaa0021928ea39c7d0e875d0c446280f.tar.gz
coinos-ui-5c86d9eadaa0021928ea39c7d0e875d0c446280f.zip
import key
-rw-r--r--src/routes/(app)/account/import/+page.svelte15
-rw-r--r--src/routes/(app)/account/pass/+page.svelte7
-rw-r--r--src/routes/(app)/payments/[...page]/+page.server.ts4
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/+page.server.ts4
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts8
-rw-r--r--src/routes/(app)/sent/+page.server.ts4
6 files changed, 23 insertions, 19 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">
diff --git a/src/routes/(app)/payments/[...page]/+page.server.ts b/src/routes/(app)/payments/[...page]/+page.server.ts
index e781022e..311d4435 100644
--- a/src/routes/(app)/payments/[...page]/+page.server.ts
+++ b/src/routes/(app)/payments/[...page]/+page.server.ts
@@ -5,7 +5,7 @@ let limit = 25;
export async function load({ cookies, depends, params }) {
depends("app:payments");
- let account = cookies.get("account");
+ let account_id = cookies.get("account_id");
let parts = params.page.split("/");
let start, end, page;
@@ -17,7 +17,7 @@ export async function load({ cookies, depends, params }) {
let offset = (page - 1) * limit;
if (!start) start = Date.now() / 1000 - 24 * 60 * 60;
- let url = `/payments?account=${account}&start=${
+ let url = `/payments?account_id=${account_id}&start=${
start * 1000
}&limit=${limit}&offset=${offset}`;
if (end) url += `&end=${end * 1000}`;
diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
index 3e56e15a..d3b71d0a 100644
--- a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
+++ b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
@@ -1,7 +1,7 @@
import { auth, get } from "$lib/utils";
export async function load({ cookies }) {
- let account = cookies.get("account");
- let { balance } = await get(`/account/${account}`, auth(cookies));
+ let account_id = cookies.get("account_id");
+ let { balance } = await get(`/account/${account_id}`, auth(cookies));
return { balance };
}
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
index 33e96595..6aee85b9 100644
--- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
+++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
@@ -2,16 +2,16 @@ import { fail, redirect } from "@sveltejs/kit";
import { auth, get, post, fd } from "$lib/utils";
export async function load({ params: { address, amount, feeRate }, cookies }) {
- let account = cookies.get("account");
+ let account_id = cookies.get("account_id");
try {
let { fee, fees, inputs, ourfee, hex } = await post(
"/bitcoin/fee",
- { address, amount, feeRate, account },
+ { address, amount, feeRate, account_id },
auth(cookies)
);
- account = await get(`/account/${account}`, auth(cookies));
+ let account = await get(`/account/${account_id}`, auth(cookies));
return {
account,
@@ -25,7 +25,7 @@ export async function load({ params: { address, amount, feeRate }, cookies }) {
inputs,
};
} catch (e: any) {
- return { account, amount, address, feeRate, message: e.message };
+ return { amount, address, feeRate, message: e.message };
}
}
diff --git a/src/routes/(app)/sent/+page.server.ts b/src/routes/(app)/sent/+page.server.ts
index 4cf580ee..9aeda733 100644
--- a/src/routes/(app)/sent/+page.server.ts
+++ b/src/routes/(app)/sent/+page.server.ts
@@ -1,7 +1,7 @@
import { get, auth } from "$lib/utils";
export let load = async ({ cookies }) => {
- let account = cookies.get("account");
- let { payments } = await get(`/payments?account=${account}`, auth(cookies));
+ let account_id = cookies.get("account_id");
+ let { payments } = await get(`/payments?account_id=${account_id}`, auth(cookies));
return { payments };
};