mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-25 17:41:27 +02:00
Adds NIP24 Kind1 create function
This commit is contained in:
@@ -2,6 +2,7 @@ package com.vitorpamplona.quartz.events
|
|||||||
|
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
import com.vitorpamplona.quartz.crypto.CryptoUtils
|
import com.vitorpamplona.quartz.crypto.CryptoUtils
|
||||||
|
import com.vitorpamplona.quartz.encoders.ATag
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
import com.vitorpamplona.quartz.encoders.HexKey
|
||||||
|
|
||||||
class NIP24Factory {
|
class NIP24Factory {
|
||||||
@@ -85,4 +86,50 @@ class NIP24Factory {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createTextNoteNIP24(
|
||||||
|
msg: String,
|
||||||
|
to: List<HexKey>,
|
||||||
|
from: ByteArray,
|
||||||
|
replyTos: List<String>? = null,
|
||||||
|
mentions: List<String>? = null,
|
||||||
|
addresses: List<ATag>?,
|
||||||
|
extraTags: List<String>?,
|
||||||
|
zapReceiver: List<ZapSplitSetup>? = null,
|
||||||
|
markAsSensitive: Boolean = false,
|
||||||
|
replyingTo: String?,
|
||||||
|
root: String?,
|
||||||
|
directMentions: Set<HexKey>,
|
||||||
|
zapRaiserAmount: Long? = null,
|
||||||
|
geohash: String? = null
|
||||||
|
): List<GiftWrapEvent> {
|
||||||
|
val senderPublicKey = CryptoUtils.pubkeyCreate(from).toHexKey()
|
||||||
|
|
||||||
|
val senderMessage = TextNoteEvent.create(
|
||||||
|
msg = msg,
|
||||||
|
privateKey = from,
|
||||||
|
replyTos = replyTos,
|
||||||
|
mentions = mentions,
|
||||||
|
zapReceiver = zapReceiver,
|
||||||
|
root = root,
|
||||||
|
extraTags = extraTags,
|
||||||
|
addresses = addresses,
|
||||||
|
directMentions = directMentions,
|
||||||
|
replyingTo = replyingTo,
|
||||||
|
markAsSensitive = markAsSensitive,
|
||||||
|
zapRaiserAmount = zapRaiserAmount,
|
||||||
|
geohash = geohash
|
||||||
|
)
|
||||||
|
|
||||||
|
return to.plus(senderPublicKey).map {
|
||||||
|
GiftWrapEvent.create(
|
||||||
|
event = SealedGossipEvent.create(
|
||||||
|
event = senderMessage,
|
||||||
|
encryptTo = it,
|
||||||
|
privateKey = from
|
||||||
|
),
|
||||||
|
recipientPubKey = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user