upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2025-01-31 00:01:15 -0300
committerfiatjaf <fiatjaf@gmail.com>2025-01-31 00:01:15 -0300
commit1fe24a6149006649a471f2245ad8f66f87595498 (patch)
treef7810a741774574c854ea6229a13dcf906cd3ae8
parent6a4b125ad771ac9da4a1347a1ed41185e30ad0cf (diff)
nip60/61 updates.
-rw-r--r--60.md51
-rw-r--r--61.md84
2 files changed, 67 insertions, 68 deletions
diff --git a/60.md b/60.md
index 8117412..23b56ac 100644
--- a/60.md
+++ b/60.md
@@ -1,5 +1,9 @@
1# NIP-60 1NIP-60
2## Cashu Wallet 2======
3
4Cashu Wallets
5-------------
6
3`draft` `optional` 7`draft` `optional`
4 8
5This NIP defines the operations of a cashu-based wallet. 9This NIP defines the operations of a cashu-based wallet.
@@ -22,19 +26,18 @@ This NIP doesn't deal with users' *receiving* money from someone else, it's just
22{ 26{
23 "kind": 37375, 27 "kind": 37375,
24 "content": nip44_encrypt([ 28 "content": nip44_encrypt([
25 [ "balance", "100", "sat" ], 29 [ "privkey", "hexkey" ],
26 [ "privkey", "hexkey" ] // explained in NIP-61 30 [ "name", "my shitposting wallet" ],
31 [ "description", "a wallet for my day-to-day shitposting" ],
32 [ "mint", "https://mint1" ]
33 // optionally "mint" and "unit" could go here
27 ]), 34 ]),
28 "tags": [ 35 "tags": [
29 [ "d", "my-wallet" ], 36 [ "d", "my-wallet" ],
30 [ "mint", "https://mint1" ],
31 [ "mint", "https://mint2" ], 37 [ "mint", "https://mint2" ],
32 [ "mint", "https://mint3" ], 38 [ "mint", "https://mint3" ],
33 [ "name", "my shitposting wallet" ], 39 [ "unit", "sat" ]
34 [ "unit", "sat" ], 40 // optionally "name" and "description" could go here
35 [ "description", "a wallet for my day-to-day shitposting" ],
36 [ "relay", "wss://relay1" ],
37 [ "relay", "wss://relay2" ],
38 ] 41 ]
39} 42}
40``` 43```
@@ -44,14 +47,13 @@ The wallet event is an addressable event `kind:37375`.
44Tags: 47Tags:
45* `d` - wallet ID. 48* `d` - wallet ID.
46* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags. 49* `mint` - Mint(s) this wallet uses -- there MUST be one or more mint tags.
47* `relay` - Relays where the wallet and related events can be found. -- one ore more relays SHOULD be specified. If missing, clients should follow [[NIP-65]].
48* `unit` - Base unit of the wallet (e.g. "sat", "usd", etc). 50* `unit` - Base unit of the wallet (e.g. "sat", "usd", etc).
49* `name` - Optional human-readable name for the wallet. 51* `name` - Optional human-readable name for the wallet.
50* `description` - Optional human-readable description of the wallet. 52* `description` - Optional human-readable description of the wallet.
51* `balance` - Optional best-effort balance of the wallet that can serve as a placeholder while an accurate balance is computed from fetching all unspent proofs. 53* `balance` - Optional best-effort balance of the wallet that can serve as a placeholder while an accurate balance is computed from fetching all unspent proofs.
52* `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 when receiving funds from others, described in NIP-61. 54* `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.
53 55
54Any tag, other than the `d` tag, can be [[NIP-44]] encrypted into the `.content` field. 56The 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.
55 57
56### Deleting a wallet event 58### Deleting a wallet event
57Due 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. 59Due 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.
@@ -67,6 +69,7 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs
67 "content": nip44_encrypt({ 69 "content": nip44_encrypt({
68 "mint": "https://stablenut.umint.cash", 70 "mint": "https://stablenut.umint.cash",
69 "proofs": [ 71 "proofs": [
72 // one or more proofs in the default cashu format
70 { 73 {
71 "id": "005c2502034d4f12", 74 "id": "005c2502034d4f12",
72 "amount": 1, 75 "amount": 1,
@@ -74,8 +77,8 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs
74 "C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46" 77 "C": "0241d98a8197ef238a192d47edf191a9de78b657308937b4f7dd0aa53beae72c46"
75 } 78 }
76 ], 79 ],
77 // tokens that were destroyed in the creation of this token 80 // tokens that were destroyed in the creation of this token (helps on wallet state transitions)
78 "del": [ "token-id-1" ] 81 "del": [ "token-event-id-1", "token-event-id-2" ]
79 }), 82 }),
80 "tags": [ 83 "tags": [
81 [ "a", "37375:<pubkey>:my-wallet" ] 84 [ "a", "37375:<pubkey>:my-wallet" ]
@@ -84,13 +87,15 @@ There can be multiple `kind:7375` events for the same mint, and multiple proofs
84``` 87```
85 88
86 * `a` an optional tag linking the token to a specific wallet. 89 * `a` an optional tag linking the token to a specific wallet.
87 * `.content` is a [[NIP-44]] encrypted payload: 90 * `.content` is a [NIP-44](44.md) encrypted payload:
88 * `mint`: The mint the proofs belong to. 91 * `mint`: The mint the proofs belong to.
89 * `proofs`: unecoded proofs 92 * `proofs`: unecoded proofs
90 * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions. 93 * `del`: token-ids that were destroyed by the creation of this token. This assists with state transitions.
91 94
92### Spending proofs 95### Spending proofs
93When 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. 96When 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).
97
98The `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.
94 99
95## Spending History Event 100## Spending History Event
96Clients SHOULD publish `kind:7376` events to create a transaction history when their balance changes. 101Clients SHOULD publish `kind:7376` events to create a transaction history when their balance changes.
@@ -115,14 +120,14 @@ Clients SHOULD publish `kind:7376` events to create a transaction history when t
115Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag: 120Clients MUST add `e` tags to create references of destroyed and created token events along with the marker of the meaning of the tag:
116* `created` - A new token event was created. 121* `created` - A new token event was created.
117* `destroyed` - A token event was destroyed. 122* `destroyed` - A token event was destroyed.
118* `redeemed` - A [[NIP-61]] nutzap was redeemed. 123* `redeemed` - A [NIP-61](61.md) nutzap was redeemed.
119 124
120All tags can be [[NIP-44]] encrypted. Clients SHOULD leave `e` tags with a `redeemed` marker unencrypted. 125like on Wallet events, clients or users may choose to encrypt all tags except for `a` tags and `e` tags with a `redeemed` marker unencrypted.
121 126
122Multiple `e` tags can be added to a `kind:7376` event. 127Multiple `e` tags can be added to a `kind:7376` event.
123 128
124# Flow 129# Flow
125A 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]] relays. 130A 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.
126 131
127## Fetch wallet and token list 132## Fetch wallet and token list
128From those relays, the client should fetch wallet and token events. 133From those relays, the client should fetch wallet and token events.
@@ -130,7 +135,7 @@ From those relays, the client should fetch wallet and token events.
130`"kinds": [37375, 7375], "authors": ["<my-pubkey>"]` 135`"kinds": [37375, 7375], "authors": ["<my-pubkey>"]`
131 136
132## Fetch proofs 137## Fetch proofs
133While the client is fetching (and perhaps validating) proofs it can use the optional `balance` tag of the wallet event to display a estimate of the balance of the wallet. 138While the client is fetching (and perhaps validating) proofs it can use the optional `balance` tag of the _wallet event_ to display a estimate of the balance of the wallet.
134 139
135## Spending token 140## Spending token
136If Alice spends 4 sats from this token event 141If Alice spends 4 sats from this token event
@@ -192,9 +197,9 @@ Her client:
192``` 197```
193 198
194## Redeeming a quote (optional) 199## Redeeming a quote (optional)
195When 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]] matching the expiration of the bolt11 received from the mint; this signals to relays when they can safely discard these events. 200When 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).
196 201
197Application developers are encouraged to use local state when possible and only publish this event when it makes sense in the context of their application. 202However, application developers SHOULD use local state when possible and only publish this event when it makes sense in the context of their application.
198 203
199```jsonc 204```jsonc
200{ 205{
diff --git a/61.md b/61.md
index 8246203..ab562c8 100644
--- a/61.md
+++ b/61.md
@@ -1,14 +1,19 @@
1# NIP-61: 1NIP-61
2## Nut Zaps 2======
3 3
4A Nut Zap is a P2PK cashu token where the payment itself is the receipt. 4Nutzaps
5-------
6
7`draft` `optional`
8
9A Nutzap is a P2PK Cashu token in which the payment itself is the receipt.
5 10
6# High-level flow 11# High-level flow
7Alice wants to nutzap 1 sat to Bob because of an event `event-id-1` she liked. 12Alice wants to nutzap 1 sat to Bob because of an event `event-id-1` she liked.
8 13
9## Alice nutzaps Bob 14## Alice nutzaps Bob
101. Alice fetches event `kind:10019` from Bob to see the mints Bob trusts. 151. Alice fetches event `kind:10019` from Bob to see the mints Bob trusts.
112. She mints a token at that mint (or swaps some tokens she already had in that mint) p2pk-locked to the pubkey Bob has listed in his `kind:10019`. 162. She mints a token at that mint (or swaps some tokens she already had in that mint) P2PK-locked to the pubkey Bob has listed in his `kind:10019`.
123. She publishes a `kind:9321` event to the relays Bob indicated with the proofs she minted. 173. She publishes a `kind:9321` event to the relays Bob indicated with the proofs she minted.
13 18
14## Bob receives the nutzap 19## Bob receives the nutzap
@@ -29,16 +34,15 @@ Alice wants to nutzap 1 sat to Bob because of an event `event-id-1` she liked.
29} 34}
30``` 35```
31 36
32`kind:10019` is an event that is useful for others to know how to send money to the user. 37* `kind:10019` is an event that is useful for others to know how to send money to the user.
33 38* `relay`: relays where the user will be reading token events from. If a user wants to send money to the user, they should write to these relays.
34* `relay` - Relays where the user will be reading token events from. If a user wants to send money to the user, they should write to these relays. 39* `mint`: mints the user is explicitly agreeing to use to receive funds on. Clients SHOULD not send money on mints not listed here or risk burning their money. Additional markers can be used to list the supported base units of the mint.
35* `mint` - Mints the user is explicitly agreeing to use to receive funds on. Clients SHOULD not send money on mints not listed here or risk burning their money. Additional markers can be used to list the supported base units of the mint. 40* `pubkey`: Public key that MUST be used to P2PK-lock receiving nutzaps -- implementations MUST NOT use the target user's main Nostr public key. This public key corresponds to the `privkey` field encrypted in a user's [nip-60](60.md) _wallet event_.
36* `pubkey` - Pubkey that SHOULD be used to P2PK-lock receiving nutzaps. If not present, clients SHOULD use the pubkey of the recipient. This is explained in Appendix 1.
37 41
38## Nutzap event 42## Nutzap event
39Event `kind:9321` is a nutzap event published by the sender, p-tagging the recipient. The outputs are P2PK-locked to the pubkey the recipient indicated in their `kind:10019` event or to the recipient pubkey if the `kind:10019` event doesn't have a explicit pubkey. 43Event `kind:9321` is a nutzap event published by the sender, p-tagging the recipient. The outputs are P2PK-locked to the public key the recipient indicated in their `kind:10019` event.
40 44
41Clients MUST prefix the pubkey they p2pk-lock with `"02"` (for nostr<>cashu pubkey compatibility). 45Clients MUST prefix the public key they P2PK-lock with `"02"` (for nostr<>cashu compatibility).
42 46
43```jsonc 47```jsonc
44{ 48{
@@ -51,43 +55,40 @@ Clients MUST prefix the pubkey they p2pk-lock with `"02"` (for nostr<>cashu pubk
51 [ "proof", "{\"amount\":1,\"C\":\"02277c66191736eb72fce9d975d08e3191f8f96afb73ab1eec37e4465683066d3f\",\"id\":\"000a93d6f8a1d2c4\",\"secret\":\"[\\\"P2PK\\\",{\\\"nonce\\\":\\\"b00bdd0467b0090a25bdf2d2f0d45ac4e355c482c1418350f273a04fedaaee83\\\",\\\"data\\\":\\\"02eaee8939e3565e48cc62967e2fde9d8e2a4b3ec0081f29eceff5c64ef10ac1ed\\\"}]\"}" ], 55 [ "proof", "{\"amount\":1,\"C\":\"02277c66191736eb72fce9d975d08e3191f8f96afb73ab1eec37e4465683066d3f\",\"id\":\"000a93d6f8a1d2c4\",\"secret\":\"[\\\"P2PK\\\",{\\\"nonce\\\":\\\"b00bdd0467b0090a25bdf2d2f0d45ac4e355c482c1418350f273a04fedaaee83\\\",\\\"data\\\":\\\"02eaee8939e3565e48cc62967e2fde9d8e2a4b3ec0081f29eceff5c64ef10ac1ed\\\"}]\"}" ],
52 [ "u", "https://stablenut.umint.cash", ], 56 [ "u", "https://stablenut.umint.cash", ],
53 [ "e", "<zapped-event-id>", "<relay-hint>" ], 57 [ "e", "<zapped-event-id>", "<relay-hint>" ],
54 [ "p", "e9fbced3a42dcf551486650cc752ab354347dd413b307484e4fd1818ab53f991" ], // recipient of nut zap 58 [ "p", "e9fbced3a42dcf551486650cc752ab354347dd413b307484e4fd1818ab53f991" ], // recipient of nutzap
55 ] 59 ]
56} 60}
57``` 61```
58 62
59* `.content` is an optional comment for the nutzap 63* `.content` is an optional comment for the nutzap
60* `amount` is a shorthand for the combined amount of all outputs. -- Clients SHOULD validate that the sum of the amounts in the outputs matches. 64* `.tags`:
61* `unit` is the base unit of the amount. 65 * `amount` is a shorthand for the combined amount of all outputs. -- Clients SHOULD validate that the sum of the amounts in the outputs matches.
62* `proof` is one ore more proofs p2pk-locked to the pubkey the recipient specified in their `kind:10019` event. 66 * `unit` is the base unit of the amount.
63* `u` is the mint the URL of the mint EXACTLY as specified by the recipient's `kind:10019`. 67 * `proof` is one ore more proofs P2PK-locked to the public key the recipient specified in their `kind:10019` event and including a DLEQ proof.
64* `e` zero or one event that is being nutzapped. 68 * `u` is the mint the URL of the mint EXACTLY as specified by the recipient's `kind:10019`.
65* `p` exactly one pubkey, specifying the recipient of the nutzap. 69 * `p` is the Nostr identity public key of nutzap recipient.
66 70 * `e` is the event that is being nutzapped, if any.
67WIP: Clients SHOULD embed a DLEQ proof in the nutzap event to make it possible to verify nutzaps without talking to the mint.
68 71
69# Sending a nutzap 72# Sending a nutzap
70 73
71* The sender fetches the recipient's `kind:10019`. 74* The sender fetches the recipient's `kind:10019`.
72* The sender mints/swaps ecash on one of the recipient's listed mints. 75* The sender mints/swaps ecash on one of the recipient's listed mints.
73* The sender p2pk locks to the recipient's specified pubkey in their `kind:10019` 76* The sender P2PK-locks to the recipient's specified public key in their `kind:10019`
74 77
75# Receiving nutzaps 78# Receiving nutzaps
76 79
77Clients should REQ for nut zaps: 80Clients should REQ for nutzaps:
78* Filtering with `#u` for mints they expect to receive ecash from. 81* Filtering with `#u` for mints they expect to receive ecash from.
79 * this is to prevent even interacting with mints the user hasn't explicitly signaled. 82 * this is to prevent even interacting with mints the user hasn't explicitly signaled.
80* Filtering with `since` of the most recent `kind:7376` event the same user has created. 83* Filtering with `since` of the most recent `kind:7376` event the same user has created.
81 * this can be used as a marker of the nut zaps that have already been swaped by the user -- clients might choose to use other kinds of markers, including internal state -- this is just a guidance of one possible approach. 84 * this can be used as a marker of the nutzaps that have already been swaped by the user -- clients might choose to use other kinds of markers, including internal state -- this is just a guidance of one possible approach.
82
83Clients MIGHT choose to use some kind of filtering (e.g. WoT) to ignore spam.
84 85
85`{ "kinds": [9321], "#p": "my-pubkey", "#u": [ "<mint-1>", "<mint-2>"], "since": <latest-created_at-of-kind-7376> }`. 86`{ "kinds": [9321], "#p": ["my-pubkey"], "#u": ["<mint-1>", "<mint-2>"], "since": <latest-created_at-of-kind-7376> }`.
86 87
87Upon receiving a new nut zap, the client should swap the tokens into a wallet the user controls, either a [[NIP-60]] wallet, their own LN wallet or anything else. 88Upon receiving a new nutzap, the client should swap the tokens into a wallet the user controls, either a [NIP-60](60.md) wallet, their own LN wallet or anything else.
88 89
89## Updating nutzap-redemption history 90## Updating nutzap-redemption history
90When claiming a token the client SHOULD create a `kind:7376` event and `e` tag the original nut zap event. This is to record that this token has already been claimed (and shouldn't be attempted again) and as signaling to the recipient that the ecash has been redeemed. 91When claiming a token the client SHOULD create a `kind:7376` event and `e` tag the original nutzap event. This is to record that this token has already been claimed (and shouldn't be attempted again) and as signaling to the recipient that the ecash has been redeemed.
91 92
92Multiple `kind:9321` events can be tagged in the same `kind:7376` event. 93Multiple `kind:9321` events can be tagged in the same `kind:7376` event.
93 94
@@ -107,26 +108,19 @@ Multiple `kind:9321` events can be tagged in the same `kind:7376` event.
107} 108}
108``` 109```
109 110
110Events that redeem a nutzap SHOULD be published to the sender's [[NIP-65]] relays. 111Events that redeem a nutzap SHOULD be published to the sender's [NIP-65](65.md) "read" relays.
111 112
112## Verifying a Cashu Zap 113## Verifying a Cashu Zap
113* Clients SHOULD check that the receiving user has issued a `kind:10019` tagging the mint where the cashu has been minted. 114When listing or counting zaps received by any given event, observer clients SHOULD:
114* Clients SHOULD check that the token is locked to the pubkey the user has listed in their `kind:10019`.
115 115
116## Final Considerations 116* check that the receiving user has issued a `kind:10019` tagging the mint where the cashu has been minted.
117* check that the token is locked to the pubkey the user has listed in their `kind:10019`.
118* look at the `u` tag and check that the token is issued in one of the mints listed in the `kind:10019`.
119* locally verify the DLEQ proof of the tokens being sent.
117 120
1181. Clients SHOULD guide their users to use NUT-11 (P2PK) compatible-mints in their `kind:10019` event to avoid receiving nut zaps anyone can spend 121All these checks can be done offline (as long as the observer has the receiver mints' keyset and their `kind:10019` event), so the process should be reasonably fast.
119 122
123## Final Considerations
1241. Clients SHOULD guide their users to use NUT-11 (P2PK) and NUT-12 (DLEQ proofs) compatible-mints in their `kind:10019` event to avoid receiving nutzaps anyone can spend.
1202. Clients SHOULD normalize and deduplicate mint URLs as described in NIP-65. 1252. Clients SHOULD normalize and deduplicate mint URLs as described in NIP-65.
121 1263. A nutzap MUST be sent to a mint the recipient has listed in their `kind:10019` event or to the NIP-65 relays of the recipient, failure to do so may result in the recipient donating the tokens to the mint since the recipient might never see the event.
1223. A nut zap MUST be sent to a mint the recipient has listed in their `kind:10019` event or to the NIP-65 relays of the recipient, failure to do so may result in the recipient donating the tokens to the mint since the recipient might never see the event.
123
124## Appendix 1: Alternative P2PK pubkey
125Clients might not have access to the user's private key (i.e. NIP-07, NIP-46 signing) and, as such, the private key to sign cashu spends might not be available, which would make spending the P2PK incoming nutzaps impossible.
126
127For this scenarios clients can:
128
129* add a `pubkey` tag to the `kind:10019` (indicating which pubkey senders should P2PK to)
130* store the private key in the `kind:37375` event in the nip44-encrypted `content` field.
131
132This is to avoid depending on NIP-07/46 adaptations to sign cashu payloads.