nips icon indicating copy to clipboard operation
nips copied to clipboard

Recurring Subscriptions

Open pablof7z opened this issue 2 years ago • 15 comments

NIP to implement Patreon-style support.

Adds a way to:

  • Create support tiers (kind:7002)
  • Subscribe to support tiers (kind:7001)

Viewable: https://github.com/nostr-protocol/nips/blob/nip88/88.md

pablof7z avatar Nov 05 '23 11:11 pablof7z

Very cool!

I'd like to see a way to tell the NWC service (or a DVM) to keep paying the 7001 event until that event gets deleted.

It must be a service to avoid missing payments (in case the user doesn't open a client on that day) and also avoid double payments in case the zap event disappears (relay is offline or busy for a day or so).

vitorpamplona avatar Nov 05 '23 14:11 vitorpamplona

@vitorpamplona

I'd like to see a way to tell the NWC service (or a DVM) to keep paying the 7001 event until that event gets deleted.

I would love to see some NWC interactions as well, though I'm concerned about it triggering based on seeing something end it. We can't guarantee the wallet is going to see deleted events or the stop event if we take @benthecarman's suggestion.

AnthonyRonning avatar Nov 05 '23 19:11 AnthonyRonning

While I agree that nwc should be used for giving invoices to the user, I don't see where it really fits into this nip outside of a recommendation section.

Maybe this nip should be incorporated into #851 somehow. Like tagging which subscription event you are creating the nwc for.

benthecarman avatar Nov 05 '23 20:11 benthecarman

Creating the 7001 event and sending to the NWC relay could mean that the NWC service is authorized by the user to get an invoice and pay that invoice in the appropriate cadence.

Or maybe it's just an extra event that has the 7001 inside of it that tells the NWC service to pay periodically.

However, I'd like to see a way to tag which NWC service is authorized to pay each subscription in case the user has multiple NWC services setup.

vitorpamplona avatar Nov 05 '23 23:11 vitorpamplona

Creating the 7001 event and sending to the NWC relay could mean that the NWC service is authorized by the user to get an invoice and pay that invoice in the appropriate cadence.

Or maybe it's just an extra event that has the 7001 inside of it that tells the NWC service to pay periodically.

However, I'd like to see a way to tag which NWC service is authorized to pay each subscription in case the user has multiple NWC services setup.

There's not really a concept of NWC services on a nostr level yet, I feel that it would be out of scope for this NIP. And any person can forward an event to "an NWC relay" (which there also isn't an exclusive concept of) so I don't think that would work either.

AnthonyRonning avatar Nov 06 '23 01:11 AnthonyRonning

There's not really a concept of NWC services on a nostr level yet,

The NWC wallet service replies to payment requests with signed events (kind:23195). The pubkey used for those responses could be used to identify which NWC service is supposed to be paying the 9001 subscription. We could add that key directly as a tag in the 9001.

Clients already use that key to identify the NWC wallet service. So that could be very easy to integrate.

vitorpamplona avatar Nov 06 '23 02:11 vitorpamplona

I envisioned something along the following lines, using the new NIP49 proposal:

  • Next to their LUD16 a user has a Zapplepay-like service in their profile identified by pubkey/relay
  • Subscriber produces a 7001 event signaling intent to subscribe
  • The NWC service of the subscriber (Alby/Zapplepay) picks up the 7001 (and optionally asks the user for confirmation in some way through DM/email/notificiation) and then sets up the connetion with the service described above. The connection has a budget/period and also the 7001 event is referenced when setting up the connection.
  • The Zapplepay-like service of the receiver is responsible for generating the invoices on behalf of the user in due time and using the NWC connection to pay them. It will also produce the zap event but clients should recognise that this is actually the 7001 author zapping. The subscriber should probably also get notified if an automatic payment like this happens.
  • Cancelling probably be just deleting the NWC connection on the sender side. Clients need to validate the payments anyway, the 7001 event in itself doesn't mean much.

kiwiidb avatar Nov 07 '23 02:11 kiwiidb

I can see something like that working. Though ideally there's no external NWC third party necessary. I'm a bit concerned of the centralizing factor here for third parties storing user NWC strings, especially if it becomes a "one string to rule them all" scenario instead of a specific string per subscription action. It'll lead to needing bigger budgets set on the wallet side and will lead to more trust that the service provider doesn't steal as much of the user's funds as possible.

I'd like to see services with subscription capabilities bring their own NWC capabilities in house, or keep it on the nostr client side. If an NWC service is needed just to set a cron job, then I'd like that service to be as trustless and servicable by anyone as possible. I don't like that zapplepay has to be a thing, it's a hack and I don't want to see it being part of important integration points for nostr.

AnthonyRonning avatar Nov 07 '23 16:11 AnthonyRonning

Maybe we can invert the architecture here. What if the pubkey receiving subscriptions must own a server that periodically parses 7001 events and sends ln invoices for payment in the cadence it offers? This would simulate the traditional way of paying for things (you have to create invoices and send them out when they are due).

That service can send the invoice over regular DMs OR we can create a new event kind (e.g. 7002) to carry the ln invoice in such a way that clients can create specific UIs for their payment, including automatically paying them with a Zap when they arrive.

Since the service already created the LN Invoice, it's not likely that it will accept double payment in the same invoice.

Payments then may be late, since there is no 24/7 service running on the subscriber side, but it could be ok.

vitorpamplona avatar Nov 07 '23 16:11 vitorpamplona

What if the pubkey receiving subscriptions must own a server that periodically parses 7001 events and sends ln invoices for payment in the cadence it offers

Yeah I think that would be similar to my "services bring NWC in house" comment. Though I think it would work with NWC as is, I don't think it needs a new event kind.

Regarding the "must own a server part", couldn't individual users take advantage of this as well? IE, Alice set up a subscription tier for her own npub, Bob wants to "subscribe" to Alice. Bob gives Alice a specific NWC meant for her, with appropriate budgets set up, and when Alice comes online in her nip88 aware client, she sends Bob an invoice via NWC. It would work better with a monthly cadence due to the async nature, but it still allows individual control and no server needed.

AnthonyRonning avatar Nov 07 '23 16:11 AnthonyRonning

Bob gives Alice a specific NWC meant for her

This sounds weird. It's like giving my vendor a user/password access to my bank account so my vendor can pay their own invoices by themselves. Sure, we can set things up to make everything work within the budget, but it's still weird granting people the right to spend in my wallet.

Alice comes online in her nip88 aware client

If the responsibility of keeping the cadence is with the subscription receiver, then sure. If Alice is late because she didn't connect her NIP88-aware client, it's her fault. But being late will make things messy (people like exact predictability, e.g. invoices come on the 1st day of the month). I still think a better user experience should have a server for the cron job.

no server needed

Isn't the NWC a server? Otherwise, the 23194 payment request event, which is ephemeral, might never be seen by the NWC. Looks like this method requires both clients (Alice's sender and Bob's payer) to be online at the same time to make sure the ephemeral event is processed.

vitorpamplona avatar Nov 07 '23 16:11 vitorpamplona

weird granting people the right to spend in my wallet

At the end of the day, it's a payment request, not an explicit spend. Almost every payment app that exists allows payment requests to occur and internal controls around it.

Isn't the NWC a server

No, it's not. It works just fine with Mutiny mobile wallets. The requirement for server is not necessary, the user pulls these down themselves.

23194 payment request event, which is ephemeral

That's why I created this awhile back: https://github.com/nostr-protocol/nips/issues/537

The Mutiny nostr relay stores these in order for users to be able to retrieve them when they are offline. Making NWC ephemeral & basically synchronous is a design flaw IMO.

I'll bring up that there's a lot of things in flight with NWC still and as long as some model can work with nip88, I don't think we absolutely have to know what that should be yet. That's just my opinion, I don't want to hijack nip88 with comments around NWC but I'll leave with those thoughts. I do think there's a lot of ways this can play nicely with NWC (or potentially NWC services if we expand upon those more) but I don't think it's an absolute requirement.

AnthonyRonning avatar Nov 07 '23 16:11 AnthonyRonning

Agree, the connection to NWC shouldn't stop this PR.

Let's not forget a lot of people don't like using NWC, so we may need to make an option that is fully manual.

I think the cron job to send invoices should be a DVM. The receiver pays the DVM to send invoices to everyone.

vitorpamplona avatar Nov 07 '23 17:11 vitorpamplona

Ok, made quite a few updates; moved the tier event to a 37001 to use NIP-33, subscribing events can keep a copy of the subscribed event.

pablof7z avatar Nov 23 '23 15:11 pablof7z

NIP88 in its current form has been implemented in the NostrDVM framework and noogle client.

believethehype avatar Mar 24 '24 12:03 believethehype