upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--60.md64
-rw-r--r--61.md2
2 files changed, 20 insertions, 46 deletions
diff --git a/60.md b/60.md
index b079e8f..0d7b31f 100644
--- a/60.md
+++ b/60.md
@@ -17,43 +17,30 @@ The purpose of this NIP is:
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:37375` 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```jsonc
26{ 26{
27 "kind": 37375, 27 "kind": 17375,
28 "content": nip44_encrypt([ 28 "content": nip44_encrypt([
29 [ "privkey", "hexkey" ], 29 [ "privkey", "hexkey" ],
30 [ "name", "my shitposting wallet" ], 30 [ "mint", "https://mint1" ],
31 [ "description", "a wallet for my day-to-day shitposting" ], 31 [ "mint", "https://mint2" ]
32 [ "mint", "https://mint1" ]
33 // optionally "mint" and "unit" could go here
34 ]), 32 ]),
35 "tags": [ 33 "tags": []
36 [ "d", "my-wallet" ],
37 [ "mint", "https://mint2" ],
38 [ "mint", "https://mint3" ],
39 [ "unit", "sat" ]
40 // optionally "name" and "description" could go here
41 ]
42} 34}
43``` 35```
44 36
45The wallet event is an addressable event `kind:37375`. 37The wallet event is an addressable event `kind:17375`.
46 38
47Tags: 39Tags:
48* `d` - wallet ID. 40* `d` - wallet ID.
49* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags. 41* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags.
50* `unit` - Base unit of the wallet (e.g. "sat", "usd", etc).
51* `name` - Optional human-readable name for the wallet.
52* `description` - Optional human-readable description of the wallet.
53* `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* `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.
54 43
55The client or user MAY decide to put some tags either inside the encrypted `.content` or under the public `.tags`, `name` and `description`, for example. However, `d` MUST always be a public tag, and `mint` and `unit` must be public if the user intends to receive [NIP-61](61.md) nutzaps.
56
57### Deleting a wallet event 44### Deleting a wallet event
58Due 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. 45Due 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.
59 46
@@ -79,13 +66,10 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs
79 // tokens that were destroyed in the creation of this token (helps on wallet state transitions) 66 // tokens that were destroyed in the creation of this token (helps on wallet state transitions)
80 "del": [ "token-event-id-1", "token-event-id-2" ] 67 "del": [ "token-event-id-1", "token-event-id-2" ]
81 }), 68 }),
82 "tags": [ 69 "tags": []
83 [ "a", "37375:<pubkey>:my-wallet" ]
84 ]
85} 70}
86``` 71```
87 72
88 * `a` an optional tag linking the token to a specific wallet.
89 * `.content` is a [NIP-44](44.md) encrypted payload: 73 * `.content` is a [NIP-44](44.md) encrypted payload:
90 * `mint`: The mint the proofs belong to. 74 * `mint`: The mint the proofs belong to.
91 * `proofs`: unecoded proofs 75 * `proofs`: unecoded proofs
@@ -104,26 +88,23 @@ Clients SHOULD publish `kind:7376` events to create a transaction history when t
104 "kind": 7376, 88 "kind": 7376,
105 "content": nip44_encrypt([ 89 "content": nip44_encrypt([
106 [ "direction", "in" ], // in = received, out = sent 90 [ "direction", "in" ], // in = received, out = sent
107 [ "amount", "1", "sat" ], 91 [ "amount", "1" ],
108 [ "e", "<event-id-of-created-token>", "<relay-hint>", "created" ], 92 [ "e", "<event-id-of-created-token>", "", "created" ]
109 ]), 93 ]),
110 "tags": [ 94 "tags": [
111 [ "a", "37375:<pubkey>:my-wallet" ], 95 [ "e", "<event-id-of-created-token>", "", "redeemed" ]
112 ] 96 ]
113} 97}
114``` 98```
115 99
116* `direction` - The direction of the transaction; `in` for received funds, `out` for sent funds. 100* `direction` - The direction of the transaction; `in` for received funds, `out` for sent funds.
117* `a` - The wallet the transaction is related to.
118 101
119Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag: 102Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag:
120* `created` - A new token event was created. 103* `created` - A new token event was created.
121* `destroyed` - A token event was destroyed. 104* `destroyed` - A token event was destroyed.
122* `redeemed` - A [NIP-61](61.md) nutzap was redeemed. 105* `redeemed` - A [NIP-61](61.md) nutzap was redeemed.
123 106
124like on Wallet events, clients or users may choose to encrypt all tags except for `a` tags and `e` tags with a `redeemed` marker unencrypted. 107Multiple `e` tags can be added, and should be encrypted, except for tags with the `redeemed` marker.
125
126Multiple `e` tags can be added to a `kind:7376` event.
127 108
128# Flow 109# Flow
129A 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. 110A 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.
@@ -131,7 +112,7 @@ A client that wants to check for user's wallets information starts by fetching `
131## Fetch wallet and token list 112## Fetch wallet and token list
132From those relays, the client should fetch wallet and token events. 113From those relays, the client should fetch wallet and token events.
133 114
134`"kinds": [37375, 7375], "authors": ["<my-pubkey>"]` 115`"kinds": [17375, 7375], "authors": ["<my-pubkey>"]`
135 116
136## Fetch proofs 117## Fetch proofs
137 118
@@ -150,9 +131,7 @@ If Alice spends 4 sats from this token event
150 { "id": "4", "amount": 8 }, 131 { "id": "4", "amount": 8 },
151 ] 132 ]
152 }), 133 }),
153 "tags": [ 134 "tags": []
154 [ "a", "37375:<pubkey>:my-wallet" ]
155 ]
156} 135}
157``` 136```
158 137
@@ -171,9 +150,7 @@ Her client:
171 ], 150 ],
172 "del": [ "event-id-1" ] 151 "del": [ "event-id-1" ]
173 }), 152 }),
174 "tags": [ 153 "tags": []
175 [ "a", "37375:<pubkey>:my-wallet" ]
176 ]
177} 154}
178``` 155```
179* MUST delete event `event-id-1` 156* MUST delete event `event-id-1`
@@ -185,17 +162,15 @@ Her client:
185 "content": nip44_encrypt([ 162 "content": nip44_encrypt([
186 [ "direction", "out" ], 163 [ "direction", "out" ],
187 [ "amount", "4", "sats" ], 164 [ "amount", "4", "sats" ],
188 [ "e", "<event-id-1>", "<relay-hint>", "destroyed" ], 165 [ "e", "<event-id-1>", "", "destroyed" ],
189 [ "e", "<event-id-2>", "<relay-hint>", "created" ], 166 [ "e", "<event-id-2>", "", "created" ],
190 ]), 167 ]),
191 "tags": [ 168 "tags": []
192 [ "a", "37375:<pubkey>:my-wallet" ],
193 ]
194} 169}
195``` 170```
196 171
197## Redeeming a quote (optional) 172## Redeeming a quote (optional)
198When 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 pending). 173When 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).
199 174
200However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application. 175However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application.
201 176
@@ -205,8 +180,7 @@ However, application developers SHOULD use local state when possible and only pu
205 "content": nip44_encrypt("quote-id"), 180 "content": nip44_encrypt("quote-id"),
206 "tags": [ 181 "tags": [
207 [ "expiration", "<expiration-timestamp>" ], 182 [ "expiration", "<expiration-timestamp>" ],
208 [ "mint", "<mint-url>" ], 183 [ "mint", "<mint-url>" ]
209 [ "a", "37375:<pubkey>:my-wallet" ]
210 ] 184 ]
211} 185}
212``` 186```
diff --git a/61.md b/61.md
index 4e28e01..d11a052 100644
--- a/61.md
+++ b/61.md
@@ -52,7 +52,7 @@ Clients MUST prefix the public key they P2PK-lock with `"02"` (for nostr<>cashu
52 tags: [ 52 tags: [
53 [ "unit", "sat" ], 53 [ "unit", "sat" ],
54 [ "proof", "{\"amount\":1,\"C\":\"02277c66191736eb72fce9d975d08e3191f8f96afb73ab1eec37e4465683066d3f\",\"id\":\"000a93d6f8a1d2c4\",\"secret\":\"[\\\"P2PK\\\",{\\\"nonce\\\":\\\"b00bdd0467b0090a25bdf2d2f0d45ac4e355c482c1418350f273a04fedaaee83\\\",\\\"data\\\":\\\"02eaee8939e3565e48cc62967e2fde9d8e2a4b3ec0081f29eceff5c64ef10ac1ed\\\"}]\"}" ], 54 [ "proof", "{\"amount\":1,\"C\":\"02277c66191736eb72fce9d975d08e3191f8f96afb73ab1eec37e4465683066d3f\",\"id\":\"000a93d6f8a1d2c4\",\"secret\":\"[\\\"P2PK\\\",{\\\"nonce\\\":\\\"b00bdd0467b0090a25bdf2d2f0d45ac4e355c482c1418350f273a04fedaaee83\\\",\\\"data\\\":\\\"02eaee8939e3565e48cc62967e2fde9d8e2a4b3ec0081f29eceff5c64ef10ac1ed\\\"}]\"}" ],
55 [ "u", "https://stablenut.umint.cash", ], 55 [ "u", "https://stablenut.umint.cash" ],
56 [ "e", "<zapped-event-id>", "<relay-hint>" ], 56 [ "e", "<zapped-event-id>", "<relay-hint>" ],
57 [ "p", "e9fbced3a42dcf551486650cc752ab354347dd413b307484e4fd1818ab53f991" ], // recipient of nutzap 57 [ "p", "e9fbced3a42dcf551486650cc752ab354347dd413b307484e4fd1818ab53f991" ], // recipient of nutzap
58 ] 58 ]