Moves Relay information to Quartz
Renames Nip19 object for better readability
This commit is contained in:
@@ -30,10 +30,10 @@ data class ATag(val kind: Int, val pubKeyHex: String, val dTag: String, val rela
|
||||
fun toNAddr(): String {
|
||||
return TlvBuilder()
|
||||
.apply {
|
||||
addString(Nip19.TlvTypes.SPECIAL, dTag)
|
||||
addStringIfNotNull(Nip19.TlvTypes.RELAY, relay)
|
||||
addHex(Nip19.TlvTypes.AUTHOR, pubKeyHex)
|
||||
addInt(Nip19.TlvTypes.KIND, kind)
|
||||
addString(Nip19Bech32.TlvTypes.SPECIAL, dTag)
|
||||
addStringIfNotNull(Nip19Bech32.TlvTypes.RELAY, relay)
|
||||
addHex(Nip19Bech32.TlvTypes.AUTHOR, pubKeyHex)
|
||||
addInt(Nip19Bech32.TlvTypes.KIND, kind)
|
||||
}
|
||||
.build()
|
||||
.toNAddress()
|
||||
@@ -76,10 +76,10 @@ data class ATag(val kind: Int, val pubKeyHex: String, val dTag: String, val rela
|
||||
if (key.startsWith("naddr")) {
|
||||
val tlv = Tlv.parse(key.bechToBytes())
|
||||
|
||||
val d = tlv.firstAsString(Nip19.TlvTypes.SPECIAL) ?: ""
|
||||
val relay = tlv.firstAsString(Nip19.TlvTypes.RELAY)
|
||||
val author = tlv.firstAsHex(Nip19.TlvTypes.AUTHOR)
|
||||
val kind = tlv.firstAsInt(Nip19.TlvTypes.KIND)
|
||||
val d = tlv.firstAsString(Nip19Bech32.TlvTypes.SPECIAL) ?: ""
|
||||
val relay = tlv.firstAsString(Nip19Bech32.TlvTypes.RELAY)
|
||||
val author = tlv.firstAsHex(Nip19Bech32.TlvTypes.AUTHOR)
|
||||
val kind = tlv.firstAsInt(Nip19Bech32.TlvTypes.KIND)
|
||||
|
||||
if (kind != null && author != null) {
|
||||
return ATag(kind, author, d, relay)
|
||||
|
||||
@@ -23,14 +23,16 @@ package com.vitorpamplona.quartz.encoders
|
||||
import android.util.Log
|
||||
import java.util.regex.Pattern
|
||||
|
||||
val lnurlpPattern = Pattern.compile("(?i:http|https):\\/\\/((.+)\\/)*\\.well-known\\/lnurlp\\/(.*)")
|
||||
|
||||
class Lud06 {
|
||||
companion object {
|
||||
val LNURLP_PATTERN = Pattern.compile("(?i:http|https):\\/\\/((.+)\\/)*\\.well-known\\/lnurlp\\/(.*)")
|
||||
}
|
||||
|
||||
fun toLud16(str: String): String? {
|
||||
return try {
|
||||
val url = toLnUrlp(str)
|
||||
|
||||
val matcher = lnurlpPattern.matcher(url)
|
||||
val matcher = LNURLP_PATTERN.matcher(url)
|
||||
matcher.find()
|
||||
val domain = matcher.group(2)
|
||||
val username = matcher.group(3)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.quartz.encoders
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
|
||||
@Stable
|
||||
class Nip11RelayInformation(
|
||||
val id: String?,
|
||||
val name: String?,
|
||||
val description: String?,
|
||||
val pubkey: String?,
|
||||
val contact: String?,
|
||||
val supported_nips: List<Int>?,
|
||||
val supported_nip_extensions: List<String>?,
|
||||
val software: String?,
|
||||
val version: String?,
|
||||
val limitation: RelayInformationLimitation?,
|
||||
val relay_countries: List<String>?,
|
||||
val language_tags: List<String>?,
|
||||
val tags: List<String>?,
|
||||
val posting_policy: String?,
|
||||
val payments_url: String?,
|
||||
val fees: RelayInformationFees?,
|
||||
) {
|
||||
companion object {
|
||||
val mapper =
|
||||
jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
|
||||
fun fromJson(json: String): Nip11RelayInformation = mapper.readValue(json, Nip11RelayInformation::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
@Stable
|
||||
class RelayInformationFee(
|
||||
val amount: Int?,
|
||||
val unit: String?,
|
||||
val period: Int?,
|
||||
val kinds: List<Int>?,
|
||||
)
|
||||
|
||||
class RelayInformationFees(
|
||||
val admission: List<RelayInformationFee>?,
|
||||
val subscription: List<RelayInformationFee>?,
|
||||
val publication: List<RelayInformationFee>?,
|
||||
val retention: List<RelayInformationFee>?,
|
||||
)
|
||||
|
||||
class RelayInformationLimitation(
|
||||
val max_message_length: Int?,
|
||||
val max_subscriptions: Int?,
|
||||
val max_filters: Int?,
|
||||
val max_limit: Int?,
|
||||
val max_subid_length: Int?,
|
||||
val min_prefix: Int?,
|
||||
val max_event_tags: Int?,
|
||||
val max_content_length: Int?,
|
||||
val min_pow_difficulty: Int?,
|
||||
val auth_required: Boolean?,
|
||||
val payment_required: Boolean?,
|
||||
)
|
||||
+12
-12
@@ -25,7 +25,7 @@ import androidx.compose.runtime.Immutable
|
||||
import com.vitorpamplona.quartz.crypto.KeyPair
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object Nip19 {
|
||||
object Nip19Bech32 {
|
||||
enum class Type {
|
||||
USER,
|
||||
NOTE,
|
||||
@@ -173,7 +173,7 @@ object Nip19 {
|
||||
}
|
||||
|
||||
fun decodePublicKey(key: String): ByteArray {
|
||||
val parsed = Nip19.uriToRoute(key)
|
||||
val parsed = Nip19Bech32.uriToRoute(key)
|
||||
val pubKeyParsed = parsed?.hex?.hexToByteArray()
|
||||
|
||||
return if (key.startsWith("nsec")) {
|
||||
@@ -187,7 +187,7 @@ fun decodePublicKey(key: String): ByteArray {
|
||||
|
||||
fun decodePublicKeyAsHexOrNull(key: String): HexKey? {
|
||||
return try {
|
||||
val parsed = Nip19.uriToRoute(key)
|
||||
val parsed = Nip19Bech32.uriToRoute(key)
|
||||
val pubKeyParsed = parsed?.hex
|
||||
|
||||
if (key.startsWith("nsec")) {
|
||||
@@ -203,37 +203,37 @@ fun decodePublicKeyAsHexOrNull(key: String): HexKey? {
|
||||
}
|
||||
|
||||
fun TlvBuilder.addString(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
string: String,
|
||||
) = addString(type.id, string)
|
||||
|
||||
fun TlvBuilder.addHex(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
key: HexKey,
|
||||
) = addHex(type.id, key)
|
||||
|
||||
fun TlvBuilder.addInt(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
data: Int,
|
||||
) = addInt(type.id, data)
|
||||
|
||||
fun TlvBuilder.addStringIfNotNull(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
data: String?,
|
||||
) = addStringIfNotNull(type.id, data)
|
||||
|
||||
fun TlvBuilder.addHexIfNotNull(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
data: HexKey?,
|
||||
) = addHexIfNotNull(type.id, data)
|
||||
|
||||
fun TlvBuilder.addIntIfNotNull(
|
||||
type: Nip19.TlvTypes,
|
||||
type: Nip19Bech32.TlvTypes,
|
||||
data: Int?,
|
||||
) = addIntIfNotNull(type.id, data)
|
||||
|
||||
fun Tlv.firstAsInt(type: Nip19.TlvTypes) = firstAsInt(type.id)
|
||||
fun Tlv.firstAsInt(type: Nip19Bech32.TlvTypes) = firstAsInt(type.id)
|
||||
|
||||
fun Tlv.firstAsHex(type: Nip19.TlvTypes) = firstAsHex(type.id)
|
||||
fun Tlv.firstAsHex(type: Nip19Bech32.TlvTypes) = firstAsHex(type.id)
|
||||
|
||||
fun Tlv.firstAsString(type: Nip19.TlvTypes) = firstAsString(type.id)
|
||||
fun Tlv.firstAsString(type: Nip19Bech32.TlvTypes) = firstAsString(type.id)
|
||||
@@ -23,8 +23,8 @@ package com.vitorpamplona.quartz.events
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.vitorpamplona.quartz.encoders.HexKey
|
||||
import com.vitorpamplona.quartz.encoders.Nip19
|
||||
import com.vitorpamplona.quartz.encoders.Nip19.nip19regex
|
||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32.nip19regex
|
||||
import java.util.regex.Pattern
|
||||
|
||||
val tagSearch = Pattern.compile("(?:\\s|\\A)\\#\\[([0-9]+)\\]")
|
||||
@@ -93,10 +93,10 @@ open class BaseTextNoteEvent(
|
||||
val additionalChars = matcher2.group(4) // additional chars
|
||||
|
||||
try {
|
||||
val parsed = Nip19.parseComponents(uriScheme, type, key, additionalChars)
|
||||
val parsed = Nip19Bech32.parseComponents(uriScheme, type, key, additionalChars)
|
||||
|
||||
if (parsed != null) {
|
||||
if (parsed.type == Nip19.Type.USER) {
|
||||
if (parsed.type == Nip19Bech32.Type.USER) {
|
||||
returningList.add(parsed.hex)
|
||||
}
|
||||
}
|
||||
@@ -137,10 +137,10 @@ open class BaseTextNoteEvent(
|
||||
val key = matcher2.group(3) // bech32
|
||||
val additionalChars = matcher2.group(4) // additional chars
|
||||
|
||||
val parsed = Nip19.parseComponents(uriScheme, type, key, additionalChars)
|
||||
val parsed = Nip19Bech32.parseComponents(uriScheme, type, key, additionalChars)
|
||||
|
||||
if (parsed != null) {
|
||||
if (parsed.type == Nip19.Type.EVENT || parsed.type == Nip19.Type.ADDRESS || parsed.type == Nip19.Type.NOTE) {
|
||||
if (parsed.type == Nip19Bech32.Type.EVENT || parsed.type == Nip19Bech32.Type.ADDRESS || parsed.type == Nip19Bech32.Type.NOTE) {
|
||||
citations.add(parsed.hex)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.crypto.CryptoUtils
|
||||
import com.vitorpamplona.quartz.encoders.ATag
|
||||
import com.vitorpamplona.quartz.encoders.Hex
|
||||
import com.vitorpamplona.quartz.encoders.HexKey
|
||||
import com.vitorpamplona.quartz.encoders.Nip19
|
||||
import com.vitorpamplona.quartz.encoders.Nip19Bech32
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
@@ -253,7 +253,7 @@ open class Event(
|
||||
return if (this is AddressableEvent) {
|
||||
ATag(kind, pubKey, dTag(), null).toNAddr()
|
||||
} else {
|
||||
Nip19.createNEvent(id, pubKey, kind, null)
|
||||
Nip19Bech32.createNEvent(id, pubKey, kind, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParser() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:naddr1qqqqygzxpsj7dqha57pjk5k37gkn6g4nzakewtmqmnwryyhd3jfwlpgxtspsgqqqw4rs3xyxus",
|
||||
)
|
||||
assertEquals(
|
||||
@@ -39,7 +39,7 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParser2() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:naddr1qq8kwatfv3jj6amfwfjkwatpwfjqygxsm6lelvfda7qlg0tud9pfhduysy4vrexj65azqtdk4tr75j6xdspsgqqqw4rsg32ag8",
|
||||
)
|
||||
assertEquals(
|
||||
@@ -51,10 +51,10 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParse3() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"naddr1qqyrswtyv5mnjv3sqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsygx3uczxts4hwue9ayfn7ggq62anzstde2qs749pm9tx2csuthhpjvpsgqqqw4rs8pmj38",
|
||||
)
|
||||
assertEquals(Nip19.Type.ADDRESS, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.ADDRESS, result?.type)
|
||||
assertEquals(
|
||||
"30023:d1e60465c2b777325e9133f2100d2bb31416dca810f54a1d95665621c5dee193:89de7920",
|
||||
result?.hex,
|
||||
@@ -130,10 +130,10 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParserPablo() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"naddr1qq2hs7p30p6kcunxxamkgcnyd33xxve3veshyq3qyujphdcz69z6jafxpnldae3xtymdekfeatkt3r4qusr3w5krqspqxpqqqpaxjlg805f",
|
||||
)
|
||||
assertEquals(Nip19.Type.ADDRESS, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.ADDRESS, result?.type)
|
||||
assertEquals(
|
||||
"31337:27241bb702d145a975260cfedee6265936dcd939eaecb88ea0e4071752c30402:xx1xulrf7wdbdlbc31far",
|
||||
result?.hex,
|
||||
@@ -146,10 +146,10 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParserGizmo() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"naddr1qpqrvvfnvccrzdryxgunzvtxvgukge34xfjnqdpcv9sk2desxgmrscesvserzd3h8ycrywphvg6nsvf58ycnqef3v5mnsvt98pjnqdfs8ypzq3huhccxt6h34eupz3jeynjgjgek8lel2f4adaea0svyk94a3njdqvzqqqr4gudhrkyk",
|
||||
)
|
||||
assertEquals(Nip19.Type.ADDRESS, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.ADDRESS, result?.type)
|
||||
assertEquals(
|
||||
"30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:613f014d2911fb9df52e048aae70268c0d216790287b5814910e1e781e8e0509",
|
||||
result?.hex,
|
||||
@@ -162,10 +162,10 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nAddrParserGizmo2() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"naddr1qq9rzd3h8y6nqwf5xyuqygzxljlrqe027xh8sy2xtyjwfzfrxcll8afxh4hh847psjckhkxwf5psgqqqw4rsty50fx",
|
||||
)
|
||||
assertEquals(Nip19.Type.ADDRESS, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.ADDRESS, result?.type)
|
||||
assertEquals(
|
||||
"30023:46fcbe3065eaf1ae7811465924e48923363ff3f526bd6f73d7c184b16bd8ce4d:1679509418",
|
||||
result?.hex,
|
||||
@@ -178,8 +178,8 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventParserTest() {
|
||||
val result =
|
||||
Nip19.uriToRoute("nostr:nevent1qqs0tsw8hjacs4fppgdg7f5yhgwwfkyua4xcs3re9wwkpkk2qeu6mhql22rcy")
|
||||
assertEquals(Nip19.Type.EVENT, result?.type)
|
||||
Nip19Bech32.uriToRoute("nostr:nevent1qqs0tsw8hjacs4fppgdg7f5yhgwwfkyua4xcs3re9wwkpkk2qeu6mhql22rcy")
|
||||
assertEquals(Nip19Bech32.Type.EVENT, result?.type)
|
||||
assertEquals("f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc", result?.hex)
|
||||
assertEquals(null, result?.relay)
|
||||
assertEquals(null, result?.author)
|
||||
@@ -189,10 +189,10 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventParser() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:nevent1qqstvrl6wftd8ht4g0vrp6m30tjs6pdxcvk977g769dcvlptkzu4ftqppamhxue69uhkummnw3ezumt0d5pzp78lz8r60568sd2a8dx3wnj6gume02gxaf92vx4fk67qv5kpagt6qvzqqqqqqygqr86c",
|
||||
)
|
||||
assertEquals(Nip19.Type.EVENT, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.EVENT, result?.type)
|
||||
assertEquals("b60ffa7256d3dd7543d830eb717ae50d05a6c32c5f791ed15b867c2bb0b954ac", result?.hex)
|
||||
assertEquals("wss://nostr.mom", result?.relay)
|
||||
assertEquals("f8ff11c7a7d3478355d3b4d174e5a473797a906ea4aa61aa9b6bc0652c1ea17a", result?.author)
|
||||
@@ -202,11 +202,11 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventParser2() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:nevent1qqsplpuwsgrrmq85rfup6w3w777rxmcmadu590emfx6z4msj2844euqpz3mhxue69uhhyetvv9ujuerpd46hxtnfdupzq3svyhng9ld8sv44950j957j9vchdktj7cxumsep9mvvjthc2pjuqvzqqqqqqye3a70w",
|
||||
)
|
||||
|
||||
assertEquals(Nip19.Type.EVENT, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.EVENT, result?.type)
|
||||
assertEquals("1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0", result?.hex)
|
||||
assertEquals("wss://relay.damus.io", result?.relay)
|
||||
assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author)
|
||||
@@ -216,11 +216,11 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventParser3() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:nevent1qqsg6gechd3dhzx38n4z8a2lylzgsmmgeamhmtzz72m9ummsnf0xjfspsdmhxue69uhkummn9ekx7mpvwaehxw309ahx7um5wghx77r5wghxgetk93mhxue69uhhyetvv9ujumn0wd68ytnzvuk8wumn8ghj7mn0wd68ytn9d9h82mny0fmkzmn6d9njuumsv93k2trhwden5te0wfjkccte9ehx7um5wghxyctwvsk8wumn8ghj7un9d3shjtnyv9kh2uewd9hs3kqsdn",
|
||||
)
|
||||
|
||||
assertEquals(Nip19.Type.EVENT, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.EVENT, result?.type)
|
||||
assertEquals("8d2338bb62db88d13cea23f55f27c4886f68cf777dac42f2b65e6f709a5e6926", result?.hex)
|
||||
assertEquals(
|
||||
"wss://nos.lol,wss://nostr.oxtr.dev,wss://relay.nostr.bg,wss://nostr.einundzwanzig.space,wss://relay.nostr.band,wss://relay.damus.io",
|
||||
@@ -231,11 +231,11 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventParserInvalidChecksum() {
|
||||
val result =
|
||||
Nip19.uriToRoute(
|
||||
Nip19Bech32.uriToRoute(
|
||||
"nostr:nevent1qqsyxq8v0730nz38dupnjzp5jegkyz4gu2ptwcps4v32hjnrap0q0espz3mhxue69uhhyetvv9ujuerpd46hxtnfdupzq3svyhng9ld8sv44950j957j9vchdktj7cxumsep9mvvjthc2pjuqvzqqqqqqyn3t9gj",
|
||||
)
|
||||
|
||||
assertEquals(Nip19.Type.EVENT, result?.type)
|
||||
assertEquals(Nip19Bech32.Type.EVENT, result?.type)
|
||||
assertEquals("4300ec7fa2f98a276f033908349651620aa8e282b76030ab22abca63e85e07e6", result?.hex)
|
||||
assertEquals("wss://relay.damus.io", result?.relay)
|
||||
assertEquals("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c", result?.author)
|
||||
@@ -245,7 +245,7 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventFormatter() {
|
||||
val nevent =
|
||||
Nip19.createNEvent(
|
||||
Nip19Bech32.createNEvent(
|
||||
"f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc",
|
||||
null,
|
||||
null,
|
||||
@@ -257,7 +257,7 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventFormatterWithExtraInfo() {
|
||||
val nevent =
|
||||
Nip19.createNEvent(
|
||||
Nip19Bech32.createNEvent(
|
||||
"f5c1c7bcbb8855210a1a8f2684ba1ce4d89ced4d8844792b9d60daca0679addc",
|
||||
"7fa56f5d6962ab1e3cd424e758c3002b8665f7b0d8dcee9fe9e288d7751ac194",
|
||||
40,
|
||||
@@ -272,7 +272,7 @@ class NIP19ParserTest {
|
||||
@Test
|
||||
fun nEventFormatterWithFullInfo() {
|
||||
val nevent =
|
||||
Nip19.createNEvent(
|
||||
Nip19Bech32.createNEvent(
|
||||
"1f878e82063d80f41a781d3a2ef7bc336f1beb7942bf3b49b42aee1251eb5cf0",
|
||||
"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c",
|
||||
1,
|
||||
|
||||
+15
-15
@@ -24,17 +24,17 @@ import org.junit.Assert
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
|
||||
class Nip19Test {
|
||||
class Nip19Bech32Test {
|
||||
@Test()
|
||||
fun uri_to_route_null() {
|
||||
val actual = Nip19.uriToRoute(null)
|
||||
val actual = Nip19Bech32.uriToRoute(null)
|
||||
|
||||
Assert.assertEquals(null, actual)
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun uri_to_route_unknown() {
|
||||
val actual = Nip19.uriToRoute("nostr:unknown")
|
||||
val actual = Nip19Bech32.uriToRoute("nostr:unknown")
|
||||
|
||||
Assert.assertEquals(null, actual)
|
||||
}
|
||||
@@ -42,9 +42,9 @@ class Nip19Test {
|
||||
@Test()
|
||||
fun uri_to_route_npub() {
|
||||
val actual =
|
||||
Nip19.uriToRoute("nostr:npub1hv7k2s755n697sptva8vkh9jz40lzfzklnwj6ekewfmxp5crwdjs27007y")
|
||||
Nip19Bech32.uriToRoute("nostr:npub1hv7k2s755n697sptva8vkh9jz40lzfzklnwj6ekewfmxp5crwdjs27007y")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.USER, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.USER, actual?.type)
|
||||
Assert.assertEquals(
|
||||
"bb3d6543d4a4f45f402b674ecb5cb2155ff12456fcdd2d66d9727660d3037365",
|
||||
actual?.hex,
|
||||
@@ -54,9 +54,9 @@ class Nip19Test {
|
||||
@Test()
|
||||
fun uri_to_route_note() {
|
||||
val actual =
|
||||
Nip19.uriToRoute("nostr:note1stqea6wmwezg9x6yyr6qkukw95ewtdukyaztycws65l8wppjmtpscawevv")
|
||||
Nip19Bech32.uriToRoute("nostr:note1stqea6wmwezg9x6yyr6qkukw95ewtdukyaztycws65l8wppjmtpscawevv")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.NOTE, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.NOTE, actual?.type)
|
||||
Assert.assertEquals(
|
||||
"82c19ee9db7644829b4420f40b72ce2d32e5b7962744b261d0d53e770432dac3",
|
||||
actual?.hex,
|
||||
@@ -66,36 +66,36 @@ class Nip19Test {
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nprofile() {
|
||||
val actual = Nip19.uriToRoute("nostr:nprofile")
|
||||
val actual = Nip19Bech32.uriToRoute("nostr:nprofile")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.USER, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.USER, actual?.type)
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nevent() {
|
||||
val actual = Nip19.uriToRoute("nostr:nevent")
|
||||
val actual = Nip19Bech32.uriToRoute("nostr:nevent")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.USER, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.USER, actual?.type)
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_nrelay() {
|
||||
val actual = Nip19.uriToRoute("nostr:nrelay")
|
||||
val actual = Nip19Bech32.uriToRoute("nostr:nrelay")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.RELAY, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.RELAY, actual?.type)
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
|
||||
@Ignore("Test not implemented yet")
|
||||
@Test()
|
||||
fun uri_to_route_naddr() {
|
||||
val actual = Nip19.uriToRoute("nostr:naddr")
|
||||
val actual = Nip19Bech32.uriToRoute("nostr:naddr")
|
||||
|
||||
Assert.assertEquals(Nip19.Type.ADDRESS, actual?.type)
|
||||
Assert.assertEquals(Nip19Bech32.Type.ADDRESS, actual?.type)
|
||||
Assert.assertEquals("*", actual?.hex)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user