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