-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write Rust Nostr book #173
Comments
I'm missing a guide of how to receive nip-17 private direct messages. My code works fine with nip-04 encrypted messages and now I tried to migrate it to nip-17. On the sender side I'm sending with The code on the receiver side looks like this:
The problem is I don't get any events. I changed the kind to PrivateDirectMessage, but it doesn't work either, tough I think GiftWrap should be the right kind to receive. If I get the code working I would also contribute with a code example or a section in the book. |
Use It's available as example in the |
Ah, this makes sense and it works now. Thanks for your quick help. |
Hey there, I would like to try NIP17, I didn't know it was supported. Thank you for your work |
Hey, I would contribute a Rust example. Though, it'll be as early as next week, I'm now having some vacations. |
Check the Is not available a |
Hi, I just submitted a PR adding example code for NIP-17 to the book. You can take a look at the code in the PR as long as it is pending. |
Hello, Is there any plan to update the book? Thanks |
Hi, do you mean the examples in this folder? |
yes, some examples in that folder are no longer working like bot.py - which is sending TypeError: Expected Filter instance, list found when calling 'await client.subscribe([nip59_filter], None)' on line 24. But I was talking also about these:
where is that 'book'? |
Hello again, I have written a few updated code sample compatible with 0.39 can't figure out How to follow a given npub via nostr_sdk? |
Ah, I see, some example doesn't work. I'm using keys = Keys.generate()
client = Client(keys) # Wrong but for some reason doesn't return error with pyright, only on script execution
signer = NostrSigner.keys(keys)
client = Client(signer) # Correct I've manually tested all the examples and fixed at commit 0227d10
The one you linked: https://rust-nostr.org
Nice! Could be something like this: async def main():
keys = Keys.parse("nsec...")
client = Client()
await client.add_relay("wss://..")
await client.connect()
# Get current contact list
f = Filter().author(keys.public_key()).kind(Kind.from_std(KindStandard.CONTACT_LIST))
events = await client.fetch_events(f, timedelta(seconds=10))
event = events.first()
if event is not None:
# Get current contact public keys
public_keys: list[PublicKey] = event.tags().public_keys()
# Add new contact
new_public_key = PublicKey.parse("npub...")
public_keys.append(new_public_key)
# Convert public keys to contacts and create a new contact list event
contacts: list[Contact] = [Contact(public_key=public_key, relay_url=None, alias=None) for public_key in public_keys]
builder = EventBuilder.contact_list(contacts)
event = builder.sign_with_keys(keys)
# Send event to relays
await client.send_event(event)
else:
print("No contact list found") |
Thanks very much it works fantastically! |
.
The text was updated successfully, but these errors were encountered: