diff options
| author | Adam Soltys <[email protected]> | 2026-02-11 17:51:24 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 17:51:24 -0800 |
| commit | 13466248004327e9a026cb89f94926f9b060d1c1 (patch) | |
| tree | 47b4972c33809ccdf866b043c92cd3e0ecf5dcd0 /src/routes/(app)/send/bitcoin | |
| parent | 3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff) | |
| download | coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip | |
linting
Diffstat (limited to 'src/routes/(app)/send/bitcoin')
5 files changed, 94 insertions, 82 deletions
diff --git a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts index e7a216d6..d8df1986 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts @@ -2,24 +2,24 @@ import { auth, get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; export async function load({ cookies, params, parent }) { - const { user } = await parent(); - const aid = cookies.get("aid") || user.id; - const { address, amount } = params; - const { balance } = await get(`/account/${aid}`, auth(cookies)); + const { user } = await parent(); + const aid = cookies.get("aid") || user.id; + const { address, amount } = params; + const { balance } = await get(`/account/${aid}`, auth(cookies)); - let invoice; - try { - invoice = await get(`/invoice/${address}`); - } catch (e) { - // invoice not found - } + let invoice; + try { + invoice = await get(`/invoice/${address}`); + } catch { + // invoice not found + } - if (invoice) { - const recipient = await get(`/users/${invoice.uid}`); - let r = `/pay/${recipient.username}`; - if (amount) r += `/${amount}`; - if (recipient?.id !== user.id) redirect(307, r); - } + if (invoice) { + const recipient = await get(`/users/${invoice.uid}`); + let r = `/pay/${recipient.username}`; + if (amount) r += `/${amount}`; + if (recipient?.id !== user.id) redirect(307, r); + } - return { balance }; + return { balance }; } diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts index b7d3c5cf..fdf129a0 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts @@ -2,9 +2,9 @@ import getRates from "$lib/rates"; import { auth, get } from "$lib/utils"; export async function load({ cookies, parent }) { - const { user } = await parent(); - const rates = await getRates(); - const aid = cookies.get("aid") || user.id; - const { balance } = await get(`/account/${aid}`, auth(cookies)); - return { balance, rate: rates[user.currency] }; + const { user } = await parent(); + const rates = await getRates(); + const aid = cookies.get("aid") || user.id; + const { balance } = await get(`/account/${aid}`, auth(cookies)); + return { balance, rate: rates[user.currency] }; } diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/+page.svelte index 96b3fbd9..6c49ad6c 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/+page.svelte @@ -34,7 +34,14 @@ <div class="text-xl text-secondary break-all">{address}</div> - <Numpad bind:amount={a} bind:fiat {currency} {submit} bind:rate={$rate} {locale} /> + <Numpad + bind:amount={a} + bind:fiat + {currency} + {submit} + bind:rate={$rate} + {locale} + /> <div class="flex justify-center gap-2"> <button 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 9695247b..7cdd86f5 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 @@ -3,68 +3,68 @@ import { auth, fd, get, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; export async function load({ - params: { address, amount, feeRate }, - cookies, - parent, + params: { address, amount, feeRate }, + cookies, + parent, }) { - const rates = await getRates(); - const { user } = await parent(); - const aid = cookies.get("aid") || user.id; - const account = await get(`/account/${aid}`, auth(cookies)); + const rates = await getRates(); + const { user } = await parent(); + const aid = cookies.get("aid") || user.id; + const account = await get(`/account/${aid}`, auth(cookies)); - if (account.type === "ark") { - const serverArkAddress = await get("/ark/address"); - return { - account, - amount, - address, - rate: rates[user.currency], - serverArkAddress, - }; - } + if (account.type === "ark") { + const serverArkAddress = await get("/ark/address"); + return { + account, + amount, + address, + rate: rates[user.currency], + serverArkAddress, + }; + } - try { - const { fee, fees, inputs, ourfee, hex, subtract } = await post( - "/bitcoin/fee", - { address, amount, feeRate, aid }, - auth(cookies), - ); + try { + const { fee, fees, inputs, ourfee, hex, subtract } = await post( + "/bitcoin/fee", + { address, amount, feeRate, aid }, + auth(cookies), + ); - return { - account, - amount, - address, - fee, - fees, - feeRate, - rate: rates[user.currency], - ourfee, - subtract, - hex, - inputs, - }; - } catch (e) { - const { message } = e as Error; - return { amount, address, feeRate, message }; - } + return { + account, + amount, + address, + fee, + fees, + feeRate, + rate: rates[user.currency], + ourfee, + subtract, + hex, + inputs, + }; + } catch (e) { + const { message } = e as Error; + return { amount, address, feeRate, message }; + } } export const actions = { - default: async ({ - cookies, - params: { address, amount, feeRate }, - request, - }) => { - let p; - try { - const body = await fd(request); - p = await post("/bitcoin/send", body, auth(cookies)); - } catch (e) { - console.log("problem sending bitcoin", e); - const { message } = e as Error; - return fail(400, { address, amount, feeRate, message }); - } + default: async ({ + cookies, + params: { address, amount, feeRate }, + request, + }) => { + let p; + try { + const body = await fd(request); + p = await post("/bitcoin/send", body, auth(cookies)); + } catch (e) { + console.log("problem sending bitcoin", e); + const { message } = e as Error; + return fail(400, { address, amount, feeRate, message }); + } - redirect(307, `/sent/${p.id}`); - }, + redirect(307, `/sent/${p.id}`); + }, }; 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 ecdb3b08..6581e12f 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -78,7 +78,8 @@ return; } - if ((account.seed || data.user.seed) && !signed) cancel(), void togglePassword(); + if ((account.seed || data.user.seed) && !signed) + (cancel(), void togglePassword()); return async ({ result }) => { if (result.type === "redirect") { goto(result.location); @@ -102,14 +103,18 @@ import("@scure/bip39"), import("@scure/bip39/wordlists/english.js"), ]); - let entropy = await decrypt(account.seed || data.user.seed, password as string); + let entropy = await decrypt( + account.seed || data.user.seed, + password as string, + ); let mnemonic = entropyToMnemonic(entropy, wordlist); let seed = await mnemonicToSeed(mnemonic, password as string); let master = HDKey.fromMasterSeed(seed, network as any); let child = master.derive(`m/84'/0'/${account.accountIndex ?? 0}'`); let raw = decode(hex); - let isPSBT = raw[0] === 0x70 && raw[1] === 0x73 && raw[2] === 0x62 && raw[3] === 0x74; + let isPSBT = + raw[0] === 0x70 && raw[1] === 0x73 && raw[2] === 0x62 && raw[3] === 0x74; let tx: any = isPSBT ? Transaction.fromPSBT(raw) : Transaction.fromRaw(raw); for (let [i, input] of tx.inputs.entries()) { |
