From 6c13dc7969cf90c6b2e74c3bd03603bc5c077cd5 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 19 Dec 2022 15:10:23 -0300 Subject: [PATCH] remove tlv from npub in nip19. --- nip19/nip19.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/nip19/nip19.go b/nip19/nip19.go index ae7e8b6..e49950c 100644 --- a/nip19/nip19.go +++ b/nip19/nip19.go @@ -1,7 +1,6 @@ package nip19 import ( - "encoding/binary" "encoding/hex" "fmt" ) @@ -15,26 +14,12 @@ func EncodePrivateKey(privateKeyHex string) (string, error) { return encode("nsec", b) } -func EncodePublicKey(publicKeyHex string, masterRelay string) (string, error) { +func EncodePublicKey(publicKeyHex string) (string, error) { b, err := hex.DecodeString(publicKeyHex) if err != nil { return "", fmt.Errorf("failed to decode public key hex: %w", err) } - tlv := make([]byte, 0, 64) - if masterRelay != "" { - relayBytes := []byte(masterRelay) - length := len(relayBytes) - if length >= 65536 { - return "", fmt.Errorf("masterRelay URL is too large") - } - - binary.BigEndian.PutUint16(tlv, 1) - binary.BigEndian.PutUint16(tlv, uint16(length)) - tlv = append(tlv, relayBytes...) - } - b = append(b, tlv...) - bits5, err := convertBits(b, 8, 5, true) if err != nil { return "", err