use std::{error, fmt};
use crate::Error;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum CovError {
MissingScriptCode,
MissingValue,
MissingSighashItem(u8),
MissingCovSignature,
BadCovDescriptor,
CovenantLift,
CovenantSighashTypeMismatch,
}
impl fmt::Display for CovError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
CovError::MissingScriptCode => write!(f, "Missing Script code"),
CovError::MissingValue => write!(f, "Missing value"),
CovError::BadCovDescriptor => write!(f, "Bad or Malformed covenant descriptor"),
CovError::CovenantLift => write!(f, "Cannot lift a covenant descriptor"),
CovError::MissingSighashItem(i) => {
write!(f, "Missing sighash item # : {} in satisfier", i)
}
CovError::MissingCovSignature => write!(f, "Missing signature over the covenant pk"),
CovError::CovenantSighashTypeMismatch => write!(
f,
"The sighash type provided in the witness must the same \
as the one used in signature"
),
}
}
}
impl error::Error for CovError {}
#[doc(hidden)]
impl From<CovError> for Error {
fn from(e: CovError) -> Error {
Error::CovError(e)
}
}