Why Nostr? What is Njump?
2024-06-23 13:21:55

Vitor Pamplona on Nostr: Wen Cashu-native zaps? ...

Wen Cashu-native zaps?
# Cashu Wallet
A cashu wallet is a wallet which information is stored in relays to make it accessible across applications.

A user can have multiple wallets.

## Cashu relay list
```js
{
"kind": 10019,
"tags": [
[ "relay", "wss://relay1" ],
[ "relay", "wss://relay2" ],
]
}
```

Users can list specific relays where their cashu wallets are to be found. If not specified, clients SHOULD use the users [[NIP-65]] relays.

## Wallet Event
```js
{
"kind": 37375,
"content": nip44_encrypt([
[ "relay", "wss://relay1" ],
[ "relay", "wss://relay2" ],
[ "proof", "event-id-1" ],
[ "proof", "event-id-2" ],
[ "description", "a wallet for my day-to-day shitposting" ],
[ "balance", "100", "sats" ]
]),
"tags": [
[ "d", "my-wallet" ]
]
}
```

The wallet event is paramaterized replaceable event `kind:37375`. `.content` can be empty or a description of the wallet.
A wallet can specify canonical relays that should be queried for the most up-to-date state of the wallet. If not specified, clients SHOULD use the users [[NIP-65]] relays.

The content is a [[NIP-44]] encrypted list of tags.

* `balance` is a probable balance of the wallet that can serve as a placeholder while an accurate balance is computed from fetching all the unspent proofs.
* `proof` is a single event of an unspent proof

## Proofs Event
An individual event is

```js
{
"kind": 7375,
"content": nip44_encrypt([
{
"mint": "https://stablenut.umint.cash",
"proofs": [
{
"id": "005c2502034d4f12",
"amount": 1,
"secret": "z+zyxAVLRqN9lEjxuNPSyRJzEstbl69Jc1vtimvtkPg=",
"C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46"
}
]
]),
"tags": [
[ "a", "37375::my-wallet" ],
]
}
```

`.content` is a [[NIP-44]] encrypted payload of the proof.

## Keys Event
```js
{
"kind": 37376,
"content": nip44_encrypt(""),
"tags": [
[ "d", "my-wallet" ],
[ "passhprase", "" ] // optional tag indicating that an additional passhprase was used to encrypt the payload -- the description is an optional user-provided description that can help the user remember what passphrqase was used
]
}
```

This event stores the most recent version of the keys to this wallet. Encryption of this payload *can* include a passphrase to guard the user from accidentally providing access to an application that was granted blanket decryption permissions.

# Flow

## Fetch cashu relay list
A client that wants to check for user's wallets information starts by fetching `kind:10019` events from the user's relays, if no event is found, it should fall back to using the user's [[NIP-65]] relays.

## Fetch wallet list
From those relays, the client should
Author Public Key
npub1gcxzte5zlkncx26j68ez60fzkvtkm9e0vrwdcvsjakxf9mu9qewqlfnj5z