nips/88.md
2023-06-29 14:58:28 +01:00

4.9 KiB

NIP-88

Nostr Cash (simple Nostr cash/token/cheque)

draft optional author:benarc

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.

Nostr Cash is simple and flexible. User gives a mint some money and the mint issues the user electromic cash/cheque/token that can be used as money in nostr.

Nostr Cash is entirely custodial and trust based, and is just a common standard for users to send/receive value in nostr. Keeping mints simple means more users can run, for themselves, their family, or the whole world.

Relays offering mints must have a keypair and an additional nostr keypair for its mint.

Nostr Cash uses derived keys, much like NIP26. Each "cash" is actually just a derived private key that can be burned or passed to another user.

All communication between the relay and user happen over NIP04.

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 cash wallet stores:

active:
    key: <string, derived private key/cash>, 
    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/cash>, 
    amount: <integer BTC millisat denomination>, 
    relay: <string, relay ws address>,
    relaykey: <string, public-key of relay>,
    timestamp: <integer timestamp> 

Workflows

Mint details

For fetching info about the mint.

User DMs the relay:

{
    "mint": <bool true>
}

Relay DMs user (maybe after a check if the relays mint has restricted access):

{
    "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

For creating new cash from a mint.

User DMs the relay:

{
  "amount": <integer millisats>
}

Relay responds with payment request, which user pays:

{
  "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:

{
  "key": <integer derived keypair number>,
  "amount": <integer BTC millisat denomination>, 
  "user": <string public-key of user>
}

Mint replies:

{
  "key": <string derived private key/cash>,
  "amount": <integer BTC millisat denomination>
}

User client stores:

{
  "key": <string derived private key/cash>,
  "amount": <integer BTC millisat denomination>,
  "relay": <string relay ws address>,
  "relaykey": <string public-key of relay>,
  "timestamp": <integer timestamp>
}

Claiming

For cashing in cash with the mint.

User DMs relay:

{
  "key": <String, derived private key/cash>,
  "amount": <Integer, BTC millisat denomination>,
  "type": <String, preffered payment method bolt11 bolt12 onchain stripe paypal shitcoin etc>
}

Relay DMs user:

{
  "type": <String, bolt11 bolt12 onchain stripe paypal shitcoin etc>
}

User DMs relay:

{
   "request": <String, payment-request bolt11 bolt12 onchain stripe paypal shitcoin etc>,
}

Sending

For sending cash to another nostr user.

User DMs relay:

{
  "key": <String, derived private key/cash>,
  "amount": <Integer, BTC millisat denomination>,
  "type": <String, public key of recipient>
}

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.

Relay DMs user(s):

{
  "key": <string derived private key/cash>,
  "amount": <integer BTC millisat denomination>
}

User(s) client stores:

{
  "key": <string derived private key/cash>,
  "amount": <integer BTC millisat denomination>,
  "relay": <string, relay ws address>,
  "relaykey": <string public-key of relay>,
  "timestamp": <integer timestamp>
}