add support for private zaps

This commit is contained in:
greenart7c3
2023-09-11 15:30:00 -03:00
parent a773be12c4
commit ff4d704bde
5 changed files with 162 additions and 52 deletions
@@ -61,6 +61,22 @@ class LnZapPaymentResponseEvent(
}
}
fun response(decryptedContent: String): Response? {
if (response != null) response
return try {
if (content.isNotEmpty()) {
response = mapper.readValue(decryptedContent, Response::class.java)
response
} else {
null
}
} catch (e: Exception) {
Log.w("LnZapPaymentResponseEvent", "Can't parse content as a payment response: $content", e)
null
}
}
companion object {
const val kind = 23195
}
@@ -123,6 +123,32 @@ class LnZapRequestEvent(
return LnZapRequestEvent(id.toHexKey(), pubKey, createdAt, tags, message, "")
}
fun createPrivateZap(
originalNote: EventInterface,
relays: Set<String>,
pubKey: HexKey,
pollOption: Int?,
message: String,
createdAt: Long = TimeUtils.now()
): LnZapRequestEvent {
val content = message
var tags = listOf(
listOf("e", originalNote.id()),
listOf("p", originalNote.pubKey()),
listOf("relays") + relays
)
if (originalNote is AddressableEvent) {
tags = tags + listOf(listOf("a", originalNote.address().toTag()))
}
if (pollOption != null && pollOption >= 0) {
tags = tags + listOf(listOf(POLL_OPTION, pollOption.toString()))
}
tags = tags + listOf(listOf("anon", ""))
return LnZapRequestEvent("", pubKey, createdAt, tags, content, "")
}
fun createAnonymous(
originalNote: EventInterface,
relays: Set<String>,