diff options
Diffstat (limited to 'src/routes/(app)/send')
3 files changed, 32 insertions, 13 deletions
diff --git a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts index 10a6a737..9fa754d6 100644 --- a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts +++ b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts @@ -26,12 +26,18 @@ export async function load({ params: { address, amount }, cookies, parent }) { } const rate = rates[user.currency]; + const serverArkAddress = account.type === "ark" ? await get("/ark/address") : null; + + // Check if destination is the user's own vault address (custodial ark invoice) + const isCustodialForward = account.type === "ark" && address === account.arkAddress; return { account, amount, address, rate, + serverArkAddress, + isCustodialForward, }; } diff --git a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte index 02f1c4fb..744886ae 100644 --- a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte @@ -2,12 +2,12 @@ import { t } from "$lib/translations"; import { enhance } from "$app/forms"; import Spinner from "$comp/Spinner.svelte"; - import { focus, s, post } from "$lib/utils"; + import { focus, loc, s, post } from "$lib/utils"; import { pin } from "$lib/store"; import { goto, invalidate } from "$app/navigation"; import { rate } from "$lib/store"; import { applyAction } from "$app/forms"; - import { sendArk } from "$lib/ark"; + import { sendArk, sendArkViaForward } from "$lib/ark"; import Amount from "$comp/Amount.svelte"; @@ -23,13 +23,24 @@ submitting = true; error = ""; try { - const txid = await sendArk(address, parseInt(amount)); + let p; - const p = await post("/post/ark/vault-send", { - hash: txid, - amount: parseInt(amount), - aid: account.id, - }); + if (data.serverArkAddress && (address === data.serverArkAddress || data.isCustodialForward)) { + // Vault→custodial: send to server and credit custodial account + p = await sendArkViaForward({ + serverArkAddress: data.serverArkAddress, + amount: parseInt(amount), + aid: account.id, + user: data.user, + }); + } else { + const txid = await sendArk(address, parseInt(amount)); + p = await post("/post/ark/vault-send", { + hash: txid, + amount: parseInt(amount), + aid: account.id, + }); + } goto(`/sent/${p.id}`, { invalidateAll: true }); } catch (e: any) { @@ -65,6 +76,7 @@ let balance = $derived(data.user.balance); let currency = $derived(data.user.currency); + let locale = $derived(loc(data.user)); let submitting = $state(false), submit = $state(); </script> @@ -81,7 +93,7 @@ {#if !error} <div class="text-xl text-secondary break-all">{address}</div> - <Amount {amount} rate={$rate} {currency} /> + <Amount {amount} rate={$rate} {currency} {locale} /> <form method="POST" use:enhance={handler}> <input name="pin" value={$pin} type="hidden" /> 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 967c47af..4cb22155 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -6,7 +6,7 @@ import Spinner from "$comp/Spinner.svelte"; import WalletPass from "$comp/WalletPass.svelte"; import { page } from "$app/stores"; - import { toFiat, f, focus, s, sat, closest, network } from "$lib/utils"; + import { toFiat, f, focus, loc, s, sat, closest, network } from "$lib/utils"; import { pin } from "$lib/store"; import { goto, invalidate } from "$app/navigation"; import { rate } from "$lib/store"; @@ -198,6 +198,7 @@ let balance = $derived(data.user.balance); let currency = $derived(data.user.currency); + let locale = $derived(loc(data.user)); let submitting = $state(), submit: any = $state(), showSettings = $state(); @@ -231,7 +232,7 @@ <div class="text-xl text-secondary break-all">{address}</div> {/if} - <Amount amount={subtract ? amount - fee - ourfee : amount} rate={$rate} {currency} /> + <Amount amount={subtract ? amount - fee - ourfee : amount} rate={$rate} {currency} {locale} /> {#if fees} <div class="text-center"> @@ -245,7 +246,7 @@ </option> {/each} </select> - <Amount amount={fee} rate={$rate} {currency} /> + <Amount amount={fee} rate={$rate} {currency} {locale} /> </div> </div> @@ -253,7 +254,7 @@ <div class="text-center"> <h2 class="text-secondary text-lg">{$t("payments.platformFee")}</h2> - <Amount amount={ourfee} rate={$rate} {currency} /> + <Amount amount={ourfee} rate={$rate} {currency} {locale} /> </div> {/if} {/if} |
