Kukks / BTCPayServerPlugins

MIT License
25 stars 25 forks source link

No QR code, deeplink or URI to the connection URI for NIP47 of Nostr plugin? #63

Open johnheenan opened 3 days ago

johnheenan commented 3 days ago

NIP47 is implmented by the nostr plugin.

NIP47 specifes an implementation must provide a connection URI for nostr clients to use at https://github.com/nostr-protocol/nips/blob/master/47.md#theory-of-operation

I assume the conection URI is then used to build a call to the function below through a nostr relay event:

https://github.com/Kukks/BTCPayServerPlugins/blob/5cfe2e5acd40cd4b982c34871c2e084cdc0467fe/Plugins/BTCPayServer.Plugins.NIP05/NostrWalletConnectLightningConnectionStringHandler.cs#L20

I cannot find a way to determine the connection URI.

From https://github.com/nostr-protocol/nips/blob/master/47.md#nostr-wallet-connect-uri

Nostr Wallet Connect URI

client discovers wallet service by scanning a QR code, handling a deeplink or pasting in a URI.

The wallet service generates this connection URI with protocol nostr+walletconnect:// and base path it's hex-encoded pubkey with the following query string parameters:

The client should then store this connection and use it when the user wants to perform actions like paying an invoice. Due to this NIP using ephemeral events, it is recommended to pick relays that do not close connections on inactivity to not drop events.

Example connection string

nostr+walletconnect://b889ff5b1513b641e2a139f661a661364979c5beee91842f8f0ef42ab558e9d4?relay=wss%3A%2F%2Frelay.damus.io&secret=71a8c14c1407c113601079c4302dab36460f0ccd0ad506f1f2dc73b5100e4f3c
johnheenan commented 3 days ago

Here is the answer: https://github.com/Kukks/NNostr/blob/78753daa9c0a81adebab1b50ebea923de654036a/NNostr.Client/Protocols/NIP67.cs#L110

return (NIP47.CreateUri(e.GetPublicKey(), key,relay, lud16:payload.Lud16), payload);

NIP67 is the name @Kukks has given to code to construct the Network Wallet Connect URI. He has assigned NIP67 one nostr event kind so far: 33194.

The static function below in the same file is used for unit tests: https://github.com/Kukks/NNostr/blob/78753daa9c0a81adebab1b50ebea923de654036a/NNostr.Client/Protocols/NIP67.cs#L40

What does this mean in practice?

I guess Kukks want an extension to NIP47 to include the wallet service can also be discovered by nostr, not just QR code, deeplink or pasting a URI.

https://github.com/Kukks/NNostr/blob/master/README.md#relay shows how to add in a nostr relay to BTCPay with the NIP67 extension.

So nostr clients that want to use NWC with BTCPay will need to generate a custom event and probably include the BTCPay server as a relay to ensure the event does not get ignored.