Adds a method to create nprofiles without creating a relay list first

This commit is contained in:
Vitor Pamplona
2025-08-06 17:54:34 -04:00
parent dddc9e1346
commit 1b043603f9

View File

@@ -51,6 +51,19 @@ data class NProfile(
return NProfile(hex, relay.mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) })
}
fun create(
authorPubKeyHex: String,
relay: NormalizedRelayUrl?,
): String =
TlvBuilder()
.apply {
addHex(TlvTypes.SPECIAL, authorPubKeyHex)
if (relay != null) {
addStringIfNotNull(TlvTypes.RELAY, relay.url)
}
}.build()
.toNProfile()
fun create(
authorPubKeyHex: String,
relays: List<NormalizedRelayUrl>,