diff --git a/anychain-neo/src/address.rs b/anychain-neo/src/address.rs index 17eefd5..d9246f7 100644 --- a/anychain-neo/src/address.rs +++ b/anychain-neo/src/address.rs @@ -61,6 +61,14 @@ impl FromStr for NeoAddress { type Err = AddressError; fn from_str(s: &str) -> Result { + 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())) } }