diff options
| author | Adam Soltys <[email protected]> | 2026-03-02 22:50:42 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-02 22:50:42 -0800 |
| commit | 97fffca3e63e2edb4818305abdbcbb8953344aa3 (patch) | |
| tree | 2791ae61b72b995dea8c2c0e3b8ead3cd0965a80 /src/routes/(app)/send/bitcoin | |
| parent | 11d358ad0412b794ecf89b4da9f99ac41ed9c3fe (diff) | |
| download | coinos-ui-97fffca3e63e2edb4818305abdbcbb8953344aa3.tar.gz coinos-ui-97fffca3e63e2edb4818305abdbcbb8953344aa3.zip | |
fee bumping ui
Diffstat (limited to 'src/routes/(app)/send/bitcoin')
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts | 3 | ||||
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte | 83 |
2 files changed, 70 insertions, 16 deletions
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 717b5a4c..54891aad 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 @@ -31,7 +31,7 @@ export async function load({ params: { address, amount, feeRate }, cookies, pare } try { - const { fee, fees, inputs, ourfee, hex, subtract } = await post( + const { fee, fees, inputs, ourfee, hex, subtract, bumpReserve } = await post( "/bitcoin/fee", { address, amount, feeRate, aid }, auth(cookies), @@ -50,6 +50,7 @@ export async function load({ params: { address, amount, feeRate }, cookies, pare hex, inputs, forward, + bumpReserve, }; } catch (e) { const { message } = e as Error; 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 246cc824..fcae8598 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -129,7 +129,7 @@ let toggle = () => (submitting = !submitting); - let { account, amount, address, message, fee, fees, subtract, ourfee, hex, inputs, forward } = + let { account, amount, address, message, fee, fees, subtract, ourfee, hex, inputs, forward, bumpReserve } = $derived(data); let feeRate: any = $state((() => data.feeRate)()); @@ -152,16 +152,34 @@ submit: any = $state(), showSettings = $state(); - let feeNames = { - fastestFee: $t("payments.fastest"), - halfHourFee: $t("payments.fast"), - hourFee: $t("payments.medium"), - }; + let customRate = $state(""); + let showCustom = $state(false); + + let presets = $derived(fees ? [ + { label: $t("payments.economy"), rate: 0.1 }, + { label: $t("payments.medium"), rate: fees.hourFee }, + { label: $t("payments.fast"), rate: fees.halfHourFee }, + { label: $t("payments.fastest"), rate: fees.fastestFee }, + ] : []); let toggleSettings = () => (showSettings = !showSettings); let setFee = () => goto(`/send/bitcoin/${address}/${amount}/${feeRate}`); let goBack = () => goto(`/send/bitcoin/${address}`); + + let pickRate = (r: number) => { + feeRate = r; + showCustom = false; + setFee(); + }; + + let applyCustom = () => { + const r = parseFloat(customRate); + if (r >= 0.1) { + feeRate = r; + setFee(); + } + }; </script> <div class="container px-4 max-w-xl mx-auto space-y-5 text-center no-transition"> @@ -187,18 +205,53 @@ <div class="text-center"> <h2 class="text-secondary text-lg">{$t("payments.networkFee")}</h2> - <div class="flex flex-wrap gap-4 justify-center"> - <select bind:value={feeRate} onchange={setFee}> - {#each Object.keys(feeNames) as feeName} - <option value={fees[feeName]}> - {feeNames[feeName]} — {fees[feeName]} sats/vb - </option> - {/each} - </select> - <Amount amount={fee} rate={$rate} {currency} {locale} /> + <div class="flex flex-wrap gap-2 justify-center mb-2"> + {#each presets as preset} + <button + type="button" + class="btn btn-sm" + class:btn-accent={feeRate == preset.rate && !showCustom} + onclick={() => pickRate(preset.rate)} + > + {preset.label} ({preset.rate}) + </button> + {/each} + <button + type="button" + class="btn btn-sm" + class:btn-accent={showCustom} + onclick={() => { showCustom = true; customRate = String(feeRate); }} + > + Custom + </button> </div> + + {#if showCustom} + <div class="flex items-center justify-center gap-2 mb-2"> + <input + type="number" + min="0.1" + step="0.1" + class="input input-bordered w-24 text-center" + bind:value={customRate} + onblur={applyCustom} + onkeydown={(e) => e.key === 'Enter' && applyCustom()} + /> + <span class="text-secondary text-sm">sat/vB</span> + </div> + {/if} + + <Amount amount={fee} rate={$rate} {currency} {locale} /> </div> + {#if bumpReserve > 0} + <div class="text-center"> + <h2 class="text-secondary text-lg">Bump Reserve</h2> + <div class="text-sm text-secondary">Refundable on confirmation</div> + <Amount amount={bumpReserve} rate={$rate} {currency} {locale} /> + </div> + {/if} + {#if ourfee} <div class="text-center"> <h2 class="text-secondary text-lg">{$t("payments.platformFee")}</h2> |
