Merge branch 'main' into amber
This commit is contained in:
@@ -96,16 +96,20 @@ open class Event(
|
||||
override fun hasZapSplitSetup() = tags.any { it.size > 1 && it[0] == "zap" }
|
||||
|
||||
override fun zapSplitSetup(): List<ZapSplitSetup> {
|
||||
return tags.filter { it.size > 1 && it[0] == "zap" }.map {
|
||||
return tags.filter { it.size > 1 && it[0] == "zap" }.mapNotNull {
|
||||
val isLnAddress = it[0].contains("@") || it[0].startsWith("LNURL", true)
|
||||
val weight = if (isLnAddress) 1.0 else (it.getOrNull(3)?.toDoubleOrNull() ?: 0.0)
|
||||
|
||||
ZapSplitSetup(
|
||||
it[1],
|
||||
it.getOrNull(2),
|
||||
weight,
|
||||
isLnAddress
|
||||
)
|
||||
if (weight > 0) {
|
||||
ZapSplitSetup(
|
||||
it[1],
|
||||
it.getOrNull(2),
|
||||
weight,
|
||||
isLnAddress
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.vitorpamplona.quartz.events
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.crypto.CryptoUtils
|
||||
import com.vitorpamplona.quartz.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.encoders.ATag
|
||||
import com.vitorpamplona.quartz.encoders.HexKey
|
||||
|
||||
class NIP24Factory {
|
||||
@@ -86,4 +87,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