well-goknown/vendor/github.com/fiatjaf/eventstore/utils.go

20 lines
401 B
Go
Raw Normal View History

package eventstore
import (
"encoding/hex"
"strconv"
"strings"
)
func GetAddrTagElements(tagValue string) (kind uint16, pkb []byte, d string) {
spl := strings.Split(tagValue, ":")
if len(spl) == 3 {
if pkb, _ := hex.DecodeString(spl[1]); len(pkb) == 32 {
if kind, err := strconv.ParseUint(spl[0], 10, 16); err == nil {
return uint16(kind), pkb, spl[2]
}
}
}
return 0, nil, ""
}