diff options
| author | Adam Soltys <[email protected]> | 2026-02-16 20:56:39 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-16 20:56:39 -0800 |
| commit | b22c813f9fb3b4d69dade75d22e90e6779919f07 (patch) | |
| tree | 173fe377e83ad65ac6721dd567d8e90d9d204be8 /src/routes/(app)/+layout.svelte | |
| parent | 8bb150db1f73164030f9e8085c13765120363644 (diff) | |
| download | coinos-ui-b22c813f9fb3b4d69dade75d22e90e6779919f07.tar.gz coinos-ui-b22c813f9fb3b4d69dade75d22e90e6779919f07.zip | |
nostr key derivation
Diffstat (limited to 'src/routes/(app)/+layout.svelte')
| -rw-r--r-- | src/routes/(app)/+layout.svelte | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 6f2e061d..0fde24fa 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -130,7 +130,11 @@ let autoProvisionAccounts = async () => { if (!user) return; if (sessionStorage.getItem("accounts:provisioned")) return; - const prfKey = getCachedPrfKey(); + let prfKey = getCachedPrfKey(); + if (!prfKey) { + const { getWalletEntropy } = await import("$lib/walletEntropy"); + prfKey = await getWalletEntropy(); + } if (!prfKey) return; sessionStorage.setItem("accounts:provisioned", "1"); @@ -139,9 +143,8 @@ const res = await fetch("/account", { headers: { accept: "application/json" } }); const accounts = await res.json(); - const hasBitcoin = accounts.some((a: any) => a.type === "bitcoin"); const hasArk = accounts.some((a: any) => a.type === "ark"); - if (hasBitcoin && hasArk) return; + if (hasArk) return; const [{ HDKey }, { entropyToMnemonic, mnemonicToSeed }, { wordlist }] = await Promise.all([ import("@scure/bip32"), @@ -154,27 +157,14 @@ const seed = await mnemonicToSeed(mnemonic); const master = HDKey.fromMasterSeed(seed, versions); - if (!hasArk) { - const { SingleKey, Wallet } = await import("@arkade-os/sdk"); - const { bytesToHex } = await import("@noble/hashes/utils.js"); - const arkChild = master.derive("m/86'/0'/0'/0/0"); - const arkHex = bytesToHex(arkChild.privateKey!); - const identity = SingleKey.fromHex(arkHex); - const wallet = await Wallet.create({ identity, arkServerUrl }); - const arkAddress = await wallet.getAddress(); - await post("/account", { name: "Savings", type: "ark", arkAddress }); - } - - if (!hasBitcoin) { - const child = master.derive("m/84'/0'/0'"); - await post("/account", { - fingerprint: child.fingerprint.toString(16).padStart(8, "0"), - pubkey: child.publicExtendedKey, - name: "Vault", - type: "bitcoin", - accountIndex: 0, - }); - } + const { SingleKey, Wallet } = await import("@arkade-os/sdk"); + const { bytesToHex } = await import("@noble/hashes/utils.js"); + const arkChild = master.derive("m/86'/0'/0'/0/0"); + const arkHex = bytesToHex(arkChild.privateKey!); + const identity = SingleKey.fromHex(arkHex); + const wallet = await Wallet.create({ identity, arkServerUrl }); + const arkAddress = await wallet.getAddress(); + await post("/account", { name: $t("accounts.savings"), type: "ark", arkAddress }); invalidate("app:payments"); } catch (e) { |
