1
0
mirror of git://jb55.com/damus synced 2024-09-19 11:43:44 +00:00

add bech32_pubkey_decode

I need this for a test
This commit is contained in:
William Casarin 2023-07-12 17:34:24 -07:00
parent 3845d32074
commit 6481f96488

View File

@ -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