Skip to content

add NIP-62 vanish event support#418

Merged
cameri merged 2 commits intocameri:mainfrom
vikashsiwach:feature/nip62-vanish
Apr 9, 2026
Merged

add NIP-62 vanish event support#418
cameri merged 2 commits intocameri:mainfrom
vikashsiwach:feature/nip62-vanish

Conversation

@vikashsiwach
Copy link
Copy Markdown
Contributor

Description

This PR implement support for NIP-62 request-to-vanish events. When a vanish event is received ,the relay deletes all existing events for that pubkey and keep only kind:62 event as tombstone.
Afterwards, all events from that pubkey are rejected.
Additional behavior:

  • kind:62 events are not broadcasted.
  • Relay tag is validated
  • Tombstone events can not be deleted by kind:5 events.

Related Issue

Fixes issue #390

Motivation and Context

NIP-62 is meant to allow users to erase their presence on a relay. This is implemented in this PR by treating kind:62 as tombstone.

How Has This Been Tested?

  • npm run lint passes
  • npm run test:unit passes (503 tests)

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

Comment on lines +232 to +238
export const isValidRequestToVanishEvent = (event: Event, relayUrl: string): boolean => {
const relayTags = event.tags
.filter((tag) => tag.length >= 2 && tag[0] === EventTags.Relay)
.map((tag) => tag[1])

return relayTags.length > 0 && relayTags.every((relay) => relay === relayUrl || relay === ALL_RELAYS)
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this missing the kind number check?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need two functions? I think we just need 1 combining these two.

Copy link
Copy Markdown
Contributor Author

@vikashsiwach vikashsiwach Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need two functions? I think we just need 1 combining these two.

Yes , we can combine these two to make single function to validate eligibility.If you want I can make the changes update the tests according to it

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikashsiwach Let's merge them please, having two functions can lead to confusion on which one is right one to use.

Comment on lines +268 to +276
public async hasActiveRequestToVanish(pubkey: string): Promise<boolean> {
const result = await this.readReplicaDbClient('events')
.select('event_id')
.where('event_pubkey', toBuffer(pubkey))
.where('event_kind', EventKinds.REQUEST_TO_VANISH)
.whereNull('deleted_at')
.first()

return Boolean(result)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are likely better off adding a column to the users table. However, I think I am okay with this approach for now. Optimizing this to use the users table can be a separate issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right , a table flag will would be better for long term optimization. I used this event based check to stay scoped to NIP-62 behavior. We can create a follow up issue for this if you want.

@cameri
Copy link
Copy Markdown
Owner

cameri commented Apr 9, 2026

@vikashsiwach Impressive work! Just left a few comments.

@vikashsiwach
Copy link
Copy Markdown
Contributor Author

Merged vanish validation and kind check in single function. Have a look on it !

@cameri cameri merged commit 78facd1 into cameri:main Apr 9, 2026
10 checks passed
phoenix-server added a commit that referenced this pull request Apr 10, 2026
* feat: add NIP-62 vanish event support (#418)

* ci: remove sonarcloud step from checks workflow

---------

Co-authored-by: Vikash Siwach <siwachvikash70@gmail.com>
Co-authored-by: github-manager <github-manager@example.com>
Co-authored-by: Ricardo Cabral <me@ricardocabral.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants