nbd-wtf / nostr-tools

Tools for developing Nostr clients.
The Unlicense
685 stars 188 forks source link

wrong index for variant #385

Closed FliXii closed 5 months ago

FliXii commented 5 months ago

Hello, I am trying to retrieve how many relays are still holding a specific message and therefore i am trying to filter for id.

No matter what method for retrieving i use, get, querysnc or subscribemany, i always get:

image

My function looks like this:

image

what am i doing wrong? Thanks in advance

alexgleason commented 5 months ago

The error is coming from the relay, in this case strfry. Do other relays give the same error?

fiatjaf commented 5 months ago

What is the id you're giving there? Looks like it's an invalid id.

FliXii commented 5 months ago

What is the id you're giving there? Looks like it's an invalid id.

My functionm for posting a message retourns the proerty field id of an event, this is the one that i am using for the query as parameter id. The code for the post looks like this.

image

Or is the id something else? I thought i must be correct as invalid ids are rejected by the relays.

Regarding @alexgleason: I have used 5 different relays and as seen two on the screenshot have replied in the same way. I will try also to use some other ones.

fiatjaf commented 5 months ago

Try changing your code to this:

const event = await window.nostr.signEvent(baseEvent)
pool.publish(relays, event)
return event.id
FliXii commented 5 months ago

Hey thanks for the idea, i have tried it out but the resulting Id from your code is identical to the one i used via the hash function.

image

Results in

image

fiatjaf commented 5 months ago

If you change the pubkey you'll get a different id, that is probably what is happening there.

Anyway, what was your problem again? In your initial post you were getting an error from relays because (I guess) the id you were giving them. If you could run that part again and print out the id you were passing to the countActiveRelays function and then I can try it here locally that will be great.

FliXii commented 5 months ago

I have resolved the error now, the problem was the type of the id in the function parameters of countActiverelays, it has to be string[] instead of string. Now i dont get the stgfy error anymore from the relays, but still not the message back that i am trying to filter for. But i guess i will figure that or make a new post. Thanks anyways :-)