fix: save key and load key

This commit is contained in:
Ren Amamiya
2026-04-08 13:16:36 +07:00
parent 4050afe93f
commit 3dd032e238
6 changed files with 257 additions and 247 deletions

View File

@@ -6,6 +6,7 @@ import QRCode from 'react-qr-code'
import { SettingsIcon } from './icons'
import { minidenticon } from 'minidenticons'
import * as Tabs from '@radix-ui/react-tabs'
import { hexToBytes } from 'nostr-tools/utils'
function Popup() {
const [keys, setKeys] = useState(null)
@@ -27,19 +28,21 @@ function Popup() {
useEffect(() => {
browser.storage.local.get(['private_key', 'relays']).then((results) => {
if (results.private_key) {
const hexKey = getPublicKey(results.private_key)
const npubKey = nip19.npubEncode(hexKey)
const hexKey = getPublicKey(hexToBytes(results.private_key))
const npub = nip19.npubEncode(hexKey)
setKeys({ npub: npubKey, hex: hexKey })
setKeys({ npub: npub, hex: hexKey })
if (results.relays) {
const relaysList = []
for (const url in results.relays) {
if (results.relays[url].write) {
relaysList.push(url)
if (relaysList.length >= 3) break
}
}
if (relaysList.length) {
const nprofileKey = nip19.nprofileEncode({
pubkey: hexKey,