Remove unused variants from `Address::Error`

This commit is contained in:
harshit933 2024-02-23 03:36:35 +05:30
parent 05b24946eb
commit 5182a8d7a8
1 changed files with 1 additions and 20 deletions

View File

@ -13,14 +13,8 @@ use crate::{base58, Network};
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] #[non_exhaustive]
pub enum Error { pub enum Error {
/// A witness version construction error.
WitnessVersion(witness_version::TryFromError),
/// A witness program error.
WitnessProgram(witness_program::Error),
/// Address size more than 520 bytes is not allowed. /// Address size more than 520 bytes is not allowed.
ExcessiveScriptSize, ExcessiveScriptSize,
/// Script is not a p2pkh, p2sh or witness program.
UnrecognizedScript,
/// Address's network differs from required one. /// Address's network differs from required one.
NetworkValidation { NetworkValidation {
/// Network that was required. /// Network that was required.
@ -37,10 +31,7 @@ impl fmt::Display for Error {
use Error::*; use Error::*;
match *self { match *self {
WitnessVersion(ref e) => write_err!(f, "witness version construction error"; e),
WitnessProgram(ref e) => write_err!(f, "witness program error"; e),
ExcessiveScriptSize => write!(f, "script size exceed 520 bytes"), ExcessiveScriptSize => write!(f, "script size exceed 520 bytes"),
UnrecognizedScript => write!(f, "script is not a p2pkh, p2sh or witness program"),
NetworkValidation { required, ref address } => { NetworkValidation { required, ref address } => {
write!(f, "address ")?; write!(f, "address ")?;
fmt::Display::fmt(&address.0, f)?; fmt::Display::fmt(&address.0, f)?;
@ -57,22 +48,12 @@ impl std::error::Error for Error {
use Error::*; use Error::*;
match self { match self {
WitnessVersion(e) => Some(e),
WitnessProgram(e) => Some(e),
UnknownHrp(e) => Some(e), UnknownHrp(e) => Some(e),
ExcessiveScriptSize | UnrecognizedScript | NetworkValidation { .. } => None, ExcessiveScriptSize | NetworkValidation { .. } => None,
} }
} }
} }
impl From<witness_version::TryFromError> for Error {
fn from(e: witness_version::TryFromError) -> Error { Error::WitnessVersion(e) }
}
impl From<witness_program::Error> for Error {
fn from(e: witness_program::Error) -> Error { Error::WitnessProgram(e) }
}
/// Error while generating address from script. /// Error while generating address from script.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum FromScriptError { pub enum FromScriptError {