-
Notifications
You must be signed in to change notification settings - Fork 165
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
Nip47 #195
Comments
What is needed from the relay to support this? I don't think the relay needs to implement anything specific for it its done on the client side? |
@thesimplekid Not entirely sure. I'll do some testing. Is there a way to enable logging? When I send events to the relay I don't see any logs. |
Its been awhile since I've looked at it but if i remember correctly its a bit tricky to debug because they're ephemeral events they don't get stored to the DB only broadcasted to any clients listening so you can't check the DB for them, I put in a couple extra logging lines temporarily when i was doing it. Whats the issue you're having that leads you to question if its supported? |
@thesimplekid was just curious if it was supported. I was running it locally and was trying to get a small client to use nip 47 against the relay. Here's a snippet of the code I was using which in itself could be incorrect. async fn nip_47_request() -> Result<()> {
let nwc_uri = std::env::var("NWC_URI").expect("NWC_URI not set");
let nwc_uri = NostrWalletConnectURI::from_str(&nwc_uri).unwrap();
info!("\n{nwc_uri}\n");
let secret = nwc_uri.secret.clone();
let signer: Keys = Keys::new(secret);
let client = Client::new(signer);
client.add_relay(nwc_uri.relay_url.clone()).await?;
client.connect().await;
println!("Connected to relay {}", nwc_uri.relay_url.clone());
let req = nip47::Request::get_info().clone();
let req_event = req.to_event(&nwc_uri).unwrap();
loop {
match client.send_event(req_event.clone()).await {
Ok(event_id) => {
info!("event_id: {}", event_id);
sleep(Duration::from_secs(30)).await;
}
Err(err) => {
sleep(Duration::from_secs(300)).await;
error!("error: {}", err);
}
}
}
} |
@thesimplekid If I send a nip1 I can see the following logs from the relay.
But if I send nip47 messages using the function I shared earlier I don't see anything really indicative that it supports nip47.
|
NIP47 uses ephemeral events so they are not persisted to the db so you shouldn't expect to the the
But it looks like the relay is receive is getting the event. Do you have any clients subscribed to listen for the event?
There is no specific support the relay needs to provide for NIP47 other then ephemeral event passing |
Here's a snippet I'm using to listen for events but I don't see any events. let mut filters_vec = Vec::new();
let subscription = Filter::new()
.kind(Kind::WalletConnectRequest)
.since(Timestamp::now());
filters_vec.push(subscription);
client.subscribe(filters_vec.clone(), None).await;
loop {
let events = client
.get_events_of(filters_vec.clone(), Some(Duration::from_secs(5)))
.await?;
info!("events: {:?}", events);
sleep(Duration::from_secs(5)).await;
} Perhaps my subscription filter isn't working for nip 47. If I use events: [Event { id: EventId(0xc5bc7fd34a50c25ee0c5842d7e6edde8166a6f85db02865c23fec0a8d94bf063), pubkey: PublicKey { inner: XOnlyPublicKey(68966f0d6709bfb0967b9aa29106f18b614c24abfb0e2872b071b20a5394e76b16f1118f92b0c9b91891b69dd60acd8c517fd3dc90958736c232ed732dc33c4f) }, created_at: Timestamp(1715607200), kind: TextNote, tags: [], content: "yolo from rust-nostr!", sig: Signature(d1f0fd1a600530b7e0e7bf5776fa341938220f29bba67d278059d179a36b697a2cedf239b319ec3473d0394759f679950b1bce8dcbd23f5cf03c499077340035) }] |
I think the issue is with your listening code not the relay. You subscribe here
But you're not actually listening for that subscription. You are then later calling You need to handle notifications on the active subscription. Here is a good example you should be able to modify for NWC events. |
@thesimplekid Even when not persisting the nip47 events, would it be possible to send an OK relay message? Because now the sender of a nip47 event doesn't know if the relay accepted it and passed it to the active subscriptions or not. And following nip01, the relay should indicate the acceptance or denial of all events with an OK message. I created a separate issue for this since it seems to be a general problem: #220 |
Hi,
Do you have plans to support Nip47?
The text was updated successfully, but these errors were encountered: