From 734e846847c478406a9fb9083be057a731d9f4cf Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 13 Mar 2026 22:02:27 -0700 Subject: fix lockfile --- src/routes/(app)/account/[id]/seed/+page.svelte | 27 ++++++++++++++++++++++++- src/routes/+layout.svelte | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/account/[id]/seed/+page.svelte b/src/routes/(app)/account/[id]/seed/+page.svelte index b31a3102..c67a2ff4 100644 --- a/src/routes/(app)/account/[id]/seed/+page.svelte +++ b/src/routes/(app)/account/[id]/seed/+page.svelte @@ -6,7 +6,7 @@ import { goto } from "$app/navigation"; import { copy, fail } from "$lib/utils"; import { t } from "$lib/translations"; - import { entropyToMnemonic } from "@scure/bip39"; + import { entropyToMnemonic, mnemonicToSeed } from "@scure/bip39"; import { wordlist } from "@scure/bip39/wordlists/english.js"; import { getCachedPrfKey } from "$lib/passwordCache"; import { prfDecrypt, isPrfEncrypted } from "$lib/crypto"; @@ -16,6 +16,7 @@ let id = $derived(account.id); let mnemonic: string | undefined = $state(); + let nsec: string | undefined = $state(); let derivationPath = $derived( account.type === "ark" @@ -44,6 +45,17 @@ } }; + let deriveNsec = async (m: string) => { + const [{ HDKey }, { nip19 }] = await Promise.all([ + import("@scure/bip32"), + import("nostr-tools"), + ]); + const { versions } = await import("$lib/utils"); + const seed = await mnemonicToSeed(m); + const child = HDKey.fromMasterSeed(seed, versions).derive("m/86'/0'/0'/0/0"); + nsec = nip19.nsecEncode(child.privateKey!); + }; + let requestMnemonic = async () => { if (await revealWithPrfKey()) return; try { @@ -57,6 +69,10 @@ }; requestMnemonic(); + + $effect(() => { + if (mnemonic && account.type === "ark") deriveNsec(mnemonic); + });
@@ -74,6 +90,15 @@
{$t("accounts.copy")}
+ + {#if nsec} +

Nsec

+

{nsec}

+ + {/if} {/if}