upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/60.md
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2026-04-10 13:31:37 -0500
committerAlex Gleason <alex@alexgleason.me>2026-04-10 13:31:37 -0500
commit5e1e24766910fc07cb61a049aed2623987458ec2 (patch)
treeb7588f61fddf9374268d5cd6f4e3f2655d7c840a /60.md
parentb8782df594b4e7e8f088869134908eed58be6078 (diff)
parent3465f540e3eaedccb5309711b502f0febf56b52f (diff)
Merge nip44-big-payloads into bigger-nip44bigger-nip44
Diffstat (limited to '60.md')
-rw-r--r--60.md39
1 files changed, 23 insertions, 16 deletions
diff --git a/60.md b/60.md
index 4d0c709..8c836ac 100644
--- a/60.md
+++ b/60.md
@@ -16,13 +16,13 @@ The purpose of this NIP is:
16 16
17This NIP doesn't deal with users' *receiving* money from someone else, it's just to keep state of the user's wallet. 17This NIP doesn't deal with users' *receiving* money from someone else, it's just to keep state of the user's wallet.
18 18
19# High-level flow 19## High-level flow
201. A user has a `kind:17375` event that represents a wallet. 201. A user has a `kind:17375` event that represents a wallet.
212. A user has `kind:7375` events that represent the unspent proofs of the wallet. -- The proofs are encrypted with the user's private key. 212. A user has `kind:7375` events that represent the unspent proofs of the wallet. -- The proofs are encrypted with the user's private key.
223. A user has `kind:7376` events that represent the spending history of the wallet -- This history is for informational purposes only and is completely optional. 223. A user has `kind:7376` events that represent the spending history of the wallet -- This history is for informational purposes only and is completely optional.
23 23
24## Wallet Event 24### Wallet Event
25```jsonc 25```javascript
26{ 26{
27 "kind": 17375, 27 "kind": 17375,
28 "content": nip44_encrypt([ 28 "content": nip44_encrypt([
@@ -40,16 +40,17 @@ Tags:
40* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags. 40* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags.
41* `privkey` - Private key used to unlock P2PK ecash. MUST be stored encrypted in the `.content` field. **This is a different private key exclusively used for the wallet, not associated in any way to the user's Nostr private key** -- This is only used for receiving [NIP-61](61.md) nutzaps. 41* `privkey` - Private key used to unlock P2PK ecash. MUST be stored encrypted in the `.content` field. **This is a different private key exclusively used for the wallet, not associated in any way to the user's Nostr private key** -- This is only used for receiving [NIP-61](61.md) nutzaps.
42 42
43## Token Event 43### Token Event
44Token events are used to record unspent proofs. 44Token events are used to record unspent proofs.
45 45
46There can be multiple `kind:7375` events for the same mint, and multiple proofs inside each `kind:7375` event. 46There can be multiple `kind:7375` events for the same mint, and multiple proofs inside each `kind:7375` event.
47 47
48```jsonc 48```javascript
49{ 49{
50 "kind": 7375, 50 "kind": 7375,
51 "content": nip44_encrypt({ 51 "content": nip44_encrypt({
52 "mint": "https://stablenut.umint.cash", 52 "mint": "https://stablenut.umint.cash",
53 "unit": "sat",
53 "proofs": [ 54 "proofs": [
54 // one or more proofs in the default cashu format 55 // one or more proofs in the default cashu format
55 { 56 {
@@ -69,21 +70,23 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs
69 * `.content` is a [NIP-44](44.md) encrypted payload: 70 * `.content` is a [NIP-44](44.md) encrypted payload:
70 * `mint`: The mint the proofs belong to. 71 * `mint`: The mint the proofs belong to.
71 * `proofs`: unencoded proofs 72 * `proofs`: unencoded proofs
73 * `unit` the base unit the proofs are denominated in (eg: `sat`, `usd`, `eur`). Default: `sat` if omitted.
72 * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions. 74 * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions.
73 75
74When one or more proofs of a token are spent, the token event should be [NIP-09](09.md)-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 (the change output should include a `del` field). 76When one or more proofs of a token are spent, the token event should be [NIP-09](09.md)-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 (the change output should include a `del` field).
75 77
76The `kind:5` _delete event_ created in the [NIP-09](09.md) process MUST have a tag `["k", "7375"]` to allow easy filtering by clients interested in state transitions. 78The `kind:5` _delete event_ created in the [NIP-09](09.md) process MUST have a tag `["k", "7375"]` to allow easy filtering by clients interested in state transitions.
77 79
78## Spending History Event 80### Spending History Event
79Clients SHOULD publish `kind:7376` events to create a transaction history when their balance changes. 81Clients SHOULD publish `kind:7376` events to create a transaction history when their balance changes.
80 82
81```jsonc 83```javascript
82{ 84{
83 "kind": 7376, 85 "kind": 7376,
84 "content": nip44_encrypt([ 86 "content": nip44_encrypt([
85 [ "direction", "in" ], // in = received, out = sent 87 [ "direction", "in" ], // in = received, out = sent
86 [ "amount", "1" ], 88 [ "amount", "1" ],
89 [ "unit", "sat" ],
87 [ "e", "<event-id-of-created-token>", "", "created" ] 90 [ "e", "<event-id-of-created-token>", "", "created" ]
88 ]), 91 ]),
89 "tags": [ 92 "tags": [
@@ -93,6 +96,7 @@ Clients SHOULD publish `kind:7376` events to create a transaction history when t
93``` 96```
94 97
95* `direction` - The direction of the transaction; `in` for received funds, `out` for sent funds. 98* `direction` - The direction of the transaction; `in` for received funds, `out` for sent funds.
99* `unit` the base unit of the amount (eg: `sat`, `usd`, `eur`). Default: `sat` if omitted.
96 100
97Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag: 101Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag:
98* `created` - A new token event was created. 102* `created` - A new token event was created.
@@ -103,24 +107,25 @@ All tags can be [NIP-44](44.md) encrypted. Clients SHOULD leave `e` tags with a
103 107
104Multiple `e` tags can be added, and should be encrypted, except for tags with the `redeemed` marker. 108Multiple `e` tags can be added, and should be encrypted, except for tags with the `redeemed` marker.
105 109
106# Flow 110## Flow
107A 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](65.md) relays. 111A 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](65.md) relays.
108 112
109## Fetch wallet and token list 113### Fetch wallet and token list
110From those relays, the client should fetch wallet and token events. 114From those relays, the client should fetch wallet and token events.
111 115
112`"kinds": [17375, 7375], "authors": ["<my-pubkey>"]` 116`"kinds": [17375, 7375], "authors": ["<my-pubkey>"]`
113 117
114## Fetch proofs 118### Fetch proofs
115 119
116## Spending token 120### Spending token
117If Alice spends 4 sats from this token event 121If Alice spends 4 sats from this token event
118```jsonc 122```javascript
119{ 123{
120 "kind": 7375, 124 "kind": 7375,
121 "id": "event-id-1", 125 "id": "event-id-1",
122 "content": nip44_encrypt({ 126 "content": nip44_encrypt({
123 "mint": "https://stablenut.umint.cash", 127 "mint": "https://stablenut.umint.cash",
128 "unit": "sat",
124 "proofs": [ 129 "proofs": [
125 { "id": "1", "amount": 1 }, 130 { "id": "1", "amount": 1 },
126 { "id": "2", "amount": 2 }, 131 { "id": "2", "amount": 2 },
@@ -134,12 +139,13 @@ If Alice spends 4 sats from this token event
134 139
135Her client: 140Her client:
136* MUST roll over the unspent proofs: 141* MUST roll over the unspent proofs:
137```jsonc 142```javascript
138{ 143{
139 "kind": 7375, 144 "kind": 7375,
140 "id": "event-id-2", 145 "id": "event-id-2",
141 "content": nip44_encrypt({ 146 "content": nip44_encrypt({
142 "mint": "https://stablenut.umint.cash", 147 "mint": "https://stablenut.umint.cash",
148 "unit": "sat",
143 "proofs": [ 149 "proofs": [
144 { "id": "1", "amount": 1 }, 150 { "id": "1", "amount": 1 },
145 { "id": "2", "amount": 2 }, 151 { "id": "2", "amount": 2 },
@@ -153,12 +159,13 @@ Her client:
153* MUST delete event `event-id-1` 159* MUST delete event `event-id-1`
154* SHOULD add the `event-id-1` to the `del` array of deleted token-ids. 160* SHOULD add the `event-id-1` to the `del` array of deleted token-ids.
155* SHOULD create a `kind:7376` event to record the spend 161* SHOULD create a `kind:7376` event to record the spend
156```jsonc 162```javascript
157{ 163{
158 "kind": 7376, 164 "kind": 7376,
159 "content": nip44_encrypt([ 165 "content": nip44_encrypt([
160 [ "direction", "out" ], 166 [ "direction", "out" ],
161 [ "amount", "4" ], 167 [ "amount", "4" ],
168 [ "unit", "sat" ],
162 [ "e", "<event-id-1>", "", "destroyed" ], 169 [ "e", "<event-id-1>", "", "destroyed" ],
163 [ "e", "<event-id-2>", "", "created" ], 170 [ "e", "<event-id-2>", "", "created" ],
164 ]), 171 ]),
@@ -166,12 +173,12 @@ Her client:
166} 173}
167``` 174```
168 175
169## Redeeming a quote (optional) 176### Redeeming a quote (optional)
170When creating a quote at a mint, an event can be used to keep the state of the quote ID, which will be used to check when the quote has been paid. These events should be created with an expiration tag [NIP-40](40.md) of 2 weeks (which is around the maximum amount of time a Lightning payment may be in-flight). 177When creating a quote at a mint, an event can be used to keep the state of the quote ID, which will be used to check when the quote has been paid. These events should be created with an expiration tag [NIP-40](40.md) of 2 weeks (which is around the maximum amount of time a Lightning payment may be in-flight).
171 178
172However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application. 179However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application.
173 180
174```jsonc 181```javascript
175{ 182{
176 "kind": 7374, 183 "kind": 7374,
177 "content": nip44_encrypt("quote-id"), 184 "content": nip44_encrypt("quote-id"),