nostr:npub1efz8l77esdtpw6l359sjvakm7azvyv6mkuxphjdk3vfzkgxkatrqlpf9s4 I'm working on a full integration of NIP-19 in nostr:npub1phpdev2d38u5hzs4jrsh360mevh0rjctu9669quy97wu23u8sqdqpfha0j but as regular webdeveloper I'm struggling to write the correct low-level stuff with the encoding/decoding with the bits and bytes before all is being encoded with the bech32 helper.

Work in progress: https://github.com/nostrver-se/nostr-php/tree/nip19 and this is the writeTLVEntry() method where I'm taking care of this: https://github.com/nostrver-se/nostr-php/blob/nip19/src/Nip19/Nip19Helper.php#L200.

So I'm looking for some help / guidance 🤓 Can you help me along? 🙏

nostr:nevent1qvzqqqqqqypzp5ajw47utygd8rxq96nd29qeavk7wna3p9ck2qwh4fmnyc6mnugmqqs2aey35tc8vw6cn2nzg5nk2n3rfw6j6rsc2z30k57cvxgcyftxk9sy9myt6

Reply to this note

Please Login to reply.

Discussion

Happy to help! I have a library implemented you can use as an example. May be this can answer some of your questions already.

I already checked it, but handling the TLV data is not there so to me it seems incomplete if you check the NIP. But thats why we could collab on this to also include it in that package 😃

Ah, than I did not needed it before apparently 🤔. You mean the number following nsec, eg nsec1 of naddr3?

Or do you mean the fact that a pubkey and relays can be included?.That indeed I have not built 🙂

We could use https://github.com/nbd-wtf/nostr-tools/blob/master/nip19.test.ts as starting point. Converting the tests to php and then implementing the code.

I have been hacking on it today, but it seems to me thay the bech32 class in bitwasp does not play nice with tlv. I have no idea why, also the decode function does not allow for bechs longer than 90 chara,but in nostr-tools this limit is raised to 5000. I feel I need to fork and improve the bech32 encoding/decoding functions. What are your thoughts on this?

Can this help?

https://github.com/nostrver-se/nostr-php/issues/74

My idea: fork it, change it, show it how it works (I don't this either, that's the part I need to learn) and reach out to the maintainers with your findings (but I see there is not much activity in the repo)?

Yes, doing that indeed, I will just recreate something based on de scure-base typescript repo

Note from nostr:npub100mahqlhxg50thmt5dyynu40nl25hat9kkkknzk8pqjfkvgq0xsqtdfyy5 he shared in the Nostr-PHP telegram group:

Apparently the 90 char limit is in the bech32 BIP https://bips.xyz/173#bech32

The library author probably didn't think of bech32 being used for anything other than encoding P2WPKH/P2WSH addresses

Still have to provide documentation, but it now supports different Bech32 kinds: https://github.com/nostriphant/nip-19

No, I thought that something like that was the case 😅