From 86b4041d12d35f9aaf0fd57e2612180ae15f5ce4 Mon Sep 17 00:00:00 2001 From: Lucas Sunsi Abreu Date: Tue, 19 Mar 2024 16:19:39 -0300 Subject: [PATCH] chore: update bech32 and base64 --- Cargo.toml | 4 ++-- src/core.rs | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bd471d6..e35ba0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ license = "GPL-3.0-only" readme = "README.md" [dependencies] -base64 = { version = "0.21.0", features = ["std"], default-features = false } -bech32 = { version = "0.9.0", default-features = false } +base64 = { version = "0.22.0", features = ["std"], default-features = false } +bech32 = { version = "0.11.0", features = ["alloc"], default-features = false } hex = { version = "0.4.3", features = ["std", "serde"], default-features = false } serde = { version = "1.0.0", features = ["derive"], default-features = false } serde_json = { version = "1.0.0", features = ["std"], default-features = false } diff --git a/src/core.rs b/src/core.rs index 6144240..ad3c4ac 100644 --- a/src/core.rs +++ b/src/core.rs @@ -41,18 +41,14 @@ pub fn resolve(s: &str) -> Result { } fn resolve_bech32(s: &str) -> Result { - let Ok((hrp, data, _)) = bech32::decode(s) else { + let Ok((hrp, bytes)) = bech32::decode(s) else { return Err("bech32 decode failed"); }; - if hrp != "lnurl" { + if hrp.to_lowercase() != "lnurl" { return Err("bech32 hrp invalid"); } - let Ok(bytes) = as bech32::FromBase32>::from_base32(&data) else { - return Err("bech32 data is not bytes"); - }; - let Ok(text) = String::from_utf8(bytes) else { return Err("bech32 bytes is not string"); };