Skip to content
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

feat: add nip47 notifications endpoint #60

Merged
merged 6 commits into from
May 28, 2024
Merged

feat: add nip47 notifications endpoint #60

merged 6 commits into from
May 28, 2024

Conversation

im-adithya
Copy link
Member

@im-adithya im-adithya commented May 21, 2024

Fixes #54

}

subscription := Subscription{
RelayUrl: requestData.RelayUrl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this optional and we default to our relay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it defaults to cfg.DefaultRelayURL ("wss://relay.getalby.com/v1") when not set

README.md Outdated
> | relayUrl | optional | string | If no relay is provided, it uses the default relay |
> | webhookUrl | required | string | Webhook URL to publish events |
> | walletPubkey | optional | string | Public key of the wallet service |
> | pubkey | optional | string | Public key of the user |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should not be optional, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 I didn't know what to do here, it's actually either-or for pubkey and wallet pubkey. Even without specifying both we can still listen to response kind events on the relay, but yeah ideally we should provide both.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However if you don't (especially if you do not provide the pubkey), http-nostr will send extra events which cannot be decrypted with the subscriber's private key and will probably cause issues with the subscribing application. I think it actually makes sense to require them both to ensure the app is subscribing to what it thinks it's subscribing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you miss that if you build a wallet then you specify only the walletPubkey.

what can be subscribed should ultimately be up for some authentication. e.g. proof you are the wallet if you only subscribe to the walletPubkey
and proof you are the pubkey if you add the pubkey.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this either/or should be reflected in the docs. simply marking them both as optional is wrong.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I thought this was for the new NIP-47 notifications which are always sent in one direction, not for standard NIP-47 request/responses

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bumi if this is for notifications then I would say all are required, or if not, should notifications be a separate API endpoint so that the requirements and responses are clearly separated from this one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rolznz what do you mean?

for me this API was either for apps that want to subscribe to relevant notifications or for wallets.
but you're right, lets make it only for apps and we require a
wallet pubkey and a connection pubkey.

Copy link
Member Author

@im-adithya im-adithya May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, so now we require both connection pubkey and wallet pubkey, and we keep listening to all the notification events the user is receiving from the NWC wallet provider

That means:

  • This is not related to request / response events
  • This can also be implemented with the normal subscription handler, but this stands as a convenient way to subscribe to notifs

WebhookUrl: requestData.WebhookUrl,
Open: true,
Authors: &[]string{requestData.WalletPubkey},
Kinds: &[]int{23195},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for nip-47 notifications, right? it should be 23196

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

Copy link
Member Author

@im-adithya im-adithya May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for NIP-47 response events, so this should be good Changed to listen to NIP-47 notifications ✅

@im-adithya im-adithya changed the title feat: add nip47 subscription endpoint feat: add nip47 notifications endpoint May 28, 2024
@bumi bumi merged commit 14052de into main May 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add special NWC subscription endpoint
3 participants