diff options
| author | Adam Soltys <[email protected]> | 2026-03-11 22:30:21 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-11 22:30:21 -0700 |
| commit | 96f3e1927d37a81d47f8683b4c135bfd30eaceaa (patch) | |
| tree | 703a8a0511f5439b5ff0efbcc43a5fd5619f99f5 /src | |
| parent | 7472a9662475c634d32300c2dab514b04b74e70f (diff) | |
| download | coinos-ui-96f3e1927d37a81d47f8683b4c135bfd30eaceaa.tar.gz coinos-ui-96f3e1927d37a81d47f8683b4c135bfd30eaceaa.zip | |
simplify bumping
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 91 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/bump-estimate/+server.ts | 12 |
2 files changed, 7 insertions, 96 deletions
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 8ba33c02..b8642338 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -55,48 +55,20 @@ success("Printing!"); }; - let showBump = $state(false); let bumpLoading = $state(false); - let bumpEstimate: any = $state(null); - let bumpTargetRate = $state(0); let bumpError = $state(""); let canBump = $derived( type === "bitcoin" && !confirmed && amount < 0 && p.bumpReserve > 0 && !p.childTxid, ); - let fetchEstimate = async (targetRate: number) => { - bumpTargetRate = targetRate; - bumpError = ""; - try { - bumpEstimate = await post("/bump/estimate", { id, targetFeeRate: targetRate }); - } catch (e: any) { - bumpError = e.message; - } - }; - - let openBump = async () => { - showBump = true; - bumpEstimate = null; - bumpError = ""; - try { - const est = await post("/bump/estimate", { id, targetFeeRate: 10 }); - bumpEstimate = est; - bumpTargetRate = est.fees?.fastestFee || 10; - await fetchEstimate(bumpTargetRate); - } catch (e: any) { - bumpError = e.message; - } - }; - let bump = async () => { bumpLoading = true; bumpError = ""; try { - const res = await post("/bump", { id, targetFeeRate: bumpTargetRate }); + const res = await post("/bump", { id }); p.childTxid = res.txid; p.bumpedFee = res.childFee; - showBump = false; success("Transaction bumped!"); } catch (e: any) { bumpError = e.message; @@ -278,61 +250,12 @@ {/if} {#if canBump} - <div class="py-4 border-b border-base-300"> - {#if !showBump} - <button type="button" class="btn btn-accent w-full" onclick={openBump}> - Speed up - </button> - {:else} - <div class="space-y-3"> - <h3 class="font-semibold">Speed up transaction</h3> - - {#if bumpEstimate?.fees} - <div class="flex flex-wrap gap-2 justify-center"> - <button - type="button" - class="btn btn-sm" - class:btn-accent={bumpTargetRate === bumpEstimate.fees.halfHourFee} - onclick={() => fetchEstimate(bumpEstimate.fees.halfHourFee)} - > - Fast ({bumpEstimate.fees.halfHourFee}) - </button> - <button - type="button" - class="btn btn-sm" - class:btn-accent={bumpTargetRate === bumpEstimate.fees.fastestFee} - onclick={() => fetchEstimate(bumpEstimate.fees.fastestFee)} - > - Fastest ({bumpEstimate.fees.fastestFee}) - </button> - </div> - - {#if bumpEstimate.cost !== undefined} - <div class="text-center text-sm"> - <span class="text-secondary">Cost:</span> - {bumpEstimate.cost} sats from your {p.bumpReserve} sat reserve - </div> - {/if} - {/if} - - {#if bumpError} - <div class="text-red-600 text-sm text-center">{bumpError}</div> - {/if} - - <div class="flex gap-2 justify-center"> - <button type="button" class="btn btn-sm" onclick={() => (showBump = false)}> - Cancel - </button> - <button - type="button" - class="btn btn-sm btn-accent" - onclick={bump} - disabled={bumpLoading || !bumpEstimate || bumpEstimate.cost > p.bumpReserve} - > - {bumpLoading ? "Bumping..." : "Confirm bump"} - </button> - </div> - </div> + <div class="py-4 border-b border-base-300 space-y-2"> + <button type="button" class="btn btn-accent w-full" onclick={bump} disabled={bumpLoading}> + {bumpLoading ? "Bumping..." : "Speed up"} + </button> + {#if bumpError} + <div class="text-red-600 text-sm text-center">{bumpError}</div> {/if} </div> {/if} diff --git a/src/routes/(app)/payment/[id]/bump-estimate/+server.ts b/src/routes/(app)/payment/[id]/bump-estimate/+server.ts deleted file mode 100644 index dc5a8642..00000000 --- a/src/routes/(app)/payment/[id]/bump-estimate/+server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { auth, post } from "$lib/utils"; -import { json, error } from "@sveltejs/kit"; - -export async function POST({ cookies, request }) { - const body = await request.json(); - try { - const res = await post("/bump/estimate", body, auth(cookies)); - return json(res); - } catch (e: any) { - error(400, e.message); - } -} |
