aboutsummaryrefslogtreecommitdiffstats
path: root/src/nostr.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-04 09:46:54 -0700
committerAdam Soltys <[email protected]>2026-08-04 09:46:54 -0700
commit399a100248792fe8d6aaf19849eab3ee3baa1984 (patch)
tree6afb67e1801997f63eb278c384b1d424bed4371c /src/nostr.js
parente462bc1e7756dcbf7c651ee282e96ee8c48b5a14 (diff)
downloadcoinosv3-399a100248792fe8d6aaf19849eab3ee3baa1984.tar.gz
coinosv3-399a100248792fe8d6aaf19849eab3ee3baa1984.zip
The Nostr card owns its built-in account; the exported key opens this wallet anywhere
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01M5kFodm9azZJVTQxnkDdKe
Diffstat (limited to 'src/nostr.js')
-rw-r--r--src/nostr.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nostr.js b/src/nostr.js
index cf3cc88..98515fe 100644
--- a/src/nostr.js
+++ b/src/nostr.js
@@ -13,7 +13,7 @@ import * as nip06 from 'nostr-tools/nip06';
import * as nip44 from 'nostr-tools/nip44';
import * as nip04 from 'nostr-tools/nip04';
import { getPublicKey, finalizeEvent, generateSecretKey } from 'nostr-tools/pure';
-import { decode as nip19decode, npubEncode } from 'nostr-tools/nip19';
+import { decode as nip19decode, npubEncode, nsecEncode } from 'nostr-tools/nip19';
import { SimplePool } from 'nostr-tools/pool';
import { randomBytes } from '@noble/hashes/utils';
import { base64urlnopad } from '@scure/base';
@@ -112,6 +112,8 @@ export function parseNostrPubkey(input) {
}
// An npub or 64-hex nostr pubkey → hex, or null if it isn't one.
export function npubOf(pkHex) { try { return npubEncode(pkHex); } catch { return null; } }
+// A raw secret key → nsec, for the one place that deliberately exports it.
+export function nsecOf(sk) { try { return nsecEncode(sk); } catch { return null; } }
// Profiles live across the network, so look them up on popular relays (broader
// than the sync relays).