mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-10 06:09:08 -05:00
added nostr cash
This commit is contained in:
parent
57e9e8d92f
commit
4cf6ea7137
189
88.md
Normal file
189
88.md
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
NIP-15
|
||||||
|
======
|
||||||
|
|
||||||
|
Nostr Cash (simple Nostr ecash)
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
`draft` `optional` `author:benarc`
|
||||||
|
|
||||||
|
> Nostr Cash is not blinded by default.
|
||||||
|
|
||||||
|
Ecash is useful and relays should have the option to offer ecash mints. Other mints could exist as stand-alone clients, but relays are ideally placed to package in with their service offerings.
|
||||||
|
|
||||||
|
Users can use relays offering mints they trust, or mints and relays they don't trust but for smaller amounts.
|
||||||
|
|
||||||
|
The relay must have a keypair and an additional keypair for its mint.
|
||||||
|
|
||||||
|
Nostr Cash uses derived keys, much like [NIP26](https://github.com/nostr-protocol/nips/blob/master/26.md).
|
||||||
|
|
||||||
|
All communication between the relay and user happen over [NIP04](https://github.com/nostr-protocol/nips/blob/master/04.md).
|
||||||
|
|
||||||
|
The mints ledger is two tables `active` and `spent`:
|
||||||
|
|
||||||
|
```
|
||||||
|
active:
|
||||||
|
key: <integer, keypair deriviation number from master>,
|
||||||
|
amount: <integer BTC millisat denomination>,
|
||||||
|
user: <string, public-key of user>,
|
||||||
|
timestamp: <integer timestamp>
|
||||||
|
|
||||||
|
spent:
|
||||||
|
key: <integer, keypair deriviation number from master>,
|
||||||
|
amount: <integer BTC millisat denomination>,
|
||||||
|
user: <string, public-key of user>,
|
||||||
|
timestamp: <integer timestamp>
|
||||||
|
```
|
||||||
|
|
||||||
|
User client ecash wallet stores:
|
||||||
|
|
||||||
|
```
|
||||||
|
active:
|
||||||
|
key: <string, derived private key/ecash>,
|
||||||
|
amount: <integer BTC millisat denomination>,
|
||||||
|
relay: <string, relay ws address>,
|
||||||
|
relaykey: <string, public-key of relay>,
|
||||||
|
timestamp: <integer timestamp>
|
||||||
|
|
||||||
|
spent:
|
||||||
|
key: <string, derived private key/ecash>,
|
||||||
|
amount: <integer BTC millisat denomination>,
|
||||||
|
relay: <string, relay ws address>,
|
||||||
|
relaykey: <string, public-key of relay>,
|
||||||
|
timestamp: <integer timestamp>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Workflows
|
||||||
|
|
||||||
|
### Mint details
|
||||||
|
|
||||||
|
User DMs the relay:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mint": <bool true>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Relay DMs user (maybe after a check if the relays mint has restricted access):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"title": <string mints title>,
|
||||||
|
"description": <string mints description>,
|
||||||
|
"liquiity": <integer optional public millisat balance of mint>,
|
||||||
|
"type": <list different offered payment types bolt11 bolt12 onchain stripe paypal shitcoin etc>,
|
||||||
|
"fee": <integer millisat fee for internal nostr payments>,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Minting
|
||||||
|
|
||||||
|
User DMs the relay:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"amount": <integer millisats>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Relay responds with payment request, which user pays:
|
||||||
|
|
||||||
|
```json{
|
||||||
|
{
|
||||||
|
"request": <String, payment-request bolt11 bolt12 onchain stripe paypal shitcoin etc>,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Once paid the mint generates derived keypair from the mints private key, storing in table `active`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <integer derived keypair number>,
|
||||||
|
"amount": <integer BTC millisat denomination>,
|
||||||
|
"user": <string, public-key of user>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Mint replies:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <string derived private key/ecash>,
|
||||||
|
"amount": <integer BTC millisat denomination>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
User client stores:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <string derived private key/ecash>,
|
||||||
|
"amount": <integer BTC millisat denomination>,
|
||||||
|
"relay": <string, relay ws address>,
|
||||||
|
"relaykey": <string public-key of relay>,
|
||||||
|
"timestamp": <integer timestamp,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Claiming
|
||||||
|
|
||||||
|
User DMs relay:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <String, derived private key/ecash>,
|
||||||
|
"amount": <Integer, BTC millisat denomination>,
|
||||||
|
"type": <String, preffered payment method bolt11 bolt12 onchain stripe paypal shitcoin etc>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Relay DMs user:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": <String, bolt11 bolt12 onchain stripe paypal shitcoin etc>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
User DMs relay:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"request": <String, payment-request bolt11 bolt12 onchain stripe paypal shitcoin etc>,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sending
|
||||||
|
|
||||||
|
User DMs relay:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <String, derived private key/ecash>,
|
||||||
|
"amount": <Integer, BTC millisat denomination>,
|
||||||
|
"type": <String, public key of recipient>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Mint `burns` the old record for the ecash and creates a new record(s), depending on if sending user is owed change (the old record from `active` to `spent` table). The mint creates a new record in `active` and DMs the recipient user the private-key/ecash. If change is due, another record is created in `active` and sent back to the sender user.
|
||||||
|
|
||||||
|
Relay DMs user(s):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <string derived private key/ecash>,
|
||||||
|
"amount": <integer BTC millisat denomination>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
User(s) client stores:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"key": <string derived private key/ecash>,
|
||||||
|
"amount": <integer BTC millisat denomination>,
|
||||||
|
"relay": <string, relay ws address>,
|
||||||
|
"relaykey": <string public-key of relay>,
|
||||||
|
"timestamp": <integer timestamp,
|
||||||
|
}
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user