upleb.uk

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

summaryrefslogtreecommitdiff
path: root/61.md
diff options
context:
space:
mode:
authorPablo Fernandez <p@f7z.io>2024-07-17 00:51:41 +0100
committerPablo Fernandez <p@f7z.io>2024-07-17 00:51:41 +0100
commit506b38916ab67a37b2d98b46b62cf0c0c5fde5a4 (patch)
tree99eeb263247a0192cbd568560463ec9ebc7120e2 /61.md
parent8b75d7be7c45f5867ea6541095f7322fe7d77a26 (diff)
cashu wallet and nut zaps
Diffstat (limited to '61.md')
-rw-r--r--61.md117
1 files changed, 117 insertions, 0 deletions
diff --git a/61.md b/61.md
new file mode 100644
index 0000000..f219f11
--- /dev/null
+++ b/61.md
@@ -0,0 +1,117 @@
1# NIP-61:
2## Nut Zaps
3
4A Nut Zap is a P2PK cashu token where the payment itself is the receipt.
5
6# High-level flow
7Alice wants to nutzap 1 sat to Bob because of an event `event-id-1` she liked.
8
9## Alice nutzaps Bob
101. 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`.
123. She publishes a `kind:7337` event to the relays Bob indicated with the proofs she minted.
13
14## Bob receives the nutzap
151. At some point, Bob's client fetches `kind:7337` events p-tagging him from his relays.
162. Bob's client swaps the token into his wallet.
17
18# Nutzap informational event
19```jsonc
20{
21 "kind": 10019,
22 "tags": [
23 [ "relay", "wss://relay1" ],
24 [ "relay", "wss://relay2" ],
25 [ "mint", "https://mint1" ],
26 [ "mint", "https://mint2" ],
27 [ "pubkey", "<p2pk-pubkey>" ]
28 ]
29}
30```
31
32`kind:10019` is an event that is useful for others to know how to send money to the user.
33
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.
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.
36* `pubkey` - Pubkey that SHOULD be used to P2PK-lock receiving nutzaps. If not present, clients SHOULD use the pubkey of the recipient.
37
38## Nutzap event
39Event `kind:7337` 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.
40
41Clients MUST prefix the recipient pubkey with `"02"` (for nostr<>cashu pubkey compatibility).
42
43```jsonc
44{
45 kind: 7337,
46 content: "[{\"amount\":1,\"C\":\"02277c66191736eb72fce9d975d08e3191f8f96afb73ab1eec37e4465683066d3f\",\"id\":\"000a93d6f8a1d2c4\",\"secret\":\"[\\\"P2PK\\\",{\\\"nonce\\\":\\\"b00bdd0467b0090a25bdf2d2f0d45ac4e355c482c1418350f273a04fedaaee83\\\",\\\"data\\\":\\\"02eaee8939e3565e48cc62967e2fde9d8e2a4b3ec0081f29eceff5c64ef10ac1ed\\\"}]\"}]",
47 pubkey: "sender-pubkey",
48 tags: [
49 [ "amount", "1", "sats" ],
50 [ "comment", "Great point" ],
51 [ "u", "https://stablenut.umint.cash", ],
52 [ "e", "<zapped-event-id>", "<relay-hint>" ],
53 [ "p", "e9fbced3a42dcf551486650cc752ab354347dd413b307484e4fd1818ab53f991" ], // recipient of nut zap
54 ]
55}
56```
57
58* `.content` is an array of p2pk-locked outputs.
59* `amount` is a shorthand for the combined amount of all outputs. -- Clients SHOULD validate that the sum of the amounts in the outputs matches.
60* `u` is the mint the URL of the mint EXACTLY as specified by the recipient's `kind:10019`.
61* `e` zero or one event that is being nutzapped.
62* `p` exactly one pubkey, specifying the recipient of the nutzap.
63
64# Sending a nutzap
65
66* The sender fetches the recipient's `kind:10019`.
67* The sender mints/swaps ecash on one of the recipient's listed mints.
68* The sender p2pk locks to the recipient's specified pubkey in their
69
70# Receiving nutzaps
71
72Clients should REQ for nut zaps:
73* Filtering with `#u` for mints they expect to receive ecash from.
74 * this is to prevent even interacting with mints the user hasn't explicitly signaled.
75* Filtering with `since` of the most recent `kind:7376` event the same user has created.
76 * 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.
77
78Clients MIGHT choose to use some kind of filtering (e.g. WoT) to ignore spam.
79
80`{ "kinds": [7337], "#p": "my-pubkey", "#u": [ "<mint-1>", "<mint-2>"], "since": <latest-created_at-of-kind-7376> }`.
81
82Upon 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.
83
84## Updating nutzap-redemption history
85When 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.
86
87Multiple `kind:7337` events can be tagged in the same `kind:7376` event.
88
89```jsonc
90{
91 "kind": 7376,
92 "content": nip44_encrypt([
93 [ "direction", "in" ], // in = received, out = sent
94 [ "amount", "1", "sats" ],
95 [ "e", "<7375-event-id>", "relay-hint", "created" ] // new token event that was created
96 ]),
97 "tags": [
98 [ "a", "37375:<pubkey>:my-wallet" ], // an optional wallet tag
99 [ "e", "<7337-event-id>", "relay-hint", "redeemed" ], // nutzap event that has been redeemed
100 [ "p", "sender-pubkey" ] // pubkey of the author of the 7337 event (nutzap sender)
101 ]
102}
103```
104
105Events that redeem a nutzap SHOULD be published to the sender's [[NIP-65]] relays.
106
107## Verifying a Cashu Zap
108* Clients SHOULD check that the receiving user has issued a `kind:10019` tagging the mint where the cashu has been minted.
109* Clients SHOULD check that the token is locked to the pubkey the user has listed in their `kind:10019`.
110
111## Final Considerations
112
1131. 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
114
1152. Clients SHOULD normalize and deduplicate mint URLs as described in NIP-65.
116
1173. 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. \ No newline at end of file