From 73e3b607211b800ecac92556819f056f92de2674 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 28 Feb 2024 16:50:23 -0500 Subject: [PATCH] Fixes missing nsec processing --- .../java/com/vitorpamplona/quartz/encoders/Nip19Bech32.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/encoders/Nip19Bech32.kt b/quartz/src/main/java/com/vitorpamplona/quartz/encoders/Nip19Bech32.kt index 0516f1916..de2e719b3 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/encoders/Nip19Bech32.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/encoders/Nip19Bech32.kt @@ -111,6 +111,7 @@ object Nip19Bech32 { val bytes = (type + key).bechToBytes() when (type.lowercase()) { + "nsec1" -> nsec(bytes) "npub1" -> npub(bytes) "note1" -> note(bytes) "nprofile1" -> nprofile(bytes) @@ -133,6 +134,11 @@ object Nip19Bech32 { return NEmbed(Event.fromJson(ungzip(bytes))) } + private fun nsec(bytes: ByteArray): NSec? { + if (bytes.isEmpty()) return null + return NSec(bytes.toHexKey()) + } + private fun npub(bytes: ByteArray): NPub? { if (bytes.isEmpty()) return null return NPub(bytes.toHexKey())