nostr-ruby
nostr-ruby copied to clipboard
Error with `Nostr::Bech32` encode and decode
Readme Bech32 methods does not work anymore on v0.3.1, either encode_<type> or decode are crashing.
For example, from Rails 8.1 console:
note_data = Nostr::Bech32.decode("note1xzce08egncw3mcm8l8edas6rrhgfj9l5uwwv2hz03zym0m9eg5hsxuyajp")
# => undefined method 'decode' for module Bech32 (NoMethodError)
# hrp, data, spec = Bech32.decode(string, string.length)
# ^^^^^^^
or
note = Nostr::Bech32.encode_note("30b1979f289e1d1de367f9f2dec3431dd09917f4e39cc55c4f8889b7ecb9452f")
# => undefined method 'convert_bits' for module Bech32 (NoMethodError)
# Bech32.encode(hrp, Bech32.convert_bits([data].pack('H*').unpack('...
# ^^^^^^^^^^^^^
# Did you mean? const_set
Damn, we need a test suite. I will look at this asap.
Thanks for looking into the crash.
~~I'm not sure if it is related to nostr_ruby or the bech32 gem as I couldn't make it work either following bech32 README instructions bypassing your Nostr::Bech32 wrapper.~~
Edit: bech32 instructions works in irb console but not in Rails one so probably a conflict with your wrapper.