diff options
Diffstat (limited to 'src/routes/(app)/send/invoice')
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 10 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.svelte | 31 |
2 files changed, 26 insertions, 15 deletions
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 59add224..dfbe9d26 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -12,7 +12,7 @@ export async function load({ cookies, depends, params: { id }, parent }) { const trust = await get("/trust", auth(cookies)); const trusted = trust.includes(invoice.uid); - if (trusted && (pin || !user.haspin)) { + if (trusted && (pin || !user.haspin) && invoice.amount) { let p; try { if (!invoice.tip && invoice.user.prompt) { @@ -37,8 +37,12 @@ export async function load({ cookies, depends, params: { id }, parent }) { if (invoice.memoPrompt && invoice.memo === null) redirect(307, `/invoice/${id}/memo`); if (user && invoice.aid === aid) error(500, { message: "Cannot send to self" }); - else if (user && ![types.lightning, types.bolt12].includes(invoice.type)) - redirect(307, `/send/${invoice.type === types.ecash ? "ecash" : "bitcoin"}/${invoice.hash}`); + else if (user && ![types.lightning, types.bolt12].includes(invoice.type)) { + // Don't redirect custodial bitcoin invoices — they should be paid internally + const isVault = invoice.account?.pubkey || invoice.account?.seed; + if (invoice.type !== types.bitcoin || isVault) + redirect(307, `/send/${invoice.type === types.ecash ? "ecash" : "bitcoin"}/${invoice.hash}`); + } if (!user) redirect(307, `/invoice/${id}`); diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 99040ed6..01b4facd 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { invalidate } from "$app/navigation"; - import { untrack } from "svelte"; + import { tick, untrack } from "svelte"; import handler from "$lib/handler"; import { t } from "$lib/translations"; import { goto, invalidateAll } from "$app/navigation"; @@ -29,14 +29,19 @@ let rate = $derived(invoice.rate * (data.rate / data.invoiceRate)); - let a: any = $state(), - af: any = $state(), + let a: any = $state(0), + af: any = $state(0), fiat = $state(untrack(() => !amount)); let amountFiat = $state((untrack(() => amount) * untrack(() => rate)) / sats); - let setAmount = () => { + let formEl: HTMLFormElement | undefined = $state(); + let setAmount = async () => { amount = a; amountFiat = af; + if (trusted) { + await tick(); + formEl?.querySelector('button[type="submit"]')?.click(); + } }; let submit = $state(), @@ -142,10 +147,10 @@ {/each} {/if} {:else} - <Numpad bind:amount={a} bind:amountFiat={af} bind:fiat {currency} {rate} {submit} /> + <Numpad bind:amount={a} bind:amountFiat={af} bind:fiat {currency} {locale} {rate} {submit} /> {/if} - <form method="POST" use:enhance={handler(toggle)} class="space-y-2"> + <form method="POST" use:enhance={handler(toggle)} class="space-y-2" bind:this={formEl}> <input name="address" value={address} type="hidden" /> <input name="amount" value={amount} type="hidden" /> <input name="payreq" value={payreq} type="hidden" /> @@ -180,13 +185,15 @@ </button> {/if} </div> - <button type="button" class="btn" onclick={external}>{$t("payments.moreOptions")}</button> + {#if amount} + <button type="button" class="btn" onclick={external}>{$t("payments.moreOptions")}</button> - {#if !trusted} - <button type="button" class="btn" onclick={toggleTrust}> - <iconify-icon icon="ph:star-fill" width={32}></iconify-icon> - {$t("payments.trustUser")} - </button> + {#if !trusted} + <button type="button" class="btn" onclick={toggleTrust}> + <iconify-icon icon="ph:star-fill" width={32}></iconify-icon> + {$t("payments.trustUser")} + </button> + {/if} {/if} </form> </div> |
