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

BUD-07 Paid storage #29

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

quentintaranpino
Copy link
Contributor

@quentintaranpino quentintaranpino commented Sep 10, 2024

BUD-07 paid storage

This pull request introduces BUD-07, a new specification outlining how servers can require and handle payments for blob storage. It defines the use of 402 Payment Required responses, with payment details provided via X-{payment_method} headers adhering to method-specific standards like Cashu (NIP-18) and Lightning (BOLT-11).

Additionally, it introduces support for recurring payments using Nostr events (Cashu via NIP-61 and Lightning via NIP-57), requiring an x tag to reference specific blobs.

The specification is designed to be extensible for future payment methods and includes guidance on client-server interactions.

Readable version here

@quentintaranpino quentintaranpino changed the title BUD07 Paid storage BUD-07 Paid storage Sep 10, 2024
Copy link
Owner

@hzrd149 hzrd149 left a comment

Choose a reason for hiding this comment

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

Looks great, a few formatting fixes and one comment. but I really like how simple this is

buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
quentintaranpino and others added 8 commits September 12, 2024 09:48
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
@quentintaranpino
Copy link
Contributor Author

L402 has been discarded in favor of a simpler approach that maintains the overall intent while adding compatibility with any L2, and potentially even other payment methods.

buds/07.md Outdated Show resolved Hide resolved
@hzrd149 hzrd149 mentioned this pull request Nov 11, 2024
@quentintaranpino
Copy link
Contributor Author

New version for the PR. This new version replaces the generic X-Payment header with dedicated headers for each supported payment method (e.g., X-Cashu, X-Lightning). This change improves clarity, scalability, and compatibility with future payment systems.

@quentintaranpino
Copy link
Contributor Author

  • Clarified the usage of X-{payment_method} headers to include payment details per specification of each method.
  • Adjusted schema to indicate encoding aligns with the corresponding method's spec (e.g., NUT-18 for Cashu, BOLT-11 for Lightning).
  • Improved examples for both X-Cashu and X-Lightning headers with real-world use cases.
  • Enhanced client implementation details, specifying that payment proof aligns with the selected method's spec.
  • Added extensibility guidelines for future payment methods, emphasizing publicly available specifications.
  • Updated error handling to include refreshed payment details on failure.

@quentintaranpino
Copy link
Contributor Author

Added recurring payments section with support for Cashu (NIP-61) and Lightning (NIP-57), requiring an 'x' tag for blob hash reference.

buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
buds/07.md Outdated Show resolved Hide resolved
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
quentintaranpino and others added 7 commits November 20, 2024 16:25
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com>
@hzrd149 hzrd149 mentioned this pull request Jan 2, 2025
@v0l
Copy link
Contributor

v0l commented Feb 2, 2025

Would it not be better to have a simple POST /payment and a way to check quota like GET /account?

Returning 402 status on upload makes sense when quota is exceeded but automatically returning an invoice seems wrong.

@v0l
Copy link
Contributor

v0l commented Feb 2, 2025

Im looking to implement payments in route96 and i think a "standard" approach would be better, should i make a PR for my idea of payments?

@quentintaranpino
Copy link
Contributor Author

quentintaranpino commented Feb 2, 2025

Would it not be better to have a simple POST /payment and a way to check quota like GET /account?

Returning 402 status on upload makes sense when quota is exceeded but automatically returning an invoice seems wrong.

I see what you mean, but I don’t think it’s incompatible. This BUD is just about what happens when you try to access a paid resource, it lays out the expected behavior when payment is required.

In my server (which this BUD is up and running 🤓), the client does a HEAD /upload, gets the cost of the upload (which could be 0 if they have balance), and then decides whether to pay or not. These kinds of decisions are up to the server admin, so I wouldn’t go into that in this BUD. Keeping it simple is best! 😊

But if you’re thinking of submitting another BUD for managing user accounts, I’ve got some ideas for GET /account, it could return more useful data beyond just the pubkey balance.

As for the POST you mentioned, maybe it could be a more general PUT/account endpoint, where users could manage their account settings on the server, create accounts?, and why not, also add funds. What do you think?

@quentintaranpino
Copy link
Contributor Author

@v0l you can try it here:

https://playground.nostrcheck.me/

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.

4 participants