Skip to content

Commit

Permalink
Changes for v1.0-beta-09, cont'd
Browse files Browse the repository at this point in the history
Change API name from uriToRoute() to parse().
  • Loading branch information
KotlinGeekDev authored Feb 14, 2025
2 parents e41421b + b94aec8 commit 417dd58
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rhodium-core/src/commonMain/kotlin/rhodium/crypto/Nip19Parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object Nip19Parser {
return null
}

fun uriToRoute(uri: String?): ParseReturn? {
fun parse(uri: String?): ParseReturn? {
if (uri == null) return null

try {
Expand Down Expand Up @@ -159,7 +159,7 @@ object Nip19Parser {
}

fun decodePublicKey(key: String): ByteArray =
when (val parsed = Nip19Parser.uriToRoute(key)?.entity) {
when (val parsed = Nip19Parser.parse(key)?.entity) {
is NSec -> Identity(privKey = key.bechToBytes()).pubKey
is NPub -> parsed.hex.toBytes()
is NProfile -> parsed.hex.toBytes()
Expand All @@ -168,7 +168,7 @@ fun decodePublicKey(key: String): ByteArray =

fun decodePrivateKeyAsHexOrNull(key: String): String? =
try {
when (val parsed = Nip19Parser.uriToRoute(key)?.entity) {
when (val parsed = Nip19Parser.parse(key)?.entity) {
is NSec -> parsed.hex
is NPub -> null
is NProfile -> null
Expand All @@ -186,7 +186,7 @@ fun decodePrivateKeyAsHexOrNull(key: String): String? =

fun decodePublicKeyAsHexOrNull(key: String): String? =
try {
when (val parsed = Nip19Parser.uriToRoute(key)?.entity) {
when (val parsed = Nip19Parser.parse(key)?.entity) {
is NSec -> Identity(privKey = key.bechToBytes()).pubKey.toHexString()
is NPub -> parsed.hex
is NProfile -> parsed.hex
Expand All @@ -204,7 +204,7 @@ fun decodePublicKeyAsHexOrNull(key: String): String? =

fun decodeEventIdAsHexOrNull(key: String): String? =
try {
when (val parsed = Nip19Parser.uriToRoute(key)?.entity) {
when (val parsed = Nip19Parser.parse(key)?.entity) {
is NSec -> null
is NPub -> null
is NProfile -> null
Expand Down

0 comments on commit 417dd58

Please sign in to comment.