chore: improve nsec input, fix copy nsec
This commit is contained in:
@ -45,13 +45,16 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
|
||||
function doLoginNsec() {
|
||||
try {
|
||||
const nsec = prompt("nsec");
|
||||
let nsec = prompt("Enter your nsec\nWARNING: THIS IS NOT RECOMMENDED. DO NOT IMPORT ANY KEYS YOU CARE ABOUT");
|
||||
if (!nsec) {
|
||||
throw new Error("no nsec provided");
|
||||
}
|
||||
const {words} = bech32.decode(nsec, 5000);
|
||||
const data = new Uint8Array(bech32.fromWords(words));
|
||||
Login.loginWithPrivateKey(bytesToHex(data));
|
||||
if (nsec.startsWith("nsec")) {
|
||||
const {words} = bech32.decode(nsec, 5000);
|
||||
const data = new Uint8Array(bech32.fromWords(words));
|
||||
nsec = bytesToHex(data);
|
||||
}
|
||||
Login.loginWithPrivateKey(nsec);
|
||||
close();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@ -134,7 +137,7 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
className="btn btn-primary"
|
||||
onClick={doLoginNsec}
|
||||
>
|
||||
Enter Nsec (INSECURE)
|
||||
Enter Nsec
|
||||
</button>
|
||||
{error && <b className="error">{error}</b>}
|
||||
</>
|
||||
|
@ -4,6 +4,7 @@ import "./settings-page.css";
|
||||
import React from "react";
|
||||
import { Button } from "@getalby/bitcoin-connect-react";
|
||||
import Copy from "element/copy";
|
||||
import { hexToBech32 } from "@snort/shared";
|
||||
|
||||
export function SettingsPage() {
|
||||
const navigate = useNavigate();
|
||||
@ -26,7 +27,7 @@ export function SettingsPage() {
|
||||
</div>}
|
||||
{login?.privateKey && <div className="private-key">
|
||||
<p>Private key</p>
|
||||
<Copy text={login.privateKey} hideText />
|
||||
<Copy text={hexToBech32('nsec', login.privateKey)} hideText />
|
||||
</div>}
|
||||
|
||||
<h1>Zaps</h1>
|
||||
|
Reference in New Issue
Block a user