mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 17:25:21 +00:00
fix nip-17 (#305)
* NIP-59 stuff * nip-17 ios to androing works, android to ios still wip * fix impl * ios compat * default relays for DMs * delivery ack works * delivery ack --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.bitchat.android.nostr
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.security.MessageDigest
|
||||
|
||||
@@ -106,6 +107,14 @@ data class NostrEvent(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute event ID (NIP-01) without signing
|
||||
*/
|
||||
fun computeEventIdHex(): String {
|
||||
val (eventId, _) = calculateEventId()
|
||||
return eventId
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate event ID according to NIP-01
|
||||
* Returns (hex_id, hash_bytes)
|
||||
@@ -122,7 +131,7 @@ data class NostrEvent(
|
||||
)
|
||||
|
||||
// Convert to JSON without escaping slashes (compact format)
|
||||
val gson = Gson()
|
||||
val gson = GsonBuilder().disableHtmlEscaping().create()
|
||||
val jsonString = gson.toJson(serialized)
|
||||
|
||||
// SHA256 hash of the JSON string
|
||||
@@ -201,6 +210,8 @@ data class NostrEvent(
|
||||
object NostrKind {
|
||||
const val METADATA = 0
|
||||
const val TEXT_NOTE = 1
|
||||
const val DIRECT_MESSAGE = 14 // NIP-17 direct message (unsigned)
|
||||
const val FILE_MESSAGE = 15 // NIP-17 file message (unsigned)
|
||||
const val SEAL = 13 // NIP-17 sealed event
|
||||
const val GIFT_WRAP = 1059 // NIP-17 gift wrap
|
||||
const val EPHEMERAL_EVENT = 20000 // For geohash channels
|
||||
|
||||
Reference in New Issue
Block a user