Show pubkey copy things
Docker / build-and-push-image (push) Successful in 35s

This commit is contained in:
Jon Staab
2026-06-12 13:01:05 -07:00
parent 5587d40688
commit bd3217f43d
9 changed files with 105 additions and 23 deletions
+16
View File
@@ -1,3 +1,19 @@
import { npubEncode } from "applesauce-core/helpers/pointers"
export function shortenPubkey(pubkey: string) {
return pubkey.length <= 16 ? pubkey : `${pubkey.slice(0, 8)}...${pubkey.slice(-8)}`
}
// Encode a hex pubkey as an npub for display. Falls back to the raw input when it
// isn't a valid pubkey, since npubEncode throws on malformed input.
export function toNpub(pubkey: string) {
try {
return npubEncode(pubkey)
} catch {
return pubkey
}
}
export function shortenNpub(pubkey: string) {
return shortenPubkey(toNpub(pubkey))
}