mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-10 11:26:19 +02:00
IsValidPublicKey() and IsValid32ByteHex() replacing IsValidPublicKeyHex()
This commit is contained in:
12
utils.go
12
utils.go
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user