From 002763669b9338962cf986a593f8687c6e0ca70f Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 15 Jul 2026 02:17:03 +0900 Subject: [PATCH] publish: don't put pubkey in the relay-hint position of NIP-22 E/e tags when there is no relay hint. --- publish.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/publish.go b/publish.go index c8f3904..601fd42 100644 --- a/publish.go +++ b/publish.go @@ -263,11 +263,12 @@ func buildNIP22Tags(evt *nostr.Event, target *nostr.Event, relayHints []string) // root scope tag rootScopeTag := nostr.Tag{rootScopeName, rootScopeValue} - if rootScopeRelay != "" { - rootScopeTag = append(rootScopeTag, rootScopeRelay) - } if rootScopeName == "E" && rootPubkey != "" { - rootScopeTag = append(rootScopeTag, rootPubkey) + // the pubkey goes in the 4th position, so the relay hint must be + // present (even if empty) to keep it there + rootScopeTag = append(rootScopeTag, rootScopeRelay, rootPubkey) + } else if rootScopeRelay != "" { + rootScopeTag = append(rootScopeTag, rootScopeRelay) } evt.Tags = append(evt.Tags, rootScopeTag) @@ -295,11 +296,11 @@ func buildNIP22Tags(evt *nostr.Event, target *nostr.Event, relayHints []string) evt.Tags = append(evt.Tags, aTag) } eTag := nostr.Tag{"e", target.ID.Hex()} - if relayHint != "" { - eTag = append(eTag, relayHint) - } if target.PubKey != (nostr.PubKey{}) { - eTag = append(eTag, target.PubKey.Hex()) + // same here: keep the pubkey in the 4th position + eTag = append(eTag, relayHint, target.PubKey.Hex()) + } else if relayHint != "" { + eTag = append(eTag, relayHint) } evt.Tags = append(evt.Tags, eTag) }