-
Notifications
You must be signed in to change notification settings - Fork 55
NUT-23: HTTP Payment required #239
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
base: main
Are you sure you want to change the base?
Conversation
This should reuse the payment request from NUT-18 and specify which fields need to be set #243 |
Looks ready. Please leave your reviews. We usually wait for an implementation before we merge. |
This is great! I have been waiting for this. For anyone building an implementation for this, here is an endpoint to test against: https://cashu402.fly.dev/secret |
It's nice to see more people building on the eCash has something really distinct and it's that "the token is the money" which means that people can use it as "proof of payment" (you send it to me and I claim it instantly). This is different from other payment methods where you can do pull based payments (ex: credit cards) or push based but you need to check if the payment was completed outbound (ex: Bitcoin) We have been working for a while with a generic flow that supports all kind of payment methods. The trade offs for ecash is
I understand why you want to create a NUT for this. Same of why x402 exists for "strictly on chain payments" but even in that case I would try to bake in the "multiple offer support" in. |
If you plan to keep I prefer sticking to an
For background, every currency has a I think this would be the best way to express pricing for 402 micropayment - in the fractional unit versus the base unit. A 1 cent per view versus $0.01 per view or 1 sat per view versus 0.000000000001BTC per view You can peruse my currency table dump below for more examples.
|
There is no such thing in Cashu. Amounts are always integers of the specified unit |
So, if "usd" can only specify whole dollars? |
A single unit of "usd" represents a dollar cent. There are no floats in the Cashu protocol. |
That's ok - if it's clarified in the spec. Currency is usually expressed as a main (base) unit and a fractional unit. I read the spec as the main unit, but it's actually the fractional unit. It wasn't apparent to me. Just wanting to reduce the potential confusion. FWIW From wikipedia Each currency typically has a main currency unit (the dollar, for example, or the euro) and a fractional unit, often defined as 1⁄100 of the main unit: 100 cents = 1 dollar, 100 centimes = 1 franc, 100 pence = 1 pound, although units of 1⁄10 or 1⁄1000 occasionally also occur. Some currencies do not have any smaller units at all, such as the Icelandic króna and the Japanese yen. |
I think this is out of scope for this NUT / PR. Cashu does not dictate anything about what "unit" can be. It can be a currency or something completely different. Also two mints can have key sets for different things that still share a name. The unit and "what it means" is only the mints responsibility and the spec can not specify anything about that. |
implemented in athenut thesimplekid/athenut-mint@723f8cd |
- `a`: The amount required in the specified unit | ||
- `u`: The currency unit (e.g., "sat", "usd", "api") | ||
- `m`: Array of mint URLs that the server accepts tokens from | ||
- `p2pk`: Optional P2PK requirements |
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.
Is P2PKOption defined anywhere?
Bump
|
Seems like this new nut is unnecessary with the change in #243 that makes the transport field optional. If the transport field in a payment request is undefined then the client can know to respond with payment in band. This PR does define the x-cashu behavior which is useful, but I wonder if it deserves a new nut? |
It helps to have the HTTP 402 process clearly spelled out in a NUT so that all servers and clients implementing it don't have to worry about 4+ different implementations ( which is usually what happens without clear instructions )
I don't know if it needs it own NUT, but it might make NUT-18 more crowded if it was merged into that |
I think it is worth keeping this in a separate NUT, as it defines the header structure and protocol (both are clearly not part of NUT-18 scope). |
This PR adds NUT-23 that describes how the HTTP 402 status code + an
X-Cashu
header can be used to require payment for http resourcesreadable version
The goal for this NUT is to keep it tightly coupled to HTTP and keep all communication in-band to reduce complexity.