Now also added the ability to use your lightning address as nip-05 verification.

https://github.com/niteshbalusu11/rustdress

Reply to this note

Please Login to reply.

Discussion

In you code "commentAllowed" equal 50 but in the checking sent comment you have a max 280 length. May be there is mistake?

May be it's because "length" returns in bytes but you want a length of utf-8 characters? But your test doesn't take an account for latin letters - I can send 280 characters.

Can you give me the test string you’re sending?

I run the code by eyes :)))

You have great eyes! :D

Thank you for auditing my shitty rust code. My first ever rust repo, lol.

But 280 and 50 are very similar to how the length of bytes to a string correlates with utf-8. For the largest character with 32 bits, 6 bytes are needed. Maybe you took this piece of code with such an original meaning somewhere?

P.S. I don't know the Rust and don't know length method of string there... :) (Bytes or utf-8 characters?)

https://doc.rust-lang.org/nightly/std/primitive.str.html#method.len

It's in bytes. So for utf-8 to be need multiplication x6 but better to use utf-8 libraries IMHO

Cool, I’ll fix it.

Yeah I took that return json from a JS version or nips repo. Can’t remember.

It is indeed a mistake, thank you for catching that.

If possible - a wish. It would be better if the public key and the private one could be set in bech32 encoding with prefixes. Firstly, the user will not confuse the private key with the public one by mistake and will not accidentally reveal it. Also, he will not have to look for decoders, since many Nostr clients give the user already encoded bech32 keys. This also reduces the risk of private key leakage through decoders. In addition, you already use the bech32 functions for encoding - there is already the same module for decoding.

Cool. Good idea, I'll just allow for both hex and bech32. Should be easy.

Thank you! I will run your server soon, I hope :)

Added it. You can enter hex or bech32 now.

Thank you!