diff options
| author | fiatjaf_ <fiatjaf@gmail.com> | 2025-01-30 23:21:21 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 23:21:21 -0300 |
| commit | 14d38014850930129e831b7ace25a9653e5d7095 (patch) | |
| tree | f0944fb005c9b700c0b199a0c02cf936d416c92d /60.md | |
| parent | 5eb515ceb97bdf0aa1570fb97ac510cd795bcf5a (diff) | |
| parent | f440eac3dccefa5c0ec9d3964e1d08357fd31e09 (diff) | |
Merge branch 'master' into video-events-regularvideo-events-regular
Diffstat (limited to '60.md')
| -rw-r--r-- | 60.md | 27 |
1 files changed, 17 insertions, 10 deletions
| @@ -39,7 +39,7 @@ This NIP doesn't deal with users' *receiving* money from someone else, it's just | |||
| 39 | } | 39 | } |
| 40 | ``` | 40 | ``` |
| 41 | 41 | ||
| 42 | The wallet event is a parameterized replaceable event `kind:37375`. | 42 | The wallet event is an addressable event `kind:37375`. |
| 43 | 43 | ||
| 44 | Tags: | 44 | Tags: |
| 45 | * `d` - wallet ID. | 45 | * `d` - wallet ID. |
| @@ -57,7 +57,7 @@ Any tag, other than the `d` tag, can be [[NIP-44]] encrypted into the `.content` | |||
| 57 | Due to addressable event being hard to delete, if a user wants to delete a wallet, they should empty the event and keep just the `d` identifier and add a `deleted` tag. | 57 | Due to addressable event being hard to delete, if a user wants to delete a wallet, they should empty the event and keep just the `d` identifier and add a `deleted` tag. |
| 58 | 58 | ||
| 59 | ## Token Event | 59 | ## Token Event |
| 60 | Token events are used to record the unspent proofs that come from the mint. | 60 | Token events are used to record unspent proofs. |
| 61 | 61 | ||
| 62 | There can be multiple `kind:7375` events for the same mint, and multiple proofs inside each `kind:7375` event. | 62 | There can be multiple `kind:7375` events for the same mint, and multiple proofs inside each `kind:7375` event. |
| 63 | 63 | ||
| @@ -73,7 +73,9 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs | |||
| 73 | "secret": "z+zyxAVLRqN9lEjxuNPSyRJzEstbl69Jc1vtimvtkPg=", | 73 | "secret": "z+zyxAVLRqN9lEjxuNPSyRJzEstbl69Jc1vtimvtkPg=", |
| 74 | "C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46" | 74 | "C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46" |
| 75 | } | 75 | } |
| 76 | ] | 76 | ], |
| 77 | // tokens that were destroyed in the creation of this token | ||
| 78 | "del": [ "token-id-1" ] | ||
| 77 | }), | 79 | }), |
| 78 | "tags": [ | 80 | "tags": [ |
| 79 | [ "a", "37375:<pubkey>:my-wallet" ] | 81 | [ "a", "37375:<pubkey>:my-wallet" ] |
| @@ -81,8 +83,11 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs | |||
| 81 | } | 83 | } |
| 82 | ``` | 84 | ``` |
| 83 | 85 | ||
| 84 | `.content` is a [[NIP-44]] encrypted payload storing the mint and the unencoded proofs. | 86 | * `a` an optional tag linking the token to a specific wallet. |
| 85 | * `a` an optional tag linking the token to a specific wallet. | 87 | * `.content` is a [[NIP-44]] encrypted payload: |
| 88 | * `mint`: The mint the proofs belong to. | ||
| 89 | * `proofs`: unecoded proofs | ||
| 90 | * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions. | ||
| 86 | 91 | ||
| 87 | ### Spending proofs | 92 | ### Spending proofs |
| 88 | When one or more proofs of a token are spent, the token event should be [[NIP-09]]-deleted and, if some proofs are unspent from the same token event, a new token event should be created rolling over the unspent proofs and adding any change outputs to the new token event. | 93 | When one or more proofs of a token are spent, the token event should be [[NIP-09]]-deleted and, if some proofs are unspent from the same token event, a new token event should be created rolling over the unspent proofs and adding any change outputs to the new token event. |
| @@ -96,7 +101,7 @@ Clients SHOULD publish `kind:7376` events to create a transaction history when t | |||
| 96 | "content": nip44_encrypt([ | 101 | "content": nip44_encrypt([ |
| 97 | [ "direction", "in" ], // in = received, out = sent | 102 | [ "direction", "in" ], // in = received, out = sent |
| 98 | [ "amount", "1", "sat" ], | 103 | [ "amount", "1", "sat" ], |
| 99 | [ "e", "<event-id-of-spent-token>", "<relay-hint>", "created" ], | 104 | [ "e", "<event-id-of-created-token>", "<relay-hint>", "created" ], |
| 100 | ]), | 105 | ]), |
| 101 | "tags": [ | 106 | "tags": [ |
| 102 | [ "a", "37375:<pubkey>:my-wallet" ], | 107 | [ "a", "37375:<pubkey>:my-wallet" ], |
| @@ -129,7 +134,7 @@ While the client is fetching (and perhaps validating) proofs it can use the opti | |||
| 129 | 134 | ||
| 130 | ## Spending token | 135 | ## Spending token |
| 131 | If Alice spends 4 sats from this token event | 136 | If Alice spends 4 sats from this token event |
| 132 | ```jsonconc | 137 | ```jsonc |
| 133 | { | 138 | { |
| 134 | "kind": 7375, | 139 | "kind": 7375, |
| 135 | "id": "event-id-1", | 140 | "id": "event-id-1", |
| @@ -150,7 +155,7 @@ If Alice spends 4 sats from this token event | |||
| 150 | 155 | ||
| 151 | Her client: | 156 | Her client: |
| 152 | * MUST roll over the unspent proofs: | 157 | * MUST roll over the unspent proofs: |
| 153 | ```jsonconc | 158 | ```jsonc |
| 154 | { | 159 | { |
| 155 | "kind": 7375, | 160 | "kind": 7375, |
| 156 | "id": "event-id-2", | 161 | "id": "event-id-2", |
| @@ -160,7 +165,8 @@ Her client: | |||
| 160 | { "id": "1", "amount": 1 }, | 165 | { "id": "1", "amount": 1 }, |
| 161 | { "id": "2", "amount": 2 }, | 166 | { "id": "2", "amount": 2 }, |
| 162 | { "id": "4", "amount": 8 }, | 167 | { "id": "4", "amount": 8 }, |
| 163 | ] | 168 | ], |
| 169 | "del": [ "event-id-1" ] | ||
| 164 | }), | 170 | }), |
| 165 | "tags": [ | 171 | "tags": [ |
| 166 | [ "a", "37375:<pubkey>:my-wallet" ] | 172 | [ "a", "37375:<pubkey>:my-wallet" ] |
| @@ -168,8 +174,9 @@ Her client: | |||
| 168 | } | 174 | } |
| 169 | ``` | 175 | ``` |
| 170 | * MUST delete event `event-id-1` | 176 | * MUST delete event `event-id-1` |
| 177 | * SHOULD add the `event-id-1` to the `del` array of deleted token-ids. | ||
| 171 | * SHOULD create a `kind:7376` event to record the spend | 178 | * SHOULD create a `kind:7376` event to record the spend |
| 172 | ```jsonconc | 179 | ```jsonc |
| 173 | { | 180 | { |
| 174 | "kind": 7376, | 181 | "kind": 7376, |
| 175 | "content": nip44_encrypt([ | 182 | "content": nip44_encrypt([ |