-
Notifications
You must be signed in to change notification settings - Fork 584
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
NIP-47 notifications #1164
NIP-47 notifications #1164
Conversation
15f04cf
to
17739eb
Compare
+1. Anything is better than request/response |
17739eb
to
6a0ac09
Compare
6a0ac09
to
aad1941
Compare
47.md
Outdated
|
||
The info event should be a replaceable event that is published by the **wallet service** on the relay to indicate which commands it supports. The content should be | ||
a plaintext string with the supported commands, space-separated, eg. `pay_invoice get_balance`. Only the `pay_invoice` command is described in this NIP, but other commands might be defined in different NIPs. | ||
If the **wallet service** supports notifications, the info event SHOULD contain a `notifications` tag with the supported notification types space-separated, eg. `payment_received balance_changed`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide an event JSON example, as this isn't very clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is given: payment_received balance_changed
. It's a standard tag as per NIP-01.
However, for a full example I have fetched the info event here from my current NWC wallet (note: there's only payment_received
as only one notification type is implemented so far):
{
"id": "df467db0a9f9ec77ffe6f561811714ccaa2e26051c20f58f33c3d66d6c2b4d1c",
"pubkey": "c04ccd5c82fc1ea3499b9c6a5c0a7ab627fbe00a0116110d4c750faeaecba1e2",
"created_at": 1713883677,
"kind": 13194,
"tags": [
[
"notifications",
"payment_received"
]
],
"content": "pay_invoice pay_keysend get_balance get_info make_invoice lookup_invoice list_transactions multi_pay_invoice multi_pay_keysend sign_message notifications",
"sig": "31f57b369459b5306a5353aa9e03be7fbde169bc881c3233625605dd12f53548179def16b9fe1137e6465d7e4d5bb27ce81fd6e75908c46b06269f4233c845d8"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I know. I meant to add it to the spec to make it more obvious and clear for implementors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, implemented in NNostr https://github.com/Kukks/NNostr/blob/master/NNostr.Client/Protocols/NIP47.cs#L182
EDIT: Added a few new things to this PR:
|
aad1941
to
32b9f3f
Compare
|
Yana just added support for these notifications in https://github.com/frnandu/yana/releases/tag/v0.15.0 |
@fiatjaf can we merge this? |
@vitorpamplona could you merge it? |
This allows the wallet service to asynchronously send notifications to connected clients as an alternative to polling.
Example usecases:
Currently two notification types are defined -
payment_received
andpayment_sent
.This has been implemented in:
There are also some minor copy updates to communicate that NWC is not just for sending payments, but a protocol for connecting apps to lightning wallets.
Currently the notification type is encrypted in the payload, similar to existing responses. The downside is that clients cannot filter notifications - they would get all or none (or would have to be filtered on the wallet service level which is currently outside the spec).