From 0c35915cb584a73d11b4c4d438ff441334391fd8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 12 Sep 2024 15:23:45 -0700 Subject: self custodial send --- src/lib/utils.ts | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/lib/utils.ts') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 69e0f949..c20a7d29 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,7 +1,7 @@ import { browser } from "$app/environment"; import { toast } from "@zerodevx/svelte-toast"; import { goto } from "$app/navigation"; -import { PUBLIC_COINOS_URL } from "$env/static/public"; +import { PUBLIC_COINOS_NETWORK, PUBLIC_COINOS_URL } from "$env/static/public"; import { page } from "$app/stores"; import { get as getStore } from "svelte/store"; @@ -41,7 +41,11 @@ export let get = (url: string, headers = {}) => { }); }; -export let post = async (url: string, body: object, headers: HeadersInit | undefined = undefined) => { +export let post = async ( + url: string, + body: object, + headers: HeadersInit | undefined = undefined +) => { headers = { "content-type": "application/json", accept: "application/json", @@ -242,7 +246,11 @@ export let select = (el: HTMLInputElement): any => export let sleep = (n: number): Promise => new Promise((r) => setTimeout(r, n)); -export let wait = async (f: () => boolean | Promise, n: number = 100, s: number = 300): Promise => { +export let wait = async ( + f: () => boolean | Promise, + n: number = 100, + s: number = 300 +): Promise => { let i = 0; while (!(await f()) && i < s) { await sleep(n); @@ -327,3 +335,30 @@ export function setCookie(name: string, value: string, seconds: number): void { const expires = "expires=" + now.toUTCString(); document.cookie = name + "=" + value + ";" + expires + ";path=/"; } + +export let network = { + bitcoin: { + bech32: "bc", + pubKeyHash: 0x00, + scriptHash: 0x05, + wif: 0x80, + }, + regtest: { + bech32: "bcrt", + pubKeyHash: 0x6f, + scriptHash: 0xc4, + wif: 0xef, + }, +}[PUBLIC_COINOS_NETWORK]; + +export let versions = { + bitcoin: { + private: 0x0488ade4, + public: 0x0488b21e, + }, + regtest: { + private: 0x04358394, + public: 0x043587cf, + }, +}[PUBLIC_COINOS_NETWORK]; + -- cgit v1.2.3 From ad0f7b0033c0273657b47e2ea22092029023c0b2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 23 Sep 2024 16:22:10 -0700 Subject: account import --- src/components/Account.svelte | 6 +- src/components/WalletPass.svelte | 67 ++++++++++++++++++++++ src/lib/utils.ts | 1 + src/locales/en.json | 14 ++++- src/routes/(app)/[username]/(profile)/+page.svelte | 4 +- src/routes/(app)/account/[id]/+page.svelte | 52 +++++++++++++++-- src/routes/(app)/account/import/+page.svelte | 43 +++++++------- src/routes/(app)/account/pass/+page.svelte | 10 ++-- src/routes/(app)/account/savings/+page.svelte | 10 ++-- src/routes/(app)/invoice/+page.server.ts | 3 +- .../pay/[username]/[...amount]/+page.server.ts | 5 +- src/routes/(app)/payments/[...page]/+page.svelte | 2 + .../[amount]/[...feeRate]/+page.server.ts | 5 +- .../[address]/[amount]/[...feeRate]/+page.svelte | 61 +------------------- src/routes/(app)/send/invoice/[id]/+page.server.ts | 5 +- .../(app)/send/lightning/[payreq]/+page.server.ts | 5 +- src/routes/(app)/sent/+page.server.ts | 7 --- src/routes/(app)/sent/+page.svelte | 52 ----------------- src/routes/(app)/sent/[id]/+page.server.ts | 7 +++ src/routes/(app)/sent/[id]/+page.svelte | 49 ++++++++++++++++ static/icons/balance.svg | 29 ++++++++++ 21 files changed, 266 insertions(+), 171 deletions(-) create mode 100644 src/components/WalletPass.svelte delete mode 100644 src/routes/(app)/sent/+page.server.ts delete mode 100644 src/routes/(app)/sent/+page.svelte create mode 100644 src/routes/(app)/sent/[id]/+page.server.ts create mode 100644 src/routes/(app)/sent/[id]/+page.svelte create mode 100644 static/icons/balance.svg (limited to 'src/lib/utils.ts') diff --git a/src/components/Account.svelte b/src/components/Account.svelte index 47deadcd..4bfdc4ac 100644 --- a/src/components/Account.svelte +++ b/src/components/Account.svelte @@ -1,5 +1,4 @@ @@ -40,7 +38,7 @@ - + + +
+ + +
+ + + diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c20a7d29..0997eeb9 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -287,6 +287,7 @@ export let types = { internal: "internal", fund: "fund", ecash: "ecash", + reconcile: "reconcile", }; export let ease = (t: number): number => diff --git a/src/locales/en.json b/src/locales/en.json index 9752a41d..78ef8de1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,6 +1,18 @@ { "accounts": { - "savings": "Savings" + "addAccount": "Add account", + "create": "Create", + "import": "Import", + "accountSetup": "Account setup", + "enterSeed": "Enter a seed phrase", + "passwordMismatch": "Passwords don't match", + "generateSeed": "Generate a new seed phrase in your browser", + "accountPassword": "Account password", + "importSeed": "Enter an existing seed phrase", + "passwordWarning": "If you lose this password you won't be able to withdraw funds from the account or restore your seed phrase. We can't recover it for you.", + "savings": "Savings", + "password": "Password", + "confirmPassword": "Confirm password" }, "404": { "404": "404", diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 03fbc454..2c2ff9a8 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -41,13 +41,13 @@ {/each}
- + diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index df121168..3dcd99b8 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -1,13 +1,27 @@
-

Import

+

{$t("accounts.import")}

-
-
-