From 36c48ca128c963b78469855d0e48fa6c1097269b Mon Sep 17 00:00:00 2001 From: Pablo Fernandez Date: Tue, 28 Jan 2025 20:26:21 +0100 Subject: [PATCH] NIP-60: more consistent state transition (#1720) --- 60.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/60.md b/60.md index b2b0dd45..491bc479 100644 --- a/60.md +++ b/60.md @@ -57,7 +57,7 @@ Any tag, other than the `d` tag, can be [[NIP-44]] encrypted into the `.content` 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. ## Token Event -Token events are used to record the unspent proofs that come from the mint. +Token events are used to record unspent proofs. There can be multiple `kind:7375` events for the same mint, and multiple proofs inside each `kind:7375` event. @@ -73,7 +73,9 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs "secret": "z+zyxAVLRqN9lEjxuNPSyRJzEstbl69Jc1vtimvtkPg=", "C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46" } - ] + ], + // tokens that were destroyed in the creation of this token + "del": [ "token-id-1" ] }), "tags": [ [ "a", "37375::my-wallet" ] @@ -81,8 +83,11 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs } ``` -`.content` is a [[NIP-44]] encrypted payload storing the mint and the unencoded proofs. -* `a` an optional tag linking the token to a specific wallet. + * `a` an optional tag linking the token to a specific wallet. + * `.content` is a [[NIP-44]] encrypted payload: + * `mint`: The mint the proofs belong to. + * `proofs`: unecoded proofs + * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions. ### Spending proofs 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 "content": nip44_encrypt([ [ "direction", "in" ], // in = received, out = sent [ "amount", "1", "sat" ], - [ "e", "", "", "created" ], + [ "e", "", "", "created" ], ]), "tags": [ [ "a", "37375::my-wallet" ], @@ -160,7 +165,8 @@ Her client: { "id": "1", "amount": 1 }, { "id": "2", "amount": 2 }, { "id": "4", "amount": 8 }, - ] + ], + "del": [ "event-id-1" ] }), "tags": [ [ "a", "37375::my-wallet" ] @@ -168,6 +174,7 @@ Her client: } ``` * MUST delete event `event-id-1` +* SHOULD add the `event-id-1` to the `del` array of deleted token-ids. * SHOULD create a `kind:7376` event to record the spend ```jsonconc {