fix: save key and load key
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user