IsValidPublicKey() and IsValid32ByteHex() replacing IsValidPublicKeyHex()

This commit is contained in:
fiatjaf
2024-01-18 16:27:56 -03:00
parent 1a7b8991a3
commit 70f719ea31
2 changed files with 19 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package nostr
import (
"encoding/hex"
"net/url"
"strings"
)
@@ -18,3 +19,14 @@ func IsValidRelayURL(u string) bool {
}
return true
}
func IsValid32ByteHex(thing string) bool {
if strings.ToLower(thing) != thing {
return false
}
if len(thing) != 64 {
return false
}
_, err := hex.DecodeString(thing)
return err == nil
}