aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/bitcoin
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/(app)/send/bitcoin')
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte28
1 files changed, 26 insertions, 2 deletions
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 609e795b..c31ce60d 100644
--- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
+++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
@@ -17,6 +17,10 @@
import { HDKey } from "@scure/bip32";
import { entropyToMnemonic, mnemonicToSeed } from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english.js";
+ import {
+ getRememberedWalletPassword,
+ forgetWalletPassword,
+ } from "$lib/passwordCache";
import Amount from "$comp/Amount.svelte";
@@ -28,9 +32,29 @@
let cancel = $state(() => (passwordPrompt = false));
let signed = $state();
- let togglePassword = () => (passwordPrompt = !passwordPrompt);
+ let trySignWithCachedPassword = async () => {
+ const cached = getRememberedWalletPassword();
+ if (!cached) return false;
+ try {
+ password = cached;
+ await signTx();
+ return true;
+ } catch (e) {
+ forgetWalletPassword();
+ return false;
+ }
+ };
+
+ let togglePassword = async () => {
+ if (passwordPrompt) {
+ passwordPrompt = false;
+ return;
+ }
+ if (await trySignWithCachedPassword()) return;
+ passwordPrompt = true;
+ };
let handler = ({ cancel }) => {
- if (account.seed && !signed) cancel(), togglePassword();
+ if (account.seed && !signed) cancel(), void togglePassword();
return async ({ result }) => {
if (result.type === "redirect") {
goto(result.location);