From e6dd124042f43d0817307851f6ef6f6a787da09d Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 13 Nov 2025 11:45:39 -0300 Subject: [PATCH] nip19: support empty "d" in naddr. --- nip19/nip19.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nip19/nip19.go b/nip19/nip19.go index 4d92b2c..bdc9de0 100644 --- a/nip19/nip19.go +++ b/nip19/nip19.go @@ -104,12 +104,13 @@ func Decode(bech32string string) (prefix string, value any, err error) { } case "naddr": var result nostr.EntityPointer + var hasIdentifier bool curr := 0 for { t, v := readTLVEntry(data[curr:]) if v == nil { // end here - if result.Kind == 0 || result.Identifier == "" || result.PublicKey == nostr.ZeroPK { + if result.Kind == 0 || !hasIdentifier || result.PublicKey == nostr.ZeroPK { return prefix, result, fmt.Errorf("incomplete naddr") } @@ -119,6 +120,7 @@ func Decode(bech32string string) (prefix string, value any, err error) { switch t { case TLVDefault: result.Identifier = string(v) + hasIdentifier = true case TLVRelay: result.Relays = append(result.Relays, string(v)) case TLVAuthor: