diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/domain/nip46/NostrConnectLoginUseCase.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/domain/nip46/NostrConnectLoginUseCase.kt index 674a38219..6725ef332 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/domain/nip46/NostrConnectLoginUseCase.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/domain/nip46/NostrConnectLoginUseCase.kt @@ -213,6 +213,6 @@ object NostrConnectLoginUseCase { private fun generateSecret(): String { val bytes = ByteArray(32) SecureRandom().nextBytes(bytes) - return bytes.joinToString("") { "%02x".format(it) } + return bytes.toHexKey() } } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt index bc5af2432..271c2783b 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.quartz.nip47WalletConnect import com.vitorpamplona.quartz.nip01Core.core.HexKey +import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import kotlinx.coroutines.test.runTest @@ -44,7 +45,7 @@ class LnZapPaymentRequestEventTest { val walletKeyPair = KeyPair() val clientSigner = NostrSignerInternal(clientKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val event = LnZapPaymentRequestEvent.create( @@ -68,7 +69,7 @@ class LnZapPaymentRequestEventTest { val walletKeyPair = KeyPair() val clientSigner = NostrSignerInternal(clientKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val request = GetBalanceMethod.create() val event = @@ -92,7 +93,7 @@ class LnZapPaymentRequestEventTest { val walletKeyPair = KeyPair() val clientSigner = NostrSignerInternal(clientKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val request = GetBalanceMethod.create() val event = @@ -116,7 +117,7 @@ class LnZapPaymentRequestEventTest { val clientSigner = NostrSignerInternal(clientKeyPair) val walletSigner = NostrSignerInternal(walletKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val event = LnZapPaymentRequestEvent.create( @@ -139,7 +140,7 @@ class LnZapPaymentRequestEventTest { val clientSigner = NostrSignerInternal(clientKeyPair) val walletSigner = NostrSignerInternal(walletKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val request = MakeInvoiceMethod.create(5000L, "test payment") val event = @@ -163,7 +164,7 @@ class LnZapPaymentRequestEventTest { val clientSigner = NostrSignerInternal(clientKeyPair) val walletSigner = NostrSignerInternal(walletKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val request = GetInfoMethod.create() val event = @@ -191,7 +192,7 @@ class LnZapPaymentRequestEventTest { val walletSigner = NostrSignerInternal(walletKeyPair) val otherSigner = NostrSignerInternal(otherKeyPair) val walletServicePubkey: HexKey = - walletKeyPair.pubKey.joinToString("") { "%02x".format(it) } + walletKeyPair.pubKey.toHexKey() val event = LnZapPaymentRequestEvent.create( diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip05DnsIdentifiers/namecoin/ElectrumXClient.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip05DnsIdentifiers/namecoin/ElectrumXClient.kt index c56dd72b1..b0ba1d6b7 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip05DnsIdentifiers/namecoin/ElectrumXClient.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip05DnsIdentifiers/namecoin/ElectrumXClient.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.quartz.nip05DnsIdentifiers.namecoin +import com.vitorpamplona.quartz.nip01Core.core.toHexKey import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock @@ -277,7 +278,7 @@ class ElectrumXClient( */ private fun electrumScriptHash(script: ByteArray): String { val digest = MessageDigest.getInstance("SHA-256").digest(script) - return digest.reversedArray().joinToString("") { "%02x".format(it) } + return digest.reversedArray().toHexKey() } /**