Closed (fixed)
Project:
Nostr Simple Publish
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Feb 2023 at 12:18 UTC
Updated:
16 Mar 2023 at 08:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sebastixI was quickly testing the publishing to my own (private) relay (wss://nostr.sebastix.dev) from my local dev environment but I don't see any incoming requests when inspecting the logs. No exception is thrown in the code. Also with the provided relay wss://nostr.pleb.network from the readme config it doesn't work.
I've done some debugging with reading out the response with
$client->recieve()which returned from both relays:["OK","b33...c33",false,"invalid: event id does not match"]Something is going wrong on signing the event and setting the event id?
Validating the event is maybe be a good extra step? Like is done here: https://github.com/nbd-wtf/nostr-tools/blob/master/event.ts#L81
Some env info:
- SMP Debian 5.10.149-1 (2022-10-17) aarch64 GNU/Linux
- PHP 8.1.16
- GMP version => 6.2.1
Comment #4
swentel commentedHmm, that's unfortunate - maybe the json_encode isn't doing things right, even though I added tests yesterday for it when converting the hash generation.
Just wondering: what was the contents of the text? That might be a clue and I can try and see if that fails in the test.
As for validation: I think validateEvent() isn't a bad idea, but I don't think that's the problem here, rather something with the text.
I wonder if there's some validation code for figuring out if the id is fine, I'm more interested in that.
That said, I think it would be good catch that exception, show a message and not store the nid in state (which at some point should become different, but that's for #3344529: Store the id when the response is succesful)
Comment #5
sebastixThis is an example of a event before it's being signed,
$event:and this is the output of
$messagewhich is being send:I've no clue either for now :)
Comment #6
swentel commentedNote: I can confirm that it doesn't work right now, which is of course annoying. Will debug further tonight.
Comment #8
swentel commentedSo, this is extremely weird. For some reason, the generation of the id in combination with the signature fails when using json_encode. Even though the tests pass for both, something is not right, and I have no clue what yet.
So, for now, I've reverted the PHP package to use the old variation and opened https://github.com/swentel/nostr-php/issues/6 to investigate later.
I've tagged a new release (1.0.5) and also alpha2 for this module: it also inspects the client response (based on your initial code).
Also added a permission to view debug information when sending a post and also logs error messages to watchdog as well.
So upgrading those two packages should make it work (it at least did here, posted a new message to the network)
Comment #9
sebastixJust did a first test after updating the module:
second try:
Looks like this second try succeeded!
I've found the note in the database of my relay.
Nice work with the debugging part =)
Comment #10
sebastixFYI when I add newlines to the content, it fails signing the the event.
Without newlines, the signing succeeds.
Comment #11
swentel commentedOh wait, the newlines might indeed be the problem. From NIP-01 (emphasis mine)
To obtain the event.id, we sha256 the serialized event. The serialization is done over the UTF-8 JSON-serialized string (with no white space or line breaks) of the following structure.
Added that on github
Comment #12
swentel commentedUpdate: confirmed that with the previous hash generation, the post isn't sent either, so yes, it's newlines, I should be able to fix that quickly!
Comment #15
swentel commentedSo it turned out to be a mix of problems, see https://github.com/swentel/nostr-php/issues/6#issuecomment-1450928213 for more background.
Tagged new releases for this module and the package. All should be good now! :)
Comment #16
sebastixNice!
I just have look at NIP-23:
https://github.com/nostr-protocol/nips/blob/master/23.md
Could be relevant for configuraring a Nostr field which can be a markdown formatted text in someway.