Skip to content

Commit

Permalink
Merge pull request #416 from str4d/ua-parser-checks
Browse files Browse the repository at this point in the history
Add Unified Address parser structural checks
  • Loading branch information
str4d authored Jul 12, 2021
2 parents 8b4ae55 + b875f6c commit 1a40fc9
Show file tree
Hide file tree
Showing 2 changed files with 336 additions and 24 deletions.
12 changes: 12 additions & 0 deletions components/zcash_address/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@ pub enum ParseError {
InvalidEncoding,
/// The string is not a Zcash address.
NotZcash,
/// Errors specific to unified addresses.
Unified(unified::ParseError),
}

impl From<unified::ParseError> for ParseError {
fn from(e: unified::ParseError) -> Self {
match e {
unified::ParseError::InvalidEncoding => Self::InvalidEncoding,
_ => Self::Unified(e),
}
}
}

impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ParseError::InvalidEncoding => write!(f, "Invalid encoding"),
ParseError::NotZcash => write!(f, "Not a Zcash address"),
ParseError::Unified(e) => e.fmt(f),
}
}
}
Expand Down
Loading

0 comments on commit 1a40fc9

Please sign in to comment.