2023-06-29 07:14:01 -04:00
NIP-88
======
2023-06-29 09:11:13 -04:00
Nostr Cash (simple Nostr cash/token/cheque)
2023-06-29 07:14:01 -04:00
-----------------------------------
`draft` `optional` `author:benarc`
2023-06-29 09:11:13 -04:00
Electronic cash is useful and relays should have the option to offer minting/custodial services. Other mints could exist as stand-alone clients, but relays are ideally placed to package in with their service offerings.
2023-06-29 07:14:01 -04:00
Users can use relays offering mints they trust, or relays they don't trust but for smaller amounts.
Relays offering mints must have a keypair and an additional nostr keypair for its mint.
2023-06-29 09:11:13 -04:00
Nostr Cash uses derived keys, much like [NIP26 ](https://github.com/nostr-protocol/nips/blob/master/26.md ). Each "cash" is actually just a derived private key that can be burned or passed to another user.
2023-06-29 07:14:01 -04:00
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 >
```
2023-06-29 09:11:13 -04:00
User client cash wallet stores:
2023-06-29 07:14:01 -04:00
```
active:
2023-06-29 09:11:13 -04:00
key: < string , derived private key / cash > ,
2023-06-29 07:14:01 -04:00
amount: < integer BTC millisat denomination > ,
relay: < string , relay ws address > ,
relaykey: < string , public-key of relay > ,
timestamp: < integer timestamp >
spent:
2023-06-29 09:11:13 -04:00
key: < string , derived private key / cash > ,
2023-06-29 07:14:01 -04:00
amount: < integer BTC millisat denomination > ,
relay: < string , relay ws address > ,
relaykey: < string , public-key of relay > ,
timestamp: < integer timestamp >
```
## Workflows
### Mint details
2023-06-29 07:14:54 -04:00
**For fetching info about the mint.**
2023-06-29 07:14:01 -04:00
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
2023-06-29 09:11:13 -04:00
**For creating new cash from a mint.**
2023-06-29 07:14:01 -04:00
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
{
2023-06-29 09:11:13 -04:00
"key": < string derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"amount": < integer BTC millisat denomination >
}
```
User client stores:
```json
{
2023-06-29 09:11:13 -04:00
"key": < string derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"amount": < integer BTC millisat denomination > ,
"relay": < string relay ws address > ,
"relaykey": < string public-key of relay > ,
"timestamp": < integer timestamp >
}
```
### Claiming
2023-06-29 09:11:13 -04:00
**For cashing in cash with the mint.**
2023-06-29 07:14:01 -04:00
User DMs relay:
```json
{
2023-06-29 09:11:13 -04:00
"key": < String , derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"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
2023-06-29 09:11:13 -04:00
**For sending cash to another nostr user.**
2023-06-29 07:14:01 -04:00
User DMs relay:
```json
{
2023-06-29 09:11:13 -04:00
"key": < String , derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"amount": < Integer , BTC millisat denomination > ,
"type": < String , public key of recipient >
}
```
2023-06-29 09:11:13 -04:00
Mint `burns` the old record for the cash and creates a new record(s), depending on if sending user is owed change (the old record moves from `active` to `spent` table). The mint creates a new record in `active` and DMs the recipient user the private-key/cash. If change is due, another record is created in `active` and sent back to the sender user.
2023-06-29 07:14:01 -04:00
Relay DMs user(s):
```json
{
2023-06-29 09:11:13 -04:00
"key": < string derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"amount": < integer BTC millisat denomination >
}
```
User(s) client stores:
```json
{
2023-06-29 09:11:13 -04:00
"key": < string derived private key / cash > ,
2023-06-29 07:14:01 -04:00
"amount": < integer BTC millisat denomination > ,
"relay": < string , relay ws address > ,
"relaykey": < string public-key of relay > ,
"timestamp": < integer timestamp >
}
```