From d4fd2467d691a69a0ba75348086424b9fb33a297 Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 7 Feb 2026 15:20:57 -0800 Subject: wip --- kinds.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 kinds.go (limited to 'kinds.go') diff --git a/kinds.go b/kinds.go new file mode 100644 index 0000000..cb76e88 --- /dev/null +++ b/kinds.go @@ -0,0 +1,51 @@ +package nostr + +// Event kind constants as defined in NIP-01 and related NIPs. +const ( + KindMetadata = 0 + KindTextNote = 1 + KindContactList = 3 + KindEncryptedDM = 4 + KindDeletion = 5 + KindRepost = 6 + KindReaction = 7 +) + +// IsRegular returns true if the kind is a regular event (stored, not replaced). +// Regular events: 1000 <= kind < 10000 or kind in {0,1,2,...} except replaceable ones. +func IsRegular(kind int) bool { + if kind == KindMetadata || kind == KindContactList { + return false + } + if kind >= 10000 && kind < 20000 { + return false // replaceable + } + if kind >= 20000 && kind < 30000 { + return false // ephemeral + } + if kind >= 30000 && kind < 40000 { + return false // addressable + } + return true +} + +// IsReplaceable returns true if the kind is replaceable (NIP-01). +// Replaceable events: 10000 <= kind < 20000, or kind 0 (metadata) or kind 3 (contact list). +func IsReplaceable(kind int) bool { + if kind == KindMetadata || kind == KindContactList { + return true + } + return kind >= 10000 && kind < 20000 +} + +// IsEphemeral returns true if the kind is ephemeral (not stored). +// Ephemeral events: 20000 <= kind < 30000. +func IsEphemeral(kind int) bool { + return kind >= 20000 && kind < 30000 +} + +// IsAddressable returns true if the kind is addressable (parameterized replaceable). +// Addressable events: 30000 <= kind < 40000. +func IsAddressable(kind int) bool { + return kind >= 30000 && kind < 40000 +} -- cgit v1.2.3