diff options
| author | Adam Soltys <[email protected]> | 2026-02-11 20:10:43 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 20:10:43 -0800 |
| commit | 56a04684c1fb77ea7b21afc6b0d2e1c4773906f6 (patch) | |
| tree | d6bc2557c56b93177bb14aa376847c6e123a4862 /src/routes/(app)/send/bitcoin | |
| parent | 13466248004327e9a026cb89f94926f9b060d1c1 (diff) | |
| download | coinos-ui-56a04684c1fb77ea7b21afc6b0d2e1c4773906f6.tar.gz coinos-ui-56a04684c1fb77ea7b21afc6b0d2e1c4773906f6.zip | |
format
Diffstat (limited to 'src/routes/(app)/send/bitcoin')
3 files changed, 21 insertions, 75 deletions
diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/+page.svelte index 6c49ad6c..76ac093e 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/+page.svelte @@ -34,21 +34,10 @@ <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 - type="button" - class="btn !w-auto grow" - onclick={setMax} - onkeydown={setMax} + <button type="button" class="btn !w-auto grow" onclick={setMax} onkeydown={setMax} >{#if $fiatStore} Max {f((balance * $rate) / sats, currency, locale)} {:else} @@ -57,12 +46,7 @@ > <form action={`/send/bitcoin/${address}/${amount}`} class="contents"> - <button - use:focus - bind:this={submit} - type="submit" - class="btn !w-auto grow btn-accent" - > + <button use:focus bind:this={submit} type="submit" class="btn !w-auto grow btn-accent"> {$t("payments.next")} </button> </form> 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 7cdd86f5..c5149a93 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,11 +2,7 @@ import getRates from "$lib/rates"; import { auth, fd, get, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; -export async function load({ - params: { address, amount, feeRate }, - cookies, - parent, -}) { +export async function load({ params: { address, amount, feeRate }, cookies, parent }) { const rates = await getRates(); const { user } = await parent(); const aid = cookies.get("aid") || user.id; @@ -50,11 +46,7 @@ export async function load({ } export const actions = { - default: async ({ - cookies, - params: { address, amount, feeRate }, - request, - }) => { + default: async ({ cookies, params: { address, amount, feeRate }, request }) => { let p; try { const body = await fd(request); 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 6581e12f..49dbe7c6 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -14,10 +14,7 @@ import { hex as hexUtil } from "@scure/base"; import * as btc from "@scure/btc-signer"; import { decrypt } from "nostr-tools/nip49"; - import { - getRememberedWalletPassword, - forgetWalletPassword, - } from "$lib/passwordCache"; + import { getRememberedWalletPassword, forgetWalletPassword } from "$lib/passwordCache"; import { sendArkViaForward } from "$lib/ark"; import Amount from "$comp/Amount.svelte"; @@ -78,8 +75,7 @@ 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); @@ -92,29 +88,21 @@ let signTx = async () => { const { decrypt } = await import("nostr-tools/nip49"); - const [ - { Transaction }, - { HDKey }, - { entropyToMnemonic, mnemonicToSeed }, - { wordlist }, - ] = await Promise.all([ - import("@scure/btc-signer"), - import("@scure/bip32"), - import("@scure/bip39"), - import("@scure/bip39/wordlists/english.js"), - ]); - let entropy = await decrypt( - account.seed || data.user.seed, - password as string, - ); + const [{ Transaction }, { HDKey }, { entropyToMnemonic, mnemonicToSeed }, { wordlist }] = + await Promise.all([ + import("@scure/btc-signer"), + import("@scure/bip32"), + import("@scure/bip39"), + import("@scure/bip39/wordlists/english.js"), + ]); + 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()) { @@ -137,27 +125,15 @@ let toggle = () => (submitting = !submitting); - let { - account, - amount, - address, - message, - fee, - fees, - subtract, - ourfee, - hex, - inputs, - } = $derived(data); + let { account, amount, address, message, fee, fees, subtract, ourfee, hex, inputs } = + $derived(data); let { feeRate }: any = $state(data); $effect(() => { if (fees) { delete fees.minimumFee; - feeRate = feeRate - ? closest(Object.values(fees), feeRate) - : fees.halfHourFee; + feeRate = feeRate ? closest(Object.values(fees), feeRate) : fees.halfHourFee; } }); @@ -182,9 +158,7 @@ let goBack = () => goto(`/send/bitcoin/${address}`); </script> -<div - class="container px-4 max-w-xl mx-auto space-y-5 text-center no-transition" -> +<div class="container px-4 max-w-xl mx-auto space-y-5 text-center no-transition"> <h1 class="text-3xl md:text-4xl font-semibold mb-2">{$t("payments.send")}</h1> {#if form?.message || message || error} @@ -194,11 +168,7 @@ {:else} <div class="text-xl text-secondary break-all">{address}</div> - <Amount - amount={subtract ? amount - fee - ourfee : amount} - rate={$rate} - {currency} - /> + <Amount amount={subtract ? amount - fee - ourfee : amount} rate={$rate} {currency} /> {#if fees} <div class="text-center"> |
