Skip to content

Commit

Permalink
Merge branch '138-feat-anychain-neo' of https://github.com/0xcregis/a…
Browse files Browse the repository at this point in the history
…nychain into 138-feat-anychain-neo
  • Loading branch information
shuimuliang committed Oct 26, 2023
2 parents ba58665 + f90b901 commit 090ad01
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions anychain-neo/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ impl FromStr for NeoAddress {
type Err = AddressError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let bytes = s.from_base58()?;
let checksum_provided = bytes[21..].to_vec();
let checksum_gen = checksum(&bytes[..21])[..4].to_vec();

if checksum_gen != checksum_provided {
return Err(AddressError::Message(format!("Invalid address {}", s)));
}

Ok(Self(s.to_string()))
}
}
Expand Down

0 comments on commit 090ad01

Please sign in to comment.