Skip to content

Commit

Permalink
chore: update bech32 and base64
Browse files Browse the repository at this point in the history
  • Loading branch information
lsunsi committed Mar 19, 2024
1 parent 629953b commit 86b4041
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
8 changes: 2 additions & 6 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@ pub fn resolve(s: &str) -> Result<Resolved, &'static str> {
}

fn resolve_bech32(s: &str) -> Result<url::Url, &'static str> {
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) = <Vec<u8> 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");
};
Expand Down

0 comments on commit 86b4041

Please sign in to comment.