SimpleNostr

From Traxel Wiki
Jump to navigation Jump to search

Install

sudo apt install python3-venv
pip3 install virtualenv
git clone https://github.com/ksfi/simple-nostr.git
cd simple-nostr
python3 -m venv bobenv
source ./bobenv/bin/activate
pip3 install websockets secp256k1 bech32
python message.py
...
deactivate

Run and error:

python message.py 
ENTER A RELAY: (default: wss://relay.damus.io)
wss://127.0.0.1:7777
wss://127.0.0.1:7777
[msg] OR [msg] // [privkey] // [pubkey] OR q to quit OR enter to watch:
test
test
Traceback (most recent call last):
  File "/home/admin/projects/nostr/simple-nostr/message.py", line 181, in <module>
    run()
  File "/home/admin/projects/nostr/simple-nostr/message.py", line 178, in run
    asyncio.run(m.sendNote())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/admin/projects/nostr/simple-nostr/message.py", line 124, in sendNote
    note = json.dumps(["EVENT", self.to_json(dm_message, iv)], separators=(',', ':'), ensure_ascii=False)
  File "/home/admin/projects/nostr/simple-nostr/message.py", line 111, in to_json
    print(base64.b64encode(self.message).decode('utf-8'))
  File "/usr/lib/python3.9/base64.py", line 58, in b64encode
    encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'