Merge 47ef4d716a8c7ff799b703d1fb1b0b6f3507540a into 0619f370bca3485bb9c5870bc2defa03c7c3d10e

This commit is contained in:
reis 2025-03-19 14:45:25 +09:00 committed by GitHub
commit db839f2c6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

85
A2.md Normal file
View File

@ -0,0 +1,85 @@
NIP-A2
======
Account delegation via kind-0
-------------------
`draft` `optional`
Defines how to use kind-0 for account delegation.
The clients responsible for account management create and post the delegator kind-0 event.
A user can utilize the delegatee account listed in their own delegator event. If a user creates a delegatee kind-0 event and it is valid, it is considered to represent the same identity with a different key pair.
## Delegator
```js
{
"kind": 0,
"tags": [
["p", <delegatee pubkey>, <approved kind for override>...],
],
"content": <metadata>,
// ...
}
```
- The `p` tag contains the delegatee's pubkey. Optional approved kinds for override can be appended. If no approved kinds are specified, it is considered unrestricted.
- MAY have multiple `p` tags.
## Delegatee
```js
{
"kind": 0,
"tags": [
["P", <delegator pubkey>],
["alt", "delegation account"], // optional
],
"content": <empty or metadata override>,
// ...
}
```
- The `P` tag contains the delegator's pubkey.
- MUST NOT have multiple `P` tags.
- The `content` can be empty or an override of the delegator's metadata if it is approved by the delegator.
## Validation
If a delegator's kind-0 has no `p` tags, and a delegatee's kind-0 contains the delegator's `P` tag, it is considered an invalid delegation, and vice versa.
## Client
Client SHOULD use the delegator's pubkey along with the delegatee's pubkey when adding to or removing from the contact list.
All delegatee stuff SHOULD be considered an override of the delegator's stuff if each kind is approved by the delegator.
## Example of kind-0 events for delegation
### Delegator
```js
{
"kind": 0,
"pubkey": "373ab6e211d2ef30fa72552a072f8cbc6c0cdb72902502d23f05818b6701eaf4",
"tags": [
["p", "1d58b9a772e6370e2193ac79055a67f4e2caabd8c9634e07e390ca1b1717946c", 0, 1, 3, 6, 7, 30023],
],
"content": "{\"name\":\"User\",\"about\":\"I'm not a bitcoiner\"}",
// ...
}
```
### Delegatee
```js
{
"kind": 0,
"pubkey": "1d58b9a772e6370e2193ac79055a67f4e2caabd8c9634e07e390ca1b1717946c",
"tags": [
["P", "373ab6e211d2ef30fa72552a072f8cbc6c0cdb72902502d23f05818b6701eaf4"],
],
"content": "{\"name\":\"User (delegatee)\"}",
// ...
}
```