- Issue created by @swentel
- 🇳🇱Netherlands sebastian hagens Breda, Netherlands
I 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#L81Some env info:
- SMP Debian 5.10.149-1 (2022-10-17) aarch64 GNU/Linux
- PHP 8.1.16
- GMP version => 6.2.1 - @sebastian-hagens opened merge request.
- 🇧🇪Belgium swentel
Hmm, 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 📌 Store the id when the response is succesful Fixed )
- 🇳🇱Netherlands sebastian hagens Breda, Netherlands
This is an example of a event before it's being signed,
$event
:[ "pubkey" => "06639a386c9c1014217622ccbcf40908c4f1a0c33e23f8d6d68f4abf655f8f71" "created_at" => 1677589707 "kind" => 1 "tags" => [] "content" => "Just some basic text to send." ]
and this is the output of
$message
which is being send:["EVENT", { "pubkey":"06639a386c9c1014217622ccbcf40908c4f1a0c33e23f8d6d68f4abf655f8f71", "created_at":1677589707, "kind":1, "tags":[], "content":"Just some basic text to send.", "id":"cb91d5318e59f76c8f4d51a9d1bbcc695d71fa53ca147464db7644557e44b3ee", "sig":"2c3c0b5889a882be150451abf6a6e99de97de086b8fa0b9fadfc52577af52edfe19741d1bfc57832f60183d17bfbf215029abcf356a211117b2db3139695fa6e" } ]
I've no clue either for now :)
- 🇧🇪Belgium swentel
Note: I can confirm that it doesn't work right now, which is of course annoying. Will debug further tonight.
- Status changed to Fixed
almost 2 years ago 12:36pm 1 March 2023 - 🇧🇪Belgium swentel
So, 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 inspects the reponse (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)
- 🇳🇱Netherlands sebastian hagens Breda, Netherlands
Just did a first test after updating the module:
["EVENT", {"pubkey":"06639a386c9c1014217622ccbcf40908c4f1a0c33e23f8d6d68f4abf655f8f71","created_at":1677676139,"kind":1,"tags":[],"content":"Testing out this Drupal module https:\/\/www.drupal.org\/project\/nostr_simple_publish where you can publish a simple note from the CMS of Drupal.\r\n\r\nhttps:\/\/shares.sebastix.dev\/wfo2Q4Dy.png","id":"40a90b62182024289663e292db061695f110a29f7c04d32e7dd1e5676579ca1d","sig":"e3ac00170ce5e3a9949200c4a21eac5c10c6788c47e38198371a7fe60c75d550c2822d4edbc6a61aa1a81573856642786a965491bf5e14dac68e5c1d5742ebbe"}] Array ( [0] => OK [1] => 40a90b62182024289663e292db061695f110a29f7c04d32e7dd1e5676579ca1d [2] => [3] => invalid: event id does not match )
second try:
["EVENT", {"pubkey":"06639a386c9c1014217622ccbcf40908c4f1a0c33e23f8d6d68f4abf655f8f71","created_at":1677676398,"kind":1,"tags":[],"content":"Just a simple note test.","id":"d1a81126b72737cfcd33a266c2bda1d8a412a8a99b0bf03c33349bb4a413fbe2","sig":"f780aa23f161995bb385491dd4787b6611e34aba8765f0203f9a838f555fbd20c9b4047472cb0d7cac6e29120baaa7898fba8fa420930248febb4a8a04e75bd4"}] Array ( [0] => OK [1] => d1a81126b72737cfcd33a266c2bda1d8a412a8a99b0bf03c33349bb4a413fbe2 [2] => 1 [3] => )
Looks like this second try succeeded!
I've found the note in the database of my relay.Nice work with the debugging part =)
- 🇳🇱Netherlands sebastian hagens Breda, Netherlands
FYI when I add newlines to the content, it fails signing the the event.
["EVENT", {"pubkey":"06639a386c9c1014217622ccbcf40908c4f1a0c33e23f8d6d68f4abf655f8f71","created_at":1677677323,"kind":1,"tags":[],"content":"Another test with https:\/\/www.drupal.org\/project\/nostr_simple_publish but now with some newlines in this note.\r\n\r\nPrevious test failed with newlines.\r\nFYI =)","id":"68c5422bbd6d971012480a1c5eba96c54bbaadb3af851b0d94d3ca7b564c169d","sig":"25b0c83476206fc820b200150241f0d1913cbca5af93a1e8261dfe0ba25dfe4290dba5bf103cea70d446e54635118ad28e5f1c47dcd1a7f6fe9fc1478d649516"}] Array ( [0] => OK [1] => 68c5422bbd6d971012480a1c5eba96c54bbaadb3af851b0d94d3ca7b564c169d [2] => [3] => invalid: event id does not match )
Without newlines, the signing succeeds.
- 🇧🇪Belgium swentel
Oh 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
- 🇧🇪Belgium swentel
Update: 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!
- 🇧🇪Belgium swentel
So 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! :)
- 🇳🇱Netherlands sebastian hagens Breda, Netherlands
Nice!
I just have look at NIP-23:
https://github.com/nostr-protocol/nips/blob/master/23.mdCould be relevant for configuraring a Nostr field which can be a markdown formatted text in someway.
Automatically closed - issue fixed for 2 weeks with no activity.