damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 6481f9648839647130e03a7110b7b151b6ffbbd4
parent 3845d32074aa8eed4a504a412b682edefadc692f
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 12 Jul 2023 17:34:24 -0700

add bech32_pubkey_decode

I need this for a test

Diffstat:
Mdamus/Util/Keys.swift | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/damus/Util/Keys.swift b/damus/Util/Keys.swift @@ -72,6 +72,14 @@ func bech32_pubkey(_ pubkey: String) -> String? { return bech32_encode(hrp: "npub", bytes) } +func bech32_pubkey_decode(_ pubkey: String) -> String? { + guard let decoded = try? bech32_decode(pubkey), decoded.hrp == "npub" else { + return nil + } + + return hex_encode(decoded.data) +} + func bech32_nopre_pubkey(_ pubkey: String) -> String? { guard let bytes = hex_decode(pubkey) else { return nil