diff options
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/+layout.svelte | 11 | ||||
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/+layout.server.ts | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 2d252385..2eda8072 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,5 +1,5 @@ <script lang="ts"> - import { getWallet, syncTransactions, settle, arkkey, arkaid, sendArk } from "$lib/ark"; + import { getWallet, syncTransactions, settle, refresh, arkkey, arkaid, sendArk } from "$lib/ark"; import { SvelteToast } from "@zerodevx/svelte-toast"; import { onDestroy, onMount } from "svelte"; import { close, connect, send, socket } from "$lib/socket"; @@ -91,6 +91,7 @@ }; let arkInitializedKey: string | undefined; + let arkRefreshTimer: ReturnType<typeof setInterval> | undefined; const initArk = async () => { const key = $arkkey; @@ -102,7 +103,14 @@ localStorage.setItem("arkkey:uid", user.id); wallet.notifyIncomingFunds(arkSync); arkSync(); + refresh().catch((e) => console.error("Ark refresh failed:", e)); settle().catch((e) => console.error("Ark settle failed:", e)); + + // Periodically recover expired VTXOs + if (arkRefreshTimer) clearInterval(arkRefreshTimer); + arkRefreshTimer = setInterval(() => { + refresh().catch((e) => console.error("Ark periodic refresh failed:", e)); + }, 60_000); } }; @@ -175,6 +183,7 @@ if (browser) { close(); clearTimeout(checkTimer); + if (arkRefreshTimer) clearInterval(arkRefreshTimer); } }); </script> diff --git a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts index 6acb36b6..acf6a370 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts +++ b/src/routes/(app)/send/bitcoin/[address]/+layout.server.ts @@ -5,7 +5,8 @@ export async function load({ cookies, params, parent }) { const { user } = await parent(); const aid = cookies.get("aid") || user.id; const { address, amount } = params; - const { balance } = await get(`/account/${aid}`, auth(cookies)); + const account = await get(`/account/${aid}`, auth(cookies)); + const senderIsVault = account.pubkey || account.seed; let invoice; try { @@ -14,7 +15,7 @@ export async function load({ cookies, params, parent }) { // invoice not found } - if (invoice) { + if (invoice && !senderIsVault) { const isVault = invoice.account?.pubkey || invoice.account?.seed; if (isVault) { // Vault account — stay on /send/bitcoin for on-chain send @@ -24,5 +25,5 @@ export async function load({ cookies, params, parent }) { } } - return { balance }; + return { balance: account.balance }; } |
