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 Cashu payments #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0
- [BUD-03: User Server List](./buds/03.md)
- [BUD-04: Mirroring blobs](./buds/04.md)
- [BUD-06: Upload requirements](./buds/06.md)
- [BUD-07: Paid upload and download](./buds/07.md)
- [BUD-08: Nostr File Metadata Tags](./buds/08.md)

## Event kinds
Expand Down
36 changes: 36 additions & 0 deletions buds/07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BUD-07
======

Paid upload and download
------------------------

`draft` `optional`

Cashu payments for uploads and downloads

## Paid Upload

The server may require payment for uploading blob by returning a `402` status code the `PUT /upload` endpoint (and `HEAD /upload` if [BUD-06](./06.md) is supported)

## Paid Downloads

The server may also require payment for downloads by responding with a `402` status code for `GET /<sha256` and `HEAD /<sha256>` endpoints

## Payment Flow

When the server is requesting payment for an endpoint it MUST respond with `402` and a `X-Cashu` header containing a base64 encoded json object (payment request)

The payment request should contain an `amount`, `mints`, `unit`, and `pubkey` fields

- `amount` The amount of ecash being requested
- `mints` An array of mints that this server uses
- `unit` The cashu `unit` from the `mints`
- `pubkey` (optional) a 33 byte pubkey to lock the tokens too. see [NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md)

When the client receives a `402` response and with a `X-Cashu` header it may retry the request with a payment

The payment should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens)

## Payment Checks

Optionally a server may respond with `402` to the `HEAD /upload`, `HEAD /<sha156>` if it supports [BUD-06](./06.md)