diff options
| author | Pablo Fernandez <pfer@me.com> | 2025-01-28 20:26:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-28 16:26:21 -0300 |
| commit | 36c48ca128c963b78469855d0e48fa6c1097269b (patch) | |
| tree | caca7ca5dbf107aece9823263b3a907bae0ca35d /60.md | |
| parent | 70db801bb7fb258c10f4b2ec58056ef74df25549 (diff) | |
NIP-60: more consistent state transition (#1720)
Diffstat (limited to '60.md')
| -rw-r--r-- | 60.md | 19 |
1 files changed, 13 insertions, 6 deletions
| @@ -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" ], |
| @@ -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,6 +174,7 @@ 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 | ```jsonconc |
| 173 | { | 180 | { |