nbd-wtf / go-nostr

Nostr library for Golang
MIT License
363 stars 102 forks source link

v0.17.0 can no longer post to wss://relay.damus.io #91

Closed marcopeereboom closed 1 year ago

marcopeereboom commented 1 year ago

It seems that the lib can no longer post to relay.damus.io when using commit: 0a3e898c2f62cdf1e8cdfa58d1e07e8ed104190b or c42059f4b49d01e056aea4a6ae8a0603926521ed.

Event is simple (somewhat simplified for readability):

        ev := nostr.Event{
                PubKey:    n.public,
                CreatedAt: time.Now(),
                Kind:      nostr.KindTextNote,
                Tags:      nil,
                Content:   msg,
        }
        ev.Sign(n.private)
        result, err := r.Publish(ctx, ev)
        if err != nil {
                n.printf("publishing error %v: %v\n", r, err)
        }
        if result == nostr.PublishStatusFailed {
                n.printf("could not send: %v\n", r)
        }

This ends up traveling through nostr.PublishStatusFailed path like so: could not send: wss://relay.damus.io and the damus client does indeed not receive the message.

Running the same code (minus the time modifications required by v0.17.0) works fine.

Was hoping someone would know what is up before I spend a bunch of time digging through the code.

fiatjaf commented 1 year ago

Did you try on 0.18.10?

marcopeereboom commented 1 year ago

Yep, it is where I started. Went from 0.16.0 to latest and worked my way back until it worked again.

go.mod excerpt

        ...
        github.com/nbd-wtf/go-nostr v0.18.10
        ...

Output from my client using the lib:

> /post this is a test
could not send: wss://nostr.wine
could not send: wss://nos.lol
could not send: wss://relay.snort.social
could not send: wss://relay.current.fyi
could not send: wss://relay.damus.io
fiatjaf commented 1 year ago

I just published this with https://github.com/fiatjaf/nak (which is using v0.18.7):

2023-06-13-092626_609x132_scrot

fiatjaf commented 1 year ago

You are missing the tags.

fiatjaf commented 1 year ago

Will add a clearer error for this case.

fiatjaf commented 1 year ago

5bbb6ba05b7e0aab44438065b319e6adbc08308c

marcopeereboom commented 1 year ago

This works. I do have one more question, did I misunderstand the NIP that tags for kind 1 are optional?

fiatjaf commented 1 year ago

Optional means they are an empty array.

marcopeereboom commented 1 year ago

Wouldn't it then not make more sense to define tags as an array instead of a pointer?

fiatjaf commented 1 year ago

Arrays are pointers in Go.